Panda Pool
Abstract base contract implementing bonding curve mechanics.
Functions
Trading
buyTokens
Purchase tokens with the base token.
Parameters:
amountIn
: Amount of base tokens to spendminAmountOut
: Minimum tokens to receiveto
: Recipient address
Returns:
amountOut
: Amount of tokens receivedfee
: Fee paid in base tokens
Errors:
PandaPool: INSUFFICIENT_OUTPUT_AMOUNT
- When amountOut is less than minAmountOutPandaPool: TRADE_BELOW_MIN
- When trade size is below minimum thresholdPandaPool: INVALID_TO
- When recipient address is zeroPandaPool: GRADUATED
- When pool has already graduated
buyTokensWithBera
Purchase tokens using native BERA.
Parameters:
minAmountOut
: Minimum tokens to receiveto
: Recipient address
Returns:
amountOut
: Amount of tokens receivedfee
: Fee paid in BERA
Errors:
PandaPool: NOT_BERA_PAIR
- When base token is not WBERAPandaPool: INSUFFICIENT_OUTPUT_AMOUNT
- When amountOut is less than minAmountOutPandaPool: INVALID_TO
- When recipient address is zeroPandaPool: GRADUATED
- When pool has already graduated
buyAllTokens
Purchase all remaining tokens in the pool.
Parameters:
to
: Recipient address
Returns:
amountOut
: Amount of tokens receivedfee
: Fee paid in base tokens
Errors:
PandaPool: INVALID_TO
- When recipient address is zeroPandaPool: INSUFFICIENT_LIQUIDITY
- When not enough liquidity for tradePandaPool: GRADUATED
- When pool has already graduated
sellTokens
Sell tokens for the base token.
Parameters:
amountIn
: Amount of tokens to sellminAmountOut
: Minimum base tokens to receiveto
: Recipient address
Returns:
amountOut
: Amount of base tokens receivedfee
: Fee paid in base tokens
Errors:
PandaPool: INSUFFICIENT_BUYING
- When selling more than boughtPandaPool: INSUFFICIENT_OUTPUT_AMOUNT
- When amountOut is less than minAmountOutPandaPool: INVALID_TO
- When recipient address is zeroPandaPool: GRADUATED
- When pool has already graduated
sellTokensForBera
Sell tokens for native BERA.
Parameters:
amountIn
: Amount of tokens to sellminAmountOut
: Minimum amount of BERA to receiveto
: Recipient address for BERA
Returns:
amountOut
: Amount of BERA receivedfee
: Fee paid in BERA
Errors:
PandaPool: NOT_BERA_PAIR
- When base token is not WBERAPandaPool: INSUFFICIENT_BUYING
- When selling more than boughtPandaPool: INSUFFICIENT_OUTPUT_AMOUNT
- When amountOut is less than minAmountOutPandaPool: INVALID_TO
- When recipient address is zero
Price Discovery Functions
getAmountOutBuy
Calculate expected output for buying tokens.
Returns:
amountOut
: Expected amount of tokens to receivefee
: Expected fee in base tokenssqrtP_new
: New square root price after the trade
Errors:
PandaPool: TRADE_BELOW_MIN
- When trade size is below minimum thresholdPandaPool: INSUFFICIENT_LIQUIDITY
- When not enough liquidity for tradePandaPool: GRADUATED
- When pool has already graduated
getAmountOutSell
Calculate expected output for selling tokens.
Parameters:
amountIn
: Amount of tokens to sell
Returns:
amountOut
: Expected amount of base tokens to receivefee
: Expected fee in base tokenssqrtP_new
: New square root price after the trade
Errors:
PandaPool: TRADE_BELOW_MIN
- When trade size is below minimum thresholdPandaPool: INSUFFICIENT_LIQUIDITY
- When not enough liquidity for tradePandaPool: GRADUATED
- When pool has already graduated
getAmountInBuy
Calculate required input for desired token output.
Parameters:
amountOut
: Desired amount of tokens to receive
Returns:
amountIn
: Required amount of base tokens to spendfee
: Expected fee in base tokenssqrtP_new
: New square root price after the trade
Errors:
PandaPool: TRADE_BELOW_MIN
- When trade size is below minimum thresholdPandaPool: INSUFFICIENT_LIQUIDITY
- When not enough tokens availablePandaPool: GRADUATED
- When pool has already graduated
getAmountInBuyRemainingTokens
Calculate amount needed to buy all remaining tokens.
Returns:
amountIn
: Amount of base tokens needed to buy all remaining tokens
Balance & Vesting Functions
totalBalanceOf
Get total balance including unvested tokens.
Parameters:
user
: Address to check balance for
Returns:
Total balance including both vested and unvested tokens
vestedBalanceOf
Get available/vested balance.
Parameters:
user
: Address to check vested balance for
Returns:
Currently vested token balance
claimableTokens
Get amount of tokens available to claim.
Parameters:
user
: Address to check claimable tokens for
Returns:
Amount of tokens currently available to claim
Errors:
PandaPool: VESTING_OFF
- When vesting is not enabledPandaPool: NOT_GRADUATED
- When pool hasn't graduated yet
claimTokens
Claim vested tokens.
Parameters:
user
: Address to claim tokens for
Returns:
Amount of tokens claimed
Errors:
PandaPool: VESTING_OFF
- When vesting is not enabledPandaPool: NO_CLAIMABLE
- When no tokens are available to claim
Pool State Functions
remainingTokensInPool
Get remaining tokens available in pool.
Returns:
Amount of tokens remaining in the pool
viewExcessTokens
View excess tokens in contract.
Returns:
excessPandaTokens
: Amount of excess Panda tokensexcessBaseTokens
: Amount of excess base tokens
collectExcessTokens
Transfer excess tokens to treasury.
Emits: ExcessCollected
Events
Emitted when pool is initialized.
Emitted on each swap operation.
Emitted when pool reserves are synchronized.
Emitted when tokens are claimed from vesting.
Emitted when excess tokens are collected.
Last updated