@platypus-finance/platypus-finance-utils
v1.0.6
Published
platypus-finance/platypus-finance-utils is a library developed by for platypus finance.
Downloads
2
Readme
platypus-finance/platypus-finance-utils
platypus-finance/platypus-finance-utils is a library developed by for platypus finance.
Installation
To install and set up the library, run:
$ npm install @platypus-finance/platypus-finance-utils
Or if you prefer using Yarn:
$ yarn add @platypus-finance/platypus-finance-utils
API Reference
.solveForDeltaX
Regarding Section 6 of our AMM yellow paper, the FROM amount, aka, delta x (denoted delta j in the paper) in our Newton's method can be obtained from the following solveForDeltaX
function, when the TO amount is given.
Params
assetX
{BigNumber} asset of token X in WAD. (e.g, use ethers.js'sparseEther('1.5')
for 1.5 USDC)assetY
{BigNumber} asset of token Y in WADliabilityX
{BigNumber} liability of token X in WADliabilityY
{BigNumber} liability of token Y in WADfy
{BigNumber} USD price of token X in WAD. (Can use 1 WAD for both fy and fx since our protocol current only supports stablepairs)fx
{BigNumber} USD price of token Y in WAD. (Can use 1 WAD for both fy and fx since our protocol current only supports stablepairs)toAmount
{BigNumber} specified TO amount of token Y in WADhaircutRate
{BigNumber} haircut rate in WAD. Can be obtained from pool's contract'sgetHaircutRate
slippageParamK
{BigNumber} in WAD. Can be obtained from pool's contract'sgetSlippageParamK
slippageParamN
{BigNumber} in BigNumber Int. Can be obtained from pool's contract'sgetSlippageParamN
slippageParamC1
{BigNumber} in WAD. Can be obtained from pool's contract'sgetC1
slippageParamXThreshold
{BigNumber} in WAD. Can be obtained from pool's contract'sgetXThreshold
returns
{BigNumber} FROM amount, Delta X, in WAD