Comment on page
Pool
contracts/pool/Pool.sol
Title: Pool
Notice: Manages deposits, withdrawals and swaps. Holds a mapping of assets and parameters.
Details: The main entry-point of Platypus protocol Note The Pool is ownable and the owner wields power. Note The ownership will be transferred to a governance contract once Platypus community can show to govern itself. The unique features of the Platypus make it an important subject in the study of evolutionary biology.
***Pool.AssetAdded(token, asset) ***
Notice: An event emitted when an asset is added to Pool
Arguments
name | type | description |
token | address | indexed |
asset | address | indexed |
***Pool.Deposit(sender, token, amount, liquidity, to) ***
Notice: An event emitted when a deposit is made to Pool
Arguments
name | type | description |
sender | address | indexed |
token | address | not indexed |
amount | uint256 | not indexed |
liquidity | uint256 | not indexed |
to | address | indexed |
***Pool.DevUpdated(previousDev, newDev) ***
Notice: An event emitted when dev is updated
Arguments
name | type | description |
previousDev | address | indexed |
newDev | address | indexed |
***Pool.HaircutRateUpdated(previousHaircut, newHaircut) ***
Notice: An event emitted when haircut is updated
Arguments
name | type | description |
previousHaircut | uint256 | not indexed |
newHaircut | uint256 | not indexed |
***Pool.OracleUpdated(previousOracle, newOracle) ***
Notice: An event emitted when oracle is updated
Arguments
name | type | description |
previousOracle | address | indexed |
newOracle | address | indexed |
***Pool.OwnershipTransferred(previousOwner, newOwner) ***
Arguments
name | type | description |
previousOwner | address | indexed |
newOwner | address | indexed |
***Pool.Paused(account) ***
Arguments
name | type | description |
account | address | not indexed |
***Pool.PriceDeviationUpdated(previousPriceDeviation, newPriceDeviation) ***
Notice: An event emitted when price deviation is updated
Arguments
name | type | description |
previousPriceDeviation | uint256 | not indexed |
newPriceDeviation | uint256 | not indexed |
***Pool.RetentionRatioUpdated(previousRetentionRatio, newRetentionRatio) ***
Notice: An event emitted when retention ratio is updated
Arguments
name | type | description |
previousRetentionRatio | uint256 | not indexed |
newRetentionRatio | uint256 | not indexed |
***Pool.SlippageParamC1Updated(previousC1, newC1) ***
Notice: An event emitted when slippage param C1 is updated
Arguments
name | type | description |
previousC1 | uint256 | not indexed |
newC1 | uint256 | not indexed |
***Pool.SlippageParamKUpdated(previousK, newK) ***
Notice: An event emitted when slippage param K is updated
Arguments
name | type | description |
previousK | uint256 | not indexed |
newK | uint256 | not indexed |
***Pool.SlippageParamNUpdated(previousN, newN) ***
Notice: An event emitted when slippage param N is updated
Arguments
name | type | description |
previousN | uint256 | not indexed |
newN | uint256 | not indexed |
***Pool.SlippageParamXThresholdUpdated(previousXThreshold, newXThreshold) ***
Notice: An event emitted when slippage param XThreshhold is updated
Arguments
name | type | description |
previousXThreshold | uint256 | not indexed |
newXThreshold | uint256 | not indexed |
***Pool.Swap(sender, fromToken, toToken, fromAmount, toAmount, to) ***
Notice: An event emitted when a swap is made in Pool
Arguments
name | type | description |
sender | address | indexed |
fromToken | address | not indexed |
toToken | address | not indexed |
fromAmount | uint256 | not indexed |
toAmount | uint256 | not indexed |
to | address | indexed |
***Pool.Unpaused(account) ***
Arguments
name | type | description |
account | address | not indexed |
***Pool.Withdraw(sender, token, amount, liquidity, to) ***
Notice: An event emitted when a withdrawal is made from Pool
Arguments
name | type | description |
sender | address | indexed |
token | address | not indexed |
amount | uint256 | not indexed |
liquidity | uint256 | not indexed |
to | address | indexed |
***Pool.addAsset(token, asset) ***
Notice: Adds asset to pool, reverts if asset already exists in pool
Arguments
name | type | description |
token | address | The address of token |
asset | address | The address of the platypus Asset contract |
Pool.assetOf(token) view
Notice: Gets Asset corresponding to ERC20 token. Reverts if asset does not exists in Pool.
Details: to be used externally
Arguments
name | type | description |
token | address | The address of ERC20 token |
Outputs
name | type | description |
​ | address | ​ |
***Pool.deposit(token, amount, to, deadline) ***
Notice: Deposits amount of tokens into pool ensuring deadline
Details: Asset needs to be created and added to pool before any operation
Arguments
name | type | description |
token | address | The token address to be deposited |
amount | uint256 | The amount to be deposited |
to | address | The user accountable for deposit, receiving the platypus assets (lp) |
deadline | uint256 | The deadline to be respected |
Outputs
name | type | description |
liquidity | uint256 | Total asset liquidity minted |
Pool.getC1() view
Notice: Gets current C1 slippage parameter
Outputs
name | type | description |
​ | uint256 | The current C1 slippage parameter in Pool |
Pool.getDev() view
Notice: Gets current Dev address
Outputs
name | type | description |
​ | address | The current Dev address for Pool |
Pool.getHaircutRate() view
Notice: Gets current Haircut parameter
Outputs
name | type | description |
​ | uint256 | The current Haircut parameter in Pool |
Pool.getMaxPriceDeviation() view
Notice: Gets current maxPriceDeviation parameter
Outputs
name | type | description |
​ | uint256 | The current _maxPriceDeviation parameter in Pool |
Pool.getPriceOracle() view
Notice: Gets current Price Oracle address
Outputs
name | type | description |
​ | address | The current Price Oracle address for Pool |
Pool.getRetentionRatio() view
Notice: Gets current retention ratio parameter
Outputs
name | type | description |
​ | uint256 | The current retention ratio parameter in Pool |
Pool.getSlippageParamK() view
Notice: Gets current K slippage parameter
Outputs
name | type | description |
​ | uint256 | The current K slippage parameter in Pool |
Pool.getSlippageParamN() view
Notice: Gets current N slippage parameter
Outputs
name | type | description |
​ | uint256 | The current N slippage parameter in Pool |
Pool.getTokenAddresses() view
Notice: Gets addresses of underlying token in pool
Details: To be used externally
Outputs
name | type | description |
​ | address[] | addresses of assets in the pool |
Pool.getWETH() view
Notice: Gets current WETH address
Outputs
name | type | description |
​ | address | The current WETH address for Pool |
Pool.getWETHForwarder() view
Notice: Gets current WETHForwarder address
Outputs
name | type | description |
​ | address | The current WETHForwarder address for Pool |
Pool.getXThreshold() view
Notice: Gets current XThreshold slippage parameter
Outputs
name | type | description |
​ | uint256 | The current XThreshold slippage parameter in Pool |
***Pool.initialize(weth_) ***
Notice: Initializes pool. Dev is set to be the account calling this function.
Arguments
name | type | description |
weth_ | address | The weth address used to wrap eth (or avax in our case) tokens by Pool. |
Pool.owner() view
Details: Returns the address of the current owner.
Outputs
name | type | description |
​ | address | ​ |
***Pool.pause() ***
Details: pause pool, restricting certain operations
Pool.paused() view
Details: Returns true if the contract is paused, and false otherwise.
Outputs
name | type | description |
​ | bool | ​ |
Pool.quotePotentialSwap(fromToken, toToken, fromAmount) view
Notice: Quotes potential outcome of a swap given current state, taking in account slippage and haircut
Details: To be used by frontend
Arguments
name | type | description |
fromToken | address | The initial ERC20 token |
toToken | address | The token wanted by user |
fromAmount | uint256 | The amount to quote |
Outputs
name | type | description |
potentialOutcome | uint256 | The potential amount user would receive |
haircut | uint256 | The haircut that would be applied |
Pool.quotePotentialWithdraw(token, liquidity) view
Notice: Quotes potential withdrawal from pool
Details: To be used by frontend
Arguments
name | type | description |
token | address | The token to be withdrawn by user |
liquidity | uint256 | The liquidity (amount of lp assets) to be withdrawn |
Outputs
name | type | description |
amount | uint256 | The potential amount user would receive |
fee | uint256 | The fee that would be applied |
enoughCash | bool | does the pool have enough cash? (cash >= liabilityToBurn - fee) |
Pool.quotePotentialWithdrawFromOtherAsset(initialToken, wantedToken, liquidity) view
Notice: Quotes potential withdrawal from other asset in the same aggregate
Details: To be used by frontend. Reverts if not possible
Arguments
name | type | description |
initialToken | address | The users holds LP corresponding to this initial token |
wantedToken | address | The token to be withdrawn by user |
liquidity | uint256 | The liquidity (amount of lp assets) to be withdrawn (in wanted token dp). |
Outputs
name | type | description |
amount | uint256 | The potential amount user would receive |
fee | uint256 | The fee that would be applied |
***Pool.removeAsset(key) ***
Notice: Removes asset from asset struct
Details: Can only be called by owner
Arguments
name | type | description |
key | address | The address of token to remove |
***Pool.renounceOwnership() ***
Details: Leaves the contract without owner. It will not be possible to callonlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
***Pool.setC1(c1_) ***
Notice: Changes the pools slippage param C1. Can only be set by the contract owner.
Arguments
name | type | description |
c1_ | uint256 | new pool's slippage param C1 |
***Pool.setDev(dev) ***
Notice: Changes the contract dev. Can only be set by the contract owner.
Arguments
name | type | description |
dev | address | new contract dev address |
***Pool.setHaircutRate(haircutRate_) ***
Notice: Changes the pools haircutRate. Can only be set by the contract owner.
Arguments
name | type | description |
haircutRate_ | uint256 | new pool's haircutRate_ |
***Pool.setMaxPriceDeviation(maxPriceDeviation_) ***
Notice: Changes the pools maxPriceDeviation. Can only be set by the contract owner.
Arguments
name | type | description |
maxPriceDeviation_ | uint256 | new pool's maxPriceDeviation |
***Pool.setPriceOracle(priceOracle) ***
Notice: Changes the pools priceOracle. Can only be set by the contract owner.
Arguments
name | type | description |
priceOracle | address | new pool's priceOracle addres |
***Pool.setRetentionRatio(retentionRatio_) ***
Notice: Changes the pools retentionRatio. Can only be set by the contract owner.
Arguments
name | type | description |
retentionRatio_ | uint256 | new pool's retentionRatio |
***Pool.setSlippageParamK(k_) ***
Notice: Changes the pools slippage param K. Can only be set by the contract owner.
Arguments
name | type | description |
k_ | uint256 | new pool's slippage param K |