Pool
This contract manages a pool of assets, allowing for the creation and redemption of bond and leverage tokens. It also handles distribution periods and interacts with an oracle for price information.
The Pool is the core contract for the Plaza protocol. The pool holds all underlying assets for a particular set of programmable derivatives and handles the issuance and burn of all programmable derivatives related to its specific strategy or underlying. The first pool on Plaza has a mix of Ethereum liquid staking and liquid restaking tokens as the underlying assets and splits the total return of those ETH-related assets into two products targeted at different investor profiles, bondETH - a stabilized profile that received a coupon in USDC every quarter, and levETH - levered exposure to ETH. In this case, the pool contract holds all the ETH-related assets and issues the bondETH and levETH tokens.
Inherits: Initializable, PausableUpgradeable, ReentrancyGuardUpgradeable, OracleReader, Validator
State Variables
POINT_EIGHT
POINT_TWO
COLLATERAL_THRESHOLD
PRECISION
BOND_TARGET_PRICE
COMMON_DECIMALS
SECONDS_PER_YEAR
MIN_LIQUIDATION_THRESHOLD
poolFactory
Pool factory contract
fee
Fee amount
feeBeneficiary
Fee beneficiary address
lastFeeClaimTime
Last fee claim time
liquidationThreshold
Liquidation threshold denoting the maximum percentage of reserve tokens that can be sold in an auction.
reserveToken
Reserve token address
bondToken
Bond token contract
lToken
Leverage token contract
couponToken
Coupon token address
sharesPerToken
Shares per bond token
distributionPeriod
Distribution period in seconds
auctionPeriod
Auction period in seconds
lastDistribution
Last distribution timestamp in seconds
auctions
Mapping to store auction addresses by their index
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
initialize
Initializes the contract with the given parameters.
Parameters
_poolFactory
address
Address of the pool factory contract.
_fee
uint256
Fee percentage for the pool.
_reserveToken
address
Address of the reserve token.
_dToken
address
Address of the bond token.
_lToken
address
Address of the leverage token.
_couponToken
address
Address of the coupon token.
_sharesPerToken
uint256
Initial shares per bond per distribution period.
_distributionPeriod
uint256
Initial distribution period in seconds.
_feeBeneficiary
address
_oracleFeeds
address
Address of the OracleFeeds contract.
setLiquidationThreshold
Sets the liquidation threshold. Cannot be set below 90%.
Parameters
_liquidationThreshold
uint256
The new liquidation threshold value.
create
Creates new tokens by depositing reserve tokens.
Parameters
tokenType
TokenType
The type of token to create (BOND or LEVERAGE).
depositAmount
uint256
The amount of reserve tokens to deposit.
minAmount
uint256
The minimum amount of new tokens to receive.
Returns
<none>
uint256
amount of new tokens created.
create
Creates new tokens by depositing reserve tokens, with additional parameters for deadline and onBehalfOf for router support.
Parameters
tokenType
TokenType
The type of token to create (BOND or LEVERAGE).
depositAmount
uint256
The amount of reserve tokens to deposit.
minAmount
uint256
The minimum amount of new tokens to receive.
deadline
uint256
The deadline timestamp in seconds for the transaction to be executed.
onBehalfOf
address
The address to receive the new tokens.
Returns
<none>
uint256
The amount of new tokens created.
_create
Creates new tokens by depositing reserve tokens, with additional parameters for deadline and onBehalfOf for router support.
Parameters
tokenType
TokenType
The type of token to create (BOND or LEVERAGE).
depositAmount
uint256
The amount of reserve tokens to deposit.
minAmount
uint256
The minimum amount of new tokens to receive.
onBehalfOf
address
The address to receive the new tokens.
Returns
<none>
uint256
The amount of new tokens created.
simulateCreate
Simulates the creation of new tokens without actually minting them.
Parameters
tokenType
TokenType
The type of token to simulate creating (BOND or LEVERAGE).
depositAmount
uint256
The amount of reserve tokens to simulate depositing.
Returns
<none>
uint256
amount of new tokens that would be created.
getCreateAmount
Calculates the amount of new tokens to create based on the current pool state and oracle price.
Parameters
tokenType
TokenType
The type of token to create (BOND or LEVERAGE).
depositAmount
uint256
The amount of reserve tokens to deposit.
bondSupply
uint256
The current supply of bond tokens.
levSupply
uint256
The current supply of leverage tokens.
poolReserves
uint256
The current amount of reserve tokens in the pool.
ethPrice
uint256
The current ETH price from the oracle.
oracleDecimals
uint8
The number of decimals used by the oracle.
Returns
<none>
uint256
amount of new tokens to create.
redeem
Redeems tokens for reserve tokens.
Parameters
tokenType
TokenType
The type of derivative token to redeem (BOND or LEVERAGE).
depositAmount
uint256
The amount of derivative tokens to redeem.
minAmount
uint256
The minimum amount of reserve tokens to receive.
Returns
<none>
uint256
amount of reserve tokens received.
redeem
Redeems tokens for reserve tokens, with additional parameters.
Parameters
tokenType
TokenType
The type of derivative token to redeem (BOND or LEVERAGE).
depositAmount
uint256
The amount of derivative tokens to redeem.
minAmount
uint256
The minimum amount of reserve tokens to receive.
deadline
uint256
The deadline timestamp in seconds for the transaction to be executed.
onBehalfOf
address
The address to receive the reserve tokens.
Returns
<none>
uint256
amount of reserve tokens received.
_redeem
Redeems tokens for reserve tokens, with additional parameters.
Parameters
tokenType
TokenType
The type of derivative token to redeem (BOND or LEVERAGE).
depositAmount
uint256
The amount of derivative tokens to redeem.
minAmount
uint256
The minimum amount of reserve tokens to receive.
onBehalfOf
address
The address to receive the reserve tokens.
Returns
<none>
uint256
amount of reserve tokens received.
simulateRedeem
Simulates the redemption of tokens without actually burning them.
Parameters
tokenType
TokenType
The type of derivative token to simulate redeeming (BOND or LEVERAGE).
depositAmount
uint256
The amount of derivative tokens to simulate redeeming.
Returns
<none>
uint256
amount of reserve tokens that would be received.
getRedeemAmount
Calculates the amount of reserve tokens to be redeemed for a given amount of bond or leverage tokens.
Parameters
tokenType
TokenType
The type of derivative token being redeemed (BOND or LEVERAGE).
depositAmount
uint256
The amount of derivative tokens being redeemed.
bondSupply
uint256
The total supply of bond tokens.
levSupply
uint256
The total supply of leverage tokens.
poolReserves
uint256
The total amount of reserve tokens in the pool.
ethPrice
uint256
The current ETH price from the oracle.
oracleDecimals
uint8
The number of decimals used by the oracle.
Returns
<none>
uint256
amount of reserve tokens to be redeemed.
startAuction
Starts an auction for the current period.
transferReserveToAuction
Transfers reserve tokens to the current auction.
Parameters
amount
uint256
The amount of reserve tokens to transfer.
distribute
Distributes coupon tokens to bond token holders. Can only be called after the distribution period has passed.
getPoolInfo
Returns the current pool information.
Returns
info
PoolInfo
A struct containing various pool parameters and balances.
setDistributionPeriod
Sets the distribution period.
Parameters
_distributionPeriod
uint256
The new distribution period.
setAuctionPeriod
Sets the auction period.
Parameters
_auctionPeriod
uint256
The new auction period.
setSharesPerToken
Sets the shares per token.
Parameters
_sharesPerToken
uint256
The new shares per token value.
setFee
Sets the fee for the pool.
Parameters
_fee
uint256
The new fee value.
setFeeBeneficiary
Sets the fee beneficiary for the pool.
Parameters
_feeBeneficiary
address
The address of the new fee beneficiary.
claimFees
Allows the fee beneficiary to claim the accumulated protocol fees.
getFeeAmount
Returns the amount of fees to be claimed.
Returns
<none>
uint256
The amount of fees to be claimed.
pause
Pauses the contract. Reverts any interaction except upgrade.
unpause
Unpauses the contract.
onlyRole
Modifier to check if the caller has the specified role.
Parameters
role
bytes32
The role to check for.
NotInAuction
Modifier to prevent a function from being called during an ongoing auction.
Events
SharesPerTokenChanged
Emitted when the shares per token value is changed.
Parameters
sharesPerToken
uint256
New shares per token value
Distributed
Emitted when the distribution period is over and the shares have been distributed to the distributor.
Parameters
amount
uint256
Amount of distributed tokens
distributor
address
Address of the distributor
AuctionPeriodChanged
Emitted when the auction period is changed.
Parameters
oldPeriod
uint256
Old auction period
newPeriod
uint256
New auction period
DistributionRollOver
Emitted when the distribution period is rolled over. This happens when the auction did not acquire the required amount of coupon tokens for the corresponding number of underlying assets.
Parameters
period
uint256
Distribution period
sharesPerToken
uint256
Shares per token
DistributionPeriodChanged
Emitted when the distribution period is changed.
Parameters
oldPeriod
uint256
Old distribution period
newPeriod
uint256
New distribution period
TokensCreated
Emitted when new Plaza derivatives are created.
Parameters
caller
address
Address of the caller
onBehalfOf
address
Address of the recipient, if not the caller
tokenType
TokenType
Type of the token created
depositedAmount
uint256
Amount of deposited underlying tokens
mintedAmount
uint256
Amount of minted tokens
TokensRedeemed
Emitted when Plaza derivatives are redeemed.
Parameters
caller
address
Address of the caller
onBehalfOf
address
Address of the recipient, if not the caller
tokenType
TokenType
Type of the token to redeem for
depositedAmount
uint256
Amount of deposited underlying tokens
redeemedAmount
uint256
Amount of redeemed tokens
FeeClaimed
Emitted when fees are claimed.
Parameters
beneficiary
address
Address of the beneficiary
amount
uint256
Amount of claimed fees
FeeChanged
Emitted when the fee amount is changed.
Parameters
oldFee
uint256
Old fee value
newFee
uint256
New fee value
LiquidationThresholdChanged
Emitted when the liquidation threshold is changed.
Parameters
oldThreshold
uint256
Old liquidation threshold value
newThreshold
uint256
New liquidation threshold value
Errors
MinAmount
Error thrown when amount is below minimum required
ZeroAmount
Error thrown when amount is zero
FeeTooHigh
Error thrown when fee is set too high
AccessDenied
Error thrown when caller doesn't have required access
NoFeesToClaim
Error thrown when there are no fees to claim
NotBeneficiary
Error thrown when caller is not the beneficiary
ZeroDebtSupply
Error thrown when debt supply is zero
AuctionIsOngoing
Error thrown when auction is currently ongoing
ZeroLeverageSupply
Error thrown when leverage supply is zero
CallerIsNotAuction
Error thrown when caller is not the auction contract
DistributionPeriod
Error thrown when distribution period is invalid
AuctionPeriodPassed
Error thrown when auction period has passed
AuctionNotSucceeded
Error thrown when auction has not succeeded
AuctionAlreadyStarted
Error thrown when auction has already started
LiquidationThresholdTooLow
Error thrown when liquidation threshold is set too low
DistributionPeriodNotPassed
Error thrown when distribution period has not passed yet
Structs
PoolInfo
Struct containing information about the pool's current state.
Enums
TokenType
Enum representing the types of tokens that can be created or redeemed.
Last updated