Skip to main content

IPool

Git Source Inherits: IPoolEvents Author: @oscarsernarosero @mpetersoCode55 @cirsteve function signatures for all Pools

Functions

swap

This is the main function of the pool to swap.
function swap(address _tokenIn, uint256 _amountIn, uint256 _minOut)
    external
    returns (uint256 amountOut, uint256 lpFeeAmount, uint256 protocolFeeAmount);
Parameters
NameTypeDescription
_tokenInaddressthe address of the token being given to the pool in exchange for another token
_amountInuint256the amount of the ERC20 _tokenIn to exchange into the Pool
_minOutuint256the amount of the other token in the pair minimum to be received for the _amountIn of _tokenIn.
Returns
NameTypeDescription
amountOutuint256the actual amount of the token coming out of the Pool as result of the swap
lpFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the LP
protocolFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the protocol

spotPrice

This is the function to retrieve the current spot price of the x token.
function spotPrice() external returns (uint256 sPrice);
Returns
NameTypeDescription
sPriceuint256the price in YToken Decimals

simSwap

This is a simulation of the swap function. Useful to get marginal price.
function simSwap(address _tokenIn, uint256 _amountIn)
    external
    returns (uint256 amountOut, uint256 lpFeeAmount, uint256 protocolFeeAmount);
Parameters
NameTypeDescription
_tokenInaddressthe address of the token being sold
_amountInuint256the amount of the ERC20 _tokenIn to sell to the Pool
Returns
NameTypeDescription
amountOutuint256the amount of the token coming out of the Pool as result of the swap (main returned value)
lpFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the LP
protocolFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the protocol

simSwapReversed

lpFeeAmount and protocolFeeAmount are already factored in the amountIn. This is useful only to know how much of the amountIn will go towards fees. This is a simulation of the swap function from the perspective of purchasing a specific amount. Useful to get marginal price.
function simSwapReversed(address _tokenout, uint256 _amountOut)
    external
    returns (uint256 amountIn, uint256 lpFeeAmount, uint256 protocolFeeAmount);
Parameters
NameTypeDescription
_tokenoutaddressthe address of the token being bought
_amountOutuint256the amount of the ERC20 _tokenOut to buy from the Pool
Returns
NameTypeDescription
amountInuint256the amount necessary of the token coming into the Pool for the desired amountOut of the swap (main returned value)
lpFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the LP
protocolFeeAmountuint256the amount of the Y token that’s being dedicated to fees for the protocol

xToken

this value is immutable A function to get the address of the x token of the pool.
function xToken() external returns (address);
Returns
NameTypeDescription
<none>addressthe address of the x token of the pool

yToken

this value is immutable A function to get the address of the Y token of the pool.
function yToken() external returns (address);
Returns
NameTypeDescription
<none>addressthe address of the Y token of the pool

enableSwaps

This is the function to activate/deactivate trading.
function enableSwaps(bool _enable) external;
Parameters
NameTypeDescription
_enableboolpass True to enable or False to disable

addXSupply

This is the function to add XToken liquidity to the pool.
function addXSupply(uint256 _amount) external;
Parameters
NameTypeDescription
_amountuint256the amount of X token to transfer from the sender to the pool

closePool

This function can be called only if the flag liquidityRemovalAllowed was set to true at construction time. This function closes the pool by removing all liquidity from it.
function closePool() external;

setLPFee

This is the function to update the LP fees per trading.
function setLPFee(uint16 _fee) external;
Parameters
NameTypeDescription
_feeuint16percentage of the transaction that will get collected as fees (in percentage basis points: 10000 -> 100.00%; 500 -> 5.00%; 1 -> 0.01%)

setProtocolFee

This is the function to update the protocol fees per trading.
function setProtocolFee(uint16 _protocolFee) external;
Parameters
NameTypeDescription
_protocolFeeuint16percentage of the transaction that will get collected as fees (in percentage basis points: 10000 -> 100.00%; 500 -> 5.00%; 1 -> 0.01%)

proposeProtocolFeeCollector

that only the current fee collector address can call this function function to propose a new protocol fee collector
function proposeProtocolFeeCollector(address _protocolFeeCollector) external;
Parameters
NameTypeDescription
_protocolFeeCollectoraddressthe new fee collector

confirmProtocolFeeCollector

that only the already proposed fee collector can call this function function to confirm a new protocol fee collector
function confirmProtocolFeeCollector() external;

collectLPFees

This function collects the fees from the Pool.
function collectLPFees() external;

withdrawRevenue

This function allows the owner of the pool to pull accrued revenue from the Pool.
function withdrawRevenue() external;

collectProtocolFees

This function collects the protocol fees from the Pool.
function collectProtocolFees() external;

xTokenLiquidity

This function gets the liquidity in the pool for xToken in WAD.
function xTokenLiquidity() external returns (uint256);
Returns
NameTypeDescription
<none>uint256the liquidity in the pool for xToken in WAD

yTokenLiquidity

This function gets the liquidity in the pool for yToken in WAD
function yTokenLiquidity() external returns (uint256);
Returns
NameTypeDescription
<none>uint256the liquidity in the pool for yToken in WAD

lpFee

fee percentage for swaps for the LP
function lpFee() external returns (uint16);
Returns
NameTypeDescription
<none>uint16the percentage for swaps in basis points that will go towards the LP

protocolFee

fee percentage for swaps for the protocol
function protocolFee() external returns (uint16);
Returns
NameTypeDescription
<none>uint16the percentage for swaps in basis points that will go towards the protocol

protocolFeeCollector

protocol-fee collector address
function protocolFeeCollector() external returns (address);
Returns
NameTypeDescription
<none>addressthe current protocolFeeCollector address

proposedProtocolFeeCollector

proposed protocol-fee collector address
function proposedProtocolFeeCollector() external returns (address);
Returns
NameTypeDescription
<none>addressthe current proposedProtocolFeeCollector address

collectedLPFees

tells current LP fees accumulated in the pool
function collectedLPFees() external returns (uint256);
Returns
NameTypeDescription
<none>uint256currently claimable LP fee balance

collectedProtocolFees

tells current protocol fees accumulated in the pool
function collectedProtocolFees() external returns (uint256);
Returns
NameTypeDescription
<none>uint256currently claimable protocol fee balance

liquidityRemovalAllowed

this value is immutable if true, the pool could be closed effectively pulling out all of the liquidity
function liquidityRemovalAllowed() external returns (bool);
Returns
NameTypeDescription
<none>boolliquidityRemovalAllowed

x

Outstanding liquidity can be calculated as x - xMin. tells the current value of x.
function x() external returns (uint256);
Returns
NameTypeDescription
<none>uint256x expressed in xToken decimals