LiquidityPoolProxy.sol

Github Link: https://github.com/Shell-Protocol/Shell-Protocol/blob/main/src/proteus/LiquidityPoolProxy.sol

constructor()

constructor(
    uint256 xToken_,
    uint256 yToken_,
    address ocean_,
    uint256 initialLpTokenSupply_
) LiquidityPool(
    xToken_,
    yToken_,
    ocean_,
    initialLpTokenSupply_,
    address(0)
);

This method is called whenever a new LiquidityPoolProxy contract is deployed.

swapGivenInputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance
*/
function swapGivenInputAmount(
   uint256 inputToken, 
   uint256 inputAmount
) public view override notFrozen returns (
   uint256 outputAmount
);

This function executes a swap of the input amount of input token for the second of the tokens that make up the pool base pair.

It should...

  1. Swap specified of input tokens for the second token that makes the liquidity pool.

depositGivenInputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance and _getTotalSupply to get the lpTokenSupply
*/
function depositGivenInputAmount(
   uint256 depositToken,
   uint256 depositAmount
) public view override notFrozen returns (
   uint256 mintAmount
);

This function deposits specified deposit amount of the specified deposit token into Liquidity Pool. Deposit token should be one of the two tokens that make up the LP base pair.

It should...

  1. Deposit a token into the Liquidity Pool.

withdrawGivenInputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance and _getTotalSupply to get the lpTokenSupply
*/
function withdrawGivenInputAmount(
   uint256 withdrawnToken,
   uint256 burnAmount
) public view override notFrozen returns (
   uint256 withdrawnAmount
);

This function withdraws specified withdraw amount of the specified withdraw token from the Liquidity Pool. Withdraw token should be one of the two tokens that make up the LP base pair.

It should...

  1. Withdraw a token from the Liquidity Pool.

swapGivenOutputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance
*/
function swapGivenOutputAmount(
   uint256 outputToken, 
   uint256 outputAmount
) public view override notFrozen returns (
   uint256 inputAmount
);

This function returns how many input tokens should be given for the desired output amount of the specified output token. Output token should be one of the two tokens that make up the LP base pair.

It should...

  1. Return the number of the other of the tokens that make up Liquidity Pool's base pair should be given for the specified output token.

depositGivenOutputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance and _getTotalSupply() to get the lpTokenSupply
*/
function depositGivenOutputAmount(
   uint256 depositToken, 
   uint256 mintAmount
) public view override notFrozen returns (
   uint256 depositAmount
);

This function returns how many deposit tokens should be deposited for the desired amount of the LP tokens. Deposit token should be one of the two tokens that make up the LP base pair.

It should...

  1. Return the number of deposit tokens necessary to receive specified mint amount of LP tokens.

withdrawGivenOutputAmount()

/**
* @dev this function should begin by calling _getBalances() to get the
*  xBalance and yBalance and _getTotalSupply() to get the lpTokenSupply
*/
function withdrawGivenOutputAmount(
   uint256 withdrawnToken,
   uint256 withdrawnAmount
) public view override notFrozen returns (
   uint256 burnAmount
);

This function returns how many LP tokens should be burned in order to receive specified withdrawn amount of the specified withdrawn token. Withdrawn token should be one of the two tokens that make up the LP base pair.

It should...

  1. Return the number of LP tokens that should be burned in order to receive specified amount of wanted token.

Last updated