resupply-insurance
This skill should be used when the user asks about "insurance pool", "reIP", "InsurancePool", "protocol insurance", "bad debt coverage", "exit delay"…
by FDU-INS★ 84 GitHub stars
Install resupply-insurance in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Resupply Insurance Pool
The Insurance Pool (reIP) is an ERC4626 vault that provides coverage against protocol insolvency and bad debt. Located in /src/protocol/InsurancePool.sol.
Overview
The Insurance Pool:
- Accepts reUSD deposits from users
- Issues reIP shares representing ownership
- Covers bad debt from liquidations
- Earns rewards from protocol fees
- Has a 7-day exit delay for withdrawals
InsurancePool Contract
contract InsurancePool is ERC4626, RewardDistributorMultiEpoch {
// Exit delay configuration
uint256 public constant EXIT_DELAY = 7 days;
// Pending withdrawal tracking
struct PendingWithdrawal {
uint256 shares;
uint256 unlockTime;
}
mapping(address => PendingWithdrawal) public pendingWithdrawals;
// Bad debt tracking
uint256 public totalBadDebt;
uint256 public coveredBadDebt;
}
Depositing to Insurance Pool
Deposit reUSD to receive reIP shares:
// Standard ERC4626 deposit
function deposit(uint256 assets, address receiver) public returns (uint256 shares) {
shares = previewDeposit(assets);
// Transfer reUSD from depositor
IERC20(asset()).safeTransferFrom(msg.sender, address(this), assets);
// Mint reIP shares
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
}
// Share calculation
function previewDeposit(uint256 assets) public view returns (uint256) {
uint256 supply = totalSupply();
uint256 totalAssets = totalAssets();
if (supply == 0) return assets;
return (assets * supply) / totalAssets;
}
Withdrawal Process
Withdrawals require a two-step process with a 7-day delay:
Step 1: Request Withdrawal
function requestWithdrawal(uint256 shares) external {
require(balanceOf(msg.sender) >= shares, "Insufficient shares");
// Lock shares
_transfer(msg.sender, address(this), shares);
// Set unlock time
pendingWithdrawals[msg.sender] = PendingWithdrawal({
shares: shares,
unlockTime: block.timestamp + EXIT_DELAY
});
emit WithdrawalRequested(msg.sender, shares, block.timestamp + EXIT_DELAY);
}
Step 2: Complete Withdrawal
function completeWithdrawal() external returns (uint256 assets) {
PendingWithdrawal memory pending = pendingWithdrawals[msg.sender];
require(pending.shares > 0, "No pending withdrawal");
require(block.timestamp >= pending.unlockTime, "Still locked");
// Calculate assets
assets = previewRedeem(pending.shares);
// Clear pending
delete pendingWithdrawals[msg.sender];
// Burn shares and transfer assets
_burn(address(this), pending.shares);
IERC20(asset()).safeTransfer(msg.sender, assets);
emit Withdraw(msg.sender, msg.sender, msg.sender, assets, pending.shares);
}
Cancel Withdrawal
function cancelWithdrawal() external {
PendingWithdrawal memory pending = pendingWithdrawals[msg.sender];
require(pending.shares > 0, "No pending withdrawal");
// Return shares
_transfer(address(this), msg.sender, pending.shares);
delete pendingWithdrawals[msg.sender];
emit WithdrawalCancelled(msg.sender, pending.shares);
}
Bad Debt Coverage
The insurance pool covers bad debt from undercollateralized liquidations:
function coverBadDebt(uint256 amount) external onlyLiquidationHandler {
uint256 available = totalAssets();
if (available >= amount) {
// Full coverage - burn reUSD
IStablecoin(asset()).burn(address(this), amount);
coveredBadDebt += amount;
} else {
// Partial coverage
if (available > 0) {
IStablecoin(asset()).burn(address(this), available);
coveredBadDebt += available;
}
// Remaining is protocol loss
totalBadDebt += (amount - available);
}
emit BadDebtCovered(amount, available);
}
Impact on Share Value
Bad debt coverage reduces total assets, affecting share value:
// Before bad debt: 1000 reUSD, 1000 shares → 1 reUSD/share
// After 100 reUSD bad debt: 900 reUSD, 1000 shares → 0.9 reUSD/share
function totalAssets() public view returns (uint256) {
return IERC20(asset()).balanceOf(address(this));
}
Reward Distribution
Insurance pool participants earn rewards:
Reward Sources
- Protocol fees: Share of interest and redemption fees
- Liquidation fees: Portion of liquidation proceeds
- RSUP emissions: Governance token rewards
Claiming Rewards
function getReward(address _account) external {
_checkpoint(_account);
for (uint256 i = 0; i < rewardTokens.length; i++) {
address token = rewardTokens[i];
uint256 reward = earned(_account, token);
if (reward > 0) {
rewards[_account][token] = 0;
IERC20(token).safeTransfer(_account, reward);
}
}
}
Reward Tracking
// Per-epoch
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the resupply-insurance skill do?
This skill should be used when the user asks about "insurance pool", "reIP", "InsurancePool", "protocol insurance", "bad debt coverage", "exit delay", "insurance vault", or needs to understand Resupply's insurance mechanism.
How do I install the resupply-insurance skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the resupply-insurance skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…