|
| 1 | +--- |
| 2 | +title: ICollateralPool |
| 3 | +description: FAssets ICollateralPool interface reference. |
| 4 | +keywords: [fassets, xrp, bitcoin, dogecoin, flare-network] |
| 5 | +sidebar_position: 6 |
| 6 | +--- |
| 7 | + |
| 8 | +Command line reference for interacting with FAssets `ICollateralPool` contract. |
| 9 | + |
| 10 | +Sourced from `ICollateralPool.sol` on [GitHub](https://github.com/flare-foundation/fassets/blob/main/contracts/userInterfaces/ICollateralPool.sol). |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Overview |
| 15 | + |
| 16 | +This interface is used by pool participants and the agent vault owner to manage collateral, fees, and reward delegation. |
| 17 | + |
| 18 | +## Functions |
| 19 | + |
| 20 | +### `enter` |
| 21 | + |
| 22 | +Enters an agent's collateral pool by depositing NAT, where tokens are timelocked and may carry [fee debt](/fassets/collateral#minting-fees-and-debt) if FAsset fees already exist in the pool. |
| 23 | +This debt must be cleared before tokens can be transferred. |
| 24 | + |
| 25 | +Parameters: |
| 26 | + |
| 27 | +- `_executor`: The account that is allowed to execute the entry (besides the user and agent). |
| 28 | + |
| 29 | +Returns: |
| 30 | + |
| 31 | +- `_receivedTokens`: The amount of pool tokens received. |
| 32 | +- `_timelockExpiresAt`: The timestamp when the timelock expires. |
| 33 | + |
| 34 | +```solidity |
| 35 | +function enter() |
| 36 | + external payable |
| 37 | + returns (uint256 _receivedTokens, uint256 _timelockExpiresAt); |
| 38 | +``` |
| 39 | + |
| 40 | +### `exit` |
| 41 | + |
| 42 | +Exits the pool by redeeming pool tokens for a share of NAT and FAsset fees. |
| 43 | +Reverts if exiting would drop the collateral ratio below the exit [CR](/fassets/collateral#collateral-ratio). |
| 44 | + |
| 45 | +Parameters: |
| 46 | + |
| 47 | +- `_tokenShare`: Amount of pool tokens to redeem. |
| 48 | + |
| 49 | +Returns: |
| 50 | + |
| 51 | +- `_natShare`: Amount of NAT received. |
| 52 | + |
| 53 | +```solidity |
| 54 | +function exit(uint256 _tokenShare) |
| 55 | + external |
| 56 | + returns (uint256 _natShare); |
| 57 | +``` |
| 58 | + |
| 59 | +### `selfCloseExit` |
| 60 | + |
| 61 | +Exits the pool by redeeming pool tokens and burning FAssets while preserving the pool's collateral ratio. |
| 62 | +FAssets are redeemed into collateral if their value does not exceed one [lot](/fassets/minting#lots). |
| 63 | + |
| 64 | +Parameters: |
| 65 | + |
| 66 | +- `_tokenShare`: The amount of pool tokens to be liquidated. |
| 67 | +- `_redeemToCollateral`: Specifies if redeemed FAssets should be exchanged to vault collateral by the agent. |
| 68 | +- `_redeemerUnderlyingAddress`: Redeemer's address on the underlying chain. |
| 69 | +- `_executor`: The account that is allowed to execute redemption. |
| 70 | + |
| 71 | +```solidity |
| 72 | +function selfCloseExit( |
| 73 | + uint256 _tokenShare, |
| 74 | + bool _redeemToCollateral, |
| 75 | + string memory _redeemerUnderlyingAddress, |
| 76 | + address payable _executor |
| 77 | +) external payable; |
| 78 | +``` |
| 79 | + |
| 80 | +### `withdrawFees` |
| 81 | + |
| 82 | +Collects FAsset fees by locking an appropriate ratio of transferable tokens. |
| 83 | + |
| 84 | +Parameters: |
| 85 | + |
| 86 | +- `_amount`: The amount of FAsset fees to withdraw (must be positive and smaller than or equal to the sender's FAsset fees). |
| 87 | + |
| 88 | +```solidity |
| 89 | +function withdrawFees(uint256 _amount) external; |
| 90 | +``` |
| 91 | + |
| 92 | +### `exitTo` |
| 93 | + |
| 94 | +Exits the pool by redeeming pool tokens for a share of NAT and FAsset fees and transferring them to a recipient. |
| 95 | +Reverts if exiting would drop the collateral ratio below the exit [CR](/fassets/collateral#collateral-ratio). |
| 96 | + |
| 97 | +Parameters: |
| 98 | + |
| 99 | +- `_tokenShare`: The amount of pool tokens to be redeemed. |
| 100 | +- `_recipient`: Recipient address for NATs and FAsset fees. |
| 101 | + |
| 102 | +Returns: |
| 103 | + |
| 104 | +- `_natShare`: The amount of NAT received. |
| 105 | + |
| 106 | +```solidity |
| 107 | +function exitTo(uint256 _tokenShare, address payable _recipient) |
| 108 | + external |
| 109 | + returns (uint256 _natShare); |
| 110 | +``` |
| 111 | + |
| 112 | +### `selfCloseExitTo` |
| 113 | + |
| 114 | +Exits the pool by redeeming pool tokens and burning FAssets, while preserving the pool's collateral ratio and allowing a recipient to be specified. |
| 115 | +FAssets are redeemed into collateral if their value does not exceed one [lot](/fassets/minting#lots). |
| 116 | + |
| 117 | +Parameters: |
| 118 | + |
| 119 | +- `_tokenShare`: The amount of pool tokens to be liquidated. |
| 120 | +- `_redeemToCollateral`: Specifies if redeemed FAssets should be exchanged to vault collateral by the agent. |
| 121 | +- `_recipient`: Recipient address for NATs and FAsset fees. |
| 122 | +- `_redeemerUnderlyingAddress`: Redeemer's address on the underlying chain. |
| 123 | +- `_executor`: The account that is allowed to execute redemption default. |
| 124 | + |
| 125 | +```solidity |
| 126 | +function selfCloseExitTo( |
| 127 | + uint256 _tokenShare, |
| 128 | + bool _redeemToCollateral, |
| 129 | + address payable _recipient, |
| 130 | + string memory _redeemerUnderlyingAddress, |
| 131 | + address payable _executor |
| 132 | +) external payable; |
| 133 | +``` |
| 134 | + |
| 135 | +### `withdrawFeesTo` |
| 136 | + |
| 137 | +Collect FAsset fees by locking an appropriate ratio of transferable tokens and transferring them to a recipient. |
| 138 | + |
| 139 | +Parameters: |
| 140 | + |
| 141 | +- `_amount`: The amount of FAsset fees to withdraw (must be positive and smaller than or equal to the sender's FAsset fees). |
| 142 | +- `_recipient`: The address to which FAsset fees will be transferred. |
| 143 | + |
| 144 | +```solidity |
| 145 | +function withdrawFeesTo(uint256 _amount, address _recipient) external; |
| 146 | +``` |
| 147 | + |
| 148 | +### `payFAssetFeeDebt` |
| 149 | + |
| 150 | +Unlocks pool tokens by paying the FAsset fee debt. |
| 151 | + |
| 152 | +Parameters: |
| 153 | + |
| 154 | +- `_fassets`: The amount of debt FAsset fees to pay for. |
| 155 | + |
| 156 | +```solidity |
| 157 | +function payFAssetFeeDebt(uint256 _fassets) external; |
| 158 | +``` |
| 159 | + |
| 160 | +### `claimAirdropDistribution` |
| 161 | + |
| 162 | +Claim airdrops earned by holding wrapped native tokens in the pool. |
| 163 | +Only the owner of the pool's corresponding agent vault may call this method. |
| 164 | + |
| 165 | +Parameters: |
| 166 | + |
| 167 | +- `_distribution`: The distribution contract to claim from. |
| 168 | +- `_month`: The month for which to claim the airdrop. |
| 169 | + |
| 170 | +Returns: |
| 171 | + |
| 172 | +- `_claimedAmount`: The amount of claimed airdrop. |
| 173 | + |
| 174 | +```solidity |
| 175 | +function claimAirdropDistribution( |
| 176 | + IDistributionToDelegators _distribution, |
| 177 | + uint256 _month |
| 178 | +) external |
| 179 | + returns(uint256 _claimedAmount); |
| 180 | +``` |
| 181 | + |
| 182 | +### `optOutOfAirdrop` |
| 183 | + |
| 184 | +Opt out of airdrops for wrapped native tokens in the pool. |
| 185 | +Only the owner of the pool's corresponding agent vault may call this method. |
| 186 | + |
| 187 | +Parameters: |
| 188 | + |
| 189 | +- `_distribution`: The distribution contract to opt out of. |
| 190 | + |
| 191 | +```solidity |
| 192 | +function optOutOfAirdrop( |
| 193 | + IDistributionToDelegators _distribution |
| 194 | +) external; |
| 195 | +``` |
| 196 | + |
| 197 | +### `delegate` |
| 198 | + |
| 199 | +Delegate WNat vote power for the wrapped native tokens held in this vault. |
| 200 | +Only the owner of the pool's corresponding agent vault may call this method. |
| 201 | + |
| 202 | +Parameters: |
| 203 | + |
| 204 | +- `_to`: The address to delegate to. |
| 205 | +- `_bips`: The delegation percentage in basis points (10000 = 100%). |
| 206 | + |
| 207 | +```solidity |
| 208 | +function delegate(address _to, uint256 _bips) external; |
| 209 | +``` |
| 210 | + |
| 211 | +### `undelegateAll` |
| 212 | + |
| 213 | +Clear WNat delegation for the wrapped native tokens held in this vault. |
| 214 | + |
| 215 | +```solidity |
| 216 | +function undelegateAll() external; |
| 217 | +``` |
| 218 | + |
| 219 | +### `claimDelegationRewards` |
| 220 | + |
| 221 | +Claim the rewards earned by delegating the voting power for the pool. |
| 222 | +Only the owner of the pool's corresponding agent vault may call this method. |
| 223 | + |
| 224 | +Parameters: |
| 225 | + |
| 226 | +- `_rewardManager`: The reward manager contract. |
| 227 | +- `_lastRewardEpoch`: The last reward epoch that was claimed. |
| 228 | +- `_proofs`: Array of reward claims with proofs. |
| 229 | + |
| 230 | +Returns: |
| 231 | + |
| 232 | +- `_claimedAmount`: The amount of claimed rewards. |
| 233 | + |
| 234 | +```solidity |
| 235 | +function claimDelegationRewards( |
| 236 | + IRewardManager _rewardManager, |
| 237 | + uint24 _lastRewardEpoch, |
| 238 | + IRewardManager.RewardClaimWithProof[] calldata _proofs |
| 239 | +) external |
| 240 | + returns(uint256 _claimedAmount); |
| 241 | +``` |
| 242 | + |
| 243 | +## View Functions |
| 244 | + |
| 245 | +### `poolToken` |
| 246 | + |
| 247 | +Get the ERC20 pool token used by this collateral pool. |
| 248 | + |
| 249 | +Returns: |
| 250 | + |
| 251 | +- `ICollateralPoolToken`: The pool token contract. |
| 252 | + |
| 253 | +```solidity |
| 254 | +function poolToken() |
| 255 | + external view |
| 256 | + returns (ICollateralPoolToken); |
| 257 | +``` |
| 258 | + |
| 259 | +### `agentVault` |
| 260 | + |
| 261 | +Get the vault of the agent that owns this collateral pool. |
| 262 | + |
| 263 | +Returns: |
| 264 | + |
| 265 | +- `address`: The agent vault address. |
| 266 | + |
| 267 | +```solidity |
| 268 | +function agentVault() |
| 269 | + external view |
| 270 | + returns (address); |
| 271 | +``` |
| 272 | + |
| 273 | +### `exitCollateralRatioBIPS` |
| 274 | + |
| 275 | +Get the exit collateral ratio in BIPS. |
| 276 | +This is the collateral ratio below which exiting the pool is not allowed. |
| 277 | + |
| 278 | +Returns: |
| 279 | + |
| 280 | +- `uint32`: The exit collateral ratio in BIPS. |
| 281 | + |
| 282 | +```solidity |
| 283 | +function exitCollateralRatioBIPS() |
| 284 | + external view |
| 285 | + returns (uint32); |
| 286 | +``` |
| 287 | + |
| 288 | +### `totalCollateral` |
| 289 | + |
| 290 | +Returns the total amount of collateral in the pool. |
| 291 | +This can differ from [`WNat.balanceOf(poolAddress)`](/network/solidity-reference/IWNat#balanceof) because the collateral must be tracked to prevent unexpected deposit type attacks on the pool. |
| 292 | + |
| 293 | +Returns: |
| 294 | + |
| 295 | +- `uint256`: Total collateral amount. |
| 296 | + |
| 297 | +```solidity |
| 298 | +function totalCollateral() |
| 299 | + external view |
| 300 | + returns (uint256); |
| 301 | +``` |
| 302 | + |
| 303 | +### `fAssetFeesOf` |
| 304 | + |
| 305 | +Returns the FAsset fees belonging to a specific user. |
| 306 | +It is the amount of FAssets the user can withdraw by burning transferable pool tokens. |
| 307 | + |
| 308 | +Parameters: |
| 309 | + |
| 310 | +- `_account`: User address. |
| 311 | + |
| 312 | +Returns: |
| 313 | + |
| 314 | +- `uint256`: Amount of FAsset fees belonging to the user. |
| 315 | + |
| 316 | +```solidity |
| 317 | +function fAssetFeesOf(address _account) |
| 318 | + external view |
| 319 | + returns (uint256); |
| 320 | +``` |
| 321 | + |
| 322 | +### `totalFAssetFees` |
| 323 | + |
| 324 | +Returns the total FAsset fees in the pool. |
| 325 | +It may differ from `FAsset.balanceOf(poolAddress)` because the collateral must be tracked to prevent unexpected deposit type attacks on the pool. |
| 326 | + |
| 327 | +Returns: |
| 328 | + |
| 329 | +- `uint256`: Total FAsset fees in the pool. |
| 330 | + |
| 331 | +```solidity |
| 332 | +function totalFAssetFees() |
| 333 | + external view |
| 334 | + returns (uint256); |
| 335 | +``` |
| 336 | + |
| 337 | +### `fAssetFeeDebtOf` |
| 338 | + |
| 339 | +Returns the user's FAsset fee debt. |
| 340 | +This is the amount of FAssets the user has to pay to make all pool tokens transferable. |
| 341 | +The debt is created on entering the pool if the user does not provide the FAssets corresponding to the share of the FAsset fees already in the pool. |
| 342 | + |
| 343 | +Parameters: |
| 344 | + |
| 345 | +- `_account`: User address. |
| 346 | + |
| 347 | +Returns: |
| 348 | + |
| 349 | +- `int256`: User's FAsset fee debt (can be negative). |
| 350 | + |
| 351 | +```solidity |
| 352 | +function fAssetFeeDebtOf(address _account) |
| 353 | + external view |
| 354 | + returns (int256); |
| 355 | +``` |
| 356 | + |
| 357 | +### `totalFAssetFeeDebt` |
| 358 | + |
| 359 | +Returns the total FAsset fee debt for all users. |
| 360 | + |
| 361 | +Returns: |
| 362 | + |
| 363 | +- `int256`: Total FAsset fee debt for all users (can be negative). |
| 364 | + |
| 365 | +```solidity |
| 366 | +function totalFAssetFeeDebt() |
| 367 | + external view |
| 368 | + returns (int256); |
| 369 | +``` |
| 370 | + |
| 371 | +### `fAssetRequiredForSelfCloseExit` |
| 372 | + |
| 373 | +Get the amount of FAssets that need to be burned to perform [`selfCloseExit`](/fassets/reference/ICollateralPool#selfcloseexit) or [`selfCloseExitTo`](/fassets/reference/ICollateralPool#selfcloseexitto). |
| 374 | + |
| 375 | +Parameters: |
| 376 | + |
| 377 | +- `_tokenAmountWei`: The amount of pool tokens to exit. |
| 378 | + |
| 379 | +Returns: |
| 380 | + |
| 381 | +- `uint256`: Amount of FAssets required for self close exit. |
| 382 | + |
| 383 | +```solidity |
| 384 | +function fAssetRequiredForSelfCloseExit(uint256 _tokenAmountWei) |
| 385 | + external view |
| 386 | + returns (uint256); |
| 387 | +``` |
0 commit comments