Proteus.sol
Github link: https://github.com/Shell-Protocol/Shell-Protocol/blob/main/src/proteus/Proteus.sol
constructor()
constructor(
int128[] memory ms,
int128[] memory _as,
int128[] memory bs,
int128[] memory ks
) Slices(ms, _as, bs, ks);
ms
int128[]
a list of slopes of the radial lines
_as
int128[]
bs
int128[]
ks
int128[]
a list of values for relative scale factors of each slice
This method is called whenever a new pool is deployed.
swapGivenInputAmount()
/**
* @dev Given an input amount of a reserve token, we compute an output
* amount of the other reserve token, keeping utility invariant.
* @dev We use FEE_DOWN because we want to decrease the perceived
* input amount and decrease the observed output amount.
*/
function swapGivenInputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 inputAmount,
SpecifiedToken inputToken
) external view returns (
uint256 outputAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
inputAmount
unit256
amount of input tokens to swap for output tokens
inputToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes output amount of the reserve token based on the input amount of the reserved token.
It should...
Return the output amount based on the input amount.
swapGivenOutputAmount()
/**
* @dev Given an output amount of a reserve token, we compute an input
* amount of the other reserve token, keeping utility invariant.
* @dev We use FEE_UP because we want to increase the perceived output
* amount and increase the observed input amount.
*/
function swapGivenOutputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 outputAmount,
SpecifiedToken outputToken
) external view returns (
uint256 inputAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
outputAmount
unit256
amount of output tokens to swap for input tokens
outputToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes input amount of the reserve token necessary to get for the desired amount of the output token.
It should...
Return input amount necessary to receive the output amount.
depositGivenInputAmount()
/**
* @dev Given an input amount of a reserve token, we compute an output
* amount of LP tokens, scaling the total supply of the LP tokens with the
* utility of the pool.
* @dev We use FEE_DOWN because we want to decrease the perceived amount
* deposited and decrease the amount of LP tokens minted.
*/
function depositGivenInputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 totalSupply,
uint256 depositedAmount,
SpecifiedToken depositedToken
) external view returns (
uint256 mintedAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
totalSupply
unit256
total supply of the LP tokens that exists currently
depositedAmount
unit256
the amount of token to be deposited
depositedToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes output amount of LP tokens based on the amount of the input token.
It should...
Return amount of LP tokens minted for the amount of the provided token.
depositGivenOutputAmount()
/**
* @dev Given an output amount of the LP token, we compute an amount of
* a reserve token that must be deposited to scale the utility of the pool
* in proportion to the change in total supply of the LP token.
* @dev We use FEE_UP because we want to increase the perceived change in
* total supply and increase the observed amount deposited.
*/
function depositGivenOutputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 totalSupply,
uint256 mintedAmount,
SpecifiedToken depositedToken
) external view returns (
uint256 depositedAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
totalSupply
unit256
total supply of the LP tokens that exists currently
mintedAmount
unit256
the amount of LP token to be minted
depositedToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes deposit amount necessary to in order to receive desired amount of LP tokens (minted amount).
It should...
Return amount of deposited token necessary to get the desired amount of LP tokens.
withdrawGivenOutputAmount()
/**
* @dev Given an output amount of a reserve token, we compute an amount of
* LP tokens that must be burned in order to decrease the total supply in
* proportion to the decrease in utility.
* @dev We use FEE_UP because we want to increase the perceived amount
* withdrawn from the pool and increase the observed decrease in total
* supply.
*/
function withdrawGivenOutputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 totalSupply,
uint256 withdrawnAmount,
SpecifiedToken withdrawnToken
) external view returns (
uint256 burnedAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
totalSupply
unit256
total supply of the LP tokens that exists currently
withdrawnAmount
unit256
the amount of token to be withdrawn
withdrawnToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes how many LP tokens should be burned in exchange for the withdraw amount of the specified token.
It should...
Return amount of LP tokens burned for the request amount of withdraw token.
withdrawGivenInputAmount()
/**
* @dev Given an input amount of the LP token, we compute an amount of
* a reserve token that must be output to decrease the pool's utility in
* proportion to the pool's decrease in total supply of the LP token.
* @dev We use FEE_UP because we want to increase the perceived amount of
* reserve tokens leaving the pool and to increase the observed amount of
* LP tokens being burned.
*/
function withdrawGivenInputAmount(
uint256 xBalance,
uint256 yBalance,
uint256 totalSupply,
uint256 burnedAmount,
SpecifiedToken withdrawnToken
) external view returns (
uint256 withdrawnAmount
);
xBalance
unit256
x token balance
yBalance
unit256
y token balance
totalSupply
unit256
total supply of the LP tokens that exists currently
burnedAmount
unit256
the amount of LP tokens that are going to be burned
withdrawnToken
SpecifiedToken enum
SpecifiedToken.X or SpecifiedToken.Y
SpecifiedToken enum:
X
enum member (technically token Ocean ID)
an indicator stating usage of token X in the operation
Y
enum member (technically token Ocean ID)
an indicator stating usage of token Y in the operation
This function computes amount of specified withdrawn token to be received for the given amount of burned LP tokens.
It should...
Return amount of withdraw tokens to be received for the amount of burned LP tokens.
Last updated