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)
);
Parameter NameTypeDescription

xToken_

unit256

Ocean ID of the first of two tokens that make up the base pair

yToken_

unit256

Ocean ID of the second of two tokens that make up the base pair

ocean_

address

an address of the Ocean contract

initialLpTokenSupply_

unit256

the initial supply of the Liquidity Provider token. It should be an even number

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
);
Parameter NameTypeDescription

inputToken

unit256

Ocean ID of one of two tokens that make up the base pair

inputAmount

unit256

amount of tokens to swap

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
);
Parameter NameTypeDescription

depositToken

unit256

Ocean ID of the token to be deposited. It should be one of the two tokens that make up the LP base pair

depositAmount

unit256

amount of tokens to deposit

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
);
Parameter NameTypeDescription

withdrawnToken

unit256

Ocean ID of the token to be withdrawn. It should be one of the two tokens that make up the LP base pair

burnAmount

unit256

amount of tokens to withdraw

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
);
Parameter NameTypeDescription

outputToken

unit256

Ocean ID of one of two tokens that make up the base pair

outputAmount

unit256

amount of tokens desired to get from the swap

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
);
Parameter NameTypeDescription

depositToken

unit256

Ocean ID of one of two tokens that make up the base pair

mintAmount

unit256

amount of LP tokens to be minted

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
);
Parameter NameTypeDescription

withdrawnToken

unit256

Ocean ID of one of two tokens that make up the base pair

withdrawnAmount

unit256

amount of tokens to be withdrawn

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