LiquidityManager
The LiquidityManager contract is the main component of Athena's decentralized cover protocol. It serves as the core liquidity and cover management system, enabling users to provide liquidity, purchase cover, and participate in the protocol's risk-sharing mechanism.
The diamond proxy pattern is used to access its computation and storage manipulation libraries. Its VirtualPool library allows it to manage several liquidity layers within its storage in order to handle cross-pool liquidity distribution.
Structs info
CoverRead
PositionRead
Position
PoolOverlap
VPoolRead
State variables info
positionToken
coverToken
ecclesiaDao
strategyManager
claimManager
yieldRewarder
withdrawDelay
The delay after commiting before a position can be withdrawn
maxLeverage
The maximum amount of pools a position can supply liquidity to
leverageFeePerPool
The fee paid out to the DAO for each leveraged pool in a position
arePoolCompatible
coverToPool
Maps a cover ID to the ID of the pool storing the cover data
nextCompensationId
The ID of the next claim to be
nextPoolId
The token ID position data
Read Functions info
positions
positionInfo
Returns the up to date position data of a token
Parameters:
positionId_
uint256
The ID of the position
Return values:
--
struct PositionRead
The position data
coverInfo
Returns the up to date cover data of a token
Parameters:
coverId_
uint256
The ID of the cover
Return values:
--
struct CoverRead
The cover data formatted for reading
poolInfo
Returns the virtual pool's storage
Parameters:
poolId_
uint64
The ID of the pool
Return values:
--
struct VPoolRead
The virtual pool's storage
positionInfos
Returns the up to date data of an array of positions
Moved to LiquidityManager since cannot pass array of storage pointers in memory
Parameters:
positionIds
uint256[]
The IDs of the positions
Return values:
--
struct PositionRead[]
The positions data
coverInfos
Returns up to date data for an array of covers
Parameters:
coverIds
uint256[]
The IDs of the covers
Return values:
--
struct CoverRead[]
The array of covers data
poolInfos
Returns up to date data for an array of pools
Parameters:
poolIds
uint256[]
The IDs of the pools
Return values:
--
struct VPoolRead[]
The array of pools data
isCoverActive
Returns if the cover is still active or has expired
Parameters:
coverId_
uint256
The ID of the cover
Return values:
--
bool
True if the cover is still active, otherwise false
poolOverlaps
Returns amount liquidity overlap between two pools
The overlap is always stored in the pool with the lowest ID
Parameters:
poolIdA_
uint64
The ID of the first pool
poolIdB_
uint64
The ID of the second pool
Return values:
--
uint256
The amount of liquidity overlap
Write Functions info
openPosition
Creates a new LP position
Wrapped tokens are tokens representing a position in a strategy, it allows the user to reinvest DeFi liquidity without having to withdraw
Parameters:
amount
uint256
The amount of tokens to supply
isWrapped
bool
True if the user can & wants to provide strategy tokens
poolIds
uint64[]
The IDs of the pools to provide liquidity to
addLiquidity
Increases the position's provided liquidity
Wrapped tokens are tokens representing a position in a strategy, it allows the user to reinvest DeFi liquidity without having to withdraw
Parameters:
positionId_
uint256
The ID of the position
amount
uint256
The amount of tokens to supply
isWrapped
bool
True if the user can & wants to provide strategy tokens
takeInterests
Takes the interests of a position
Parameters:
positionId_
uint256
The ID of the position
commitRemoveLiquidity
Commits to withdraw the position's liquidity
Ongoing claims must be resolved before being able to commit
Parameters:
positionId_
uint256
The ID of the position
uncommitRemoveLiquidity
Cancels a position's commit to withdraw its liquidity
Parameters:
positionId_
uint256
The ID of the position
removeLiquidity
Closes a position and withdraws its liquidity
The position must be committed and the delay elapsed to withdrawal
Parameters:
positionId_
uint256
The ID of the position
keepWrapped_
bool
True if the user wants to keep the strategy tokens
openCover
Buys a cover
Parameters:
poolId_
uint64
The ID of the pool
coverAmount_
uint256
The amount of cover to buy
premiums_
uint256
The amount of premiums to pay
updateCover
Updates or closes a cover
If premiumsToRemove_ is max uint256 then withdraw premiums & closes the cover
Parameters:
coverId_
uint256
The ID of the cover
coverToAdd_
uint256
The amount of cover to add
coverToRemove_
uint256
The amount of cover to remove
premiumsToAdd_
uint256
The amount of premiums to add
premiumsToRemove_
uint256
The amount of premiums to remove
Events info
PoolCreated
Emitted when a new pool is created
PositionOpenned
Emitted when a position is opened
InterestsTaken
Emitted when a position's liquidity is updated
PositionLiquidityUpdated
Emitted when a position's liquidity is updated
CoverOpenned
Emits when a new cover is bought
CoverUpdated
Emits when a cover is updated
CoverClosed
Emits when a cover is closed
CompensationPaid
Compensation is paid out for a claim
Last updated