1.0.6 • Published 3 years ago
@platypus-finance/platypus-finance-utils v1.0.6
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-utilsOr if you prefer using Yarn:
$ yarn add @platypus-finance/platypus-finance-utilsAPI 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'sgetHaircutRateslippageParamK{BigNumber} in WAD. Can be obtained from pool's contract'sgetSlippageParamKslippageParamN{BigNumber} in BigNumber Int. Can be obtained from pool's contract'sgetSlippageParamNslippageParamC1{BigNumber} in WAD. Can be obtained from pool's contract'sgetC1slippageParamXThreshold{BigNumber} in WAD. Can be obtained from pool's contract'sgetXThresholdreturns{BigNumber} FROM amount, Delta X, in WAD