LiquidityProtection
This contract implements the liquidity protection mechanism.
Functions:
Function constructor(contract ILiquidityProtectionSettings settings, contract ILiquidityProtectionStore store, contract ILiquidityProtectionStats stats, contract ILiquidityProtectionSystemStore systemStore, contract ITokenHolder wallet, contract ITokenGovernance networkTokenGovernance, contract ITokenGovernance govTokenGovernance, contract ICheckpointStore lastRemoveCheckpointStore)
constructor(contract ILiquidityProtectionSettings settings, contract ILiquidityProtectionStore store, contract ILiquidityProtectionStats stats, contract ILiquidityProtectionSystemStore systemStore, contract ITokenHolder wallet, contract ITokenGovernance networkTokenGovernance, contract ITokenGovernance govTokenGovernance, contract ICheckpointStore lastRemoveCheckpointStore)
initializes a new LiquidityProtection contract
Parameters:
settings
: liquidity protection settingsstore
: liquidity protection storestats
: liquidity protection statssystemStore
: liquidity protection system storewallet
: liquidity protection walletnetworkTokenGovernance
: network token governancegovTokenGovernance
: governance token governancelastRemoveCheckpointStore
: last liquidity removal/unprotection checkpoints store
Function store() → contract ILiquidityProtectionStore
store() → contract ILiquidityProtectionStore
returns the LP store
Return Values:
the LP store
Function stats() → contract ILiquidityProtectionStats
stats() → contract ILiquidityProtectionStats
returns the LP stats
Return Values:
the LP stats
Function settings() → contract ILiquidityProtectionSettings
settings() → contract ILiquidityProtectionSettings
returns the LP settings
Return Values:
the LP settings
Function systemStore() → contract ILiquidityProtectionSystemStore
systemStore() → contract ILiquidityProtectionSystemStore
returns the LP system store
Return Values:
the LP system store
Function wallet() → contract ITokenHolder
wallet() → contract ITokenHolder
returns the LP wallet
Return Values:
the LP wallet
Function receive()
receive()
accept ETH
Function transferStoreOwnership(address newOwner)
transferStoreOwnership(address newOwner)
transfers the ownership of the store
can only be called by the contract owner
Parameters:
newOwner
: the new owner of the store
Function acceptStoreOwnership()
acceptStoreOwnership()
accepts the ownership of the store
can only be called by the contract owner
Function transferWalletOwnership(address newOwner)
transferWalletOwnership(address newOwner)
transfers the ownership of the wallet
can only be called by the contract owner
Parameters:
newOwner
: the new owner of the wallet
Function acceptWalletOwnership()
acceptWalletOwnership()
accepts the ownership of the wallet
can only be called by the contract owner
Function addLiquidityFor(address owner, contract IConverterAnchor poolAnchor, contract IReserveToken reserveToken, uint256 amount) → uint256
addLiquidityFor(address owner, contract IConverterAnchor poolAnchor, contract IReserveToken reserveToken, uint256 amount) → uint256
adds protected liquidity to a pool for a specific recipient
also mints new governance tokens for the caller if the caller adds network tokens
Parameters:
owner
: position ownerpoolAnchor
: anchor of the poolreserveToken
: reserve token to add to the poolamount
: amount of tokens to add to the pool
Return Values:
new position id
Function addLiquidity(contract IConverterAnchor poolAnchor, contract IReserveToken reserveToken, uint256 amount) → uint256
addLiquidity(contract IConverterAnchor poolAnchor, contract IReserveToken reserveToken, uint256 amount) → uint256
adds protected liquidity to a pool
also mints new governance tokens for the caller if the caller adds network tokens
Parameters:
poolAnchor
: anchor of the poolreserveToken
: reserve token to add to the poolamount
: amount of tokens to add to the pool
Return Values:
new position id
Function poolAvailableSpace(contract IConverterAnchor poolAnchor) → uint256, uint256
poolAvailableSpace(contract IConverterAnchor poolAnchor) → uint256, uint256
returns the single-side staking limits of a given pool
Parameters:
poolAnchor
: anchor of the pool
Return Values:
maximum amount of base tokens that can be single-side staked in the pool
maximum amount of network tokens that can be single-side staked in the pool
Function removeLiquidityReturn(uint256 id, uint32 portion, uint256 removeTimestamp) → uint256, uint256, uint256
removeLiquidityReturn(uint256 id, uint32 portion, uint256 removeTimestamp) → uint256, uint256, uint256
returns the expected/actual amounts the provider will receive for removing liquidity
it's also possible to provide the remove liquidity time to get an estimation
for the return at that given point
Parameters:
id
: position idportion
: portion of liquidity to remove, in PPMremoveTimestamp
: time at which the liquidity is removed
Return Values:
expected return amount in the reserve token
actual return amount in the reserve token
compensation in the network token
Function removeLiquidity(uint256 id, uint32 portion)
removeLiquidity(uint256 id, uint32 portion)
removes protected liquidity from a pool
also burns governance tokens from the caller if the caller removes network tokens
Parameters:
id
: position idportion
: portion of liquidity to remove, in PPM
Function transferPosition(uint256 id, address newProvider) → uint256
transferPosition(uint256 id, address newProvider) → uint256
transfers a position to a new provider
Parameters:
id
: position idnewProvider
: the new provider
Return Values:
new position id
Function transferPositionAndNotify(uint256 id, address newProvider, contract ITransferPositionCallback callback, bytes data) → uint256
transferPositionAndNotify(uint256 id, address newProvider, contract ITransferPositionCallback callback, bytes data) → uint256
transfers a position to a new provider and optionally notifies another contract
Parameters:
id
: position idnewProvider
: the new providercallback
: the callback contract to notifydata
: custom data provided to the callback
Return Values:
new position id
Function claimBalance(uint256 startIndex, uint256 endIndex)
claimBalance(uint256 startIndex, uint256 endIndex)
allows the caller to claim network token balance that is no longer locked
note that the function can revert if the range is too large
Parameters:
startIndex
: start index in the caller's list of locked balancesendIndex
: end index in the caller's list of locked balances (exclusive)
Function poolROI(contract IDSToken poolToken, contract IReserveToken reserveToken, uint256 reserveAmount, uint256 poolRateN, uint256 poolRateD, uint256 reserveRateN, uint256 reserveRateD) → uint256
poolROI(contract IDSToken poolToken, contract IReserveToken reserveToken, uint256 reserveAmount, uint256 poolRateN, uint256 poolRateD, uint256 reserveRateN, uint256 reserveRateD) → uint256
returns the ROI for removing liquidity in the current state after providing liquidity with the given args
the function assumes full protection is in effect
return value is in PPM and can be larger than PPM_RESOLUTION for positive ROI, 1M = 0% ROI
Parameters:
poolToken
: pool tokenreserveToken
: reserve tokenreserveAmount
: reserve token amount that was addedpoolRateN
: rate of 1 pool token in reserve token units when the liquidity was added (numerator)poolRateD
: rate of 1 pool token in reserve token units when the liquidity was added (denominator)reserveRateN
: rate of 1 reserve token in the other reserve token units when the liquidity was added (numerator)reserveRateD
: rate of 1 reserve token in the other reserve token units when the liquidity was added (denominator)
Return Values:
ROI in PPM
Last updated