@iloop/sdk-mainnet
TypeScript icon, indicating that this package has built-in type declarations

1.0.19 • Public • Published

#iloop-sdk

Calculate adjust leverage

  • Deposit: A token JITOSOL
  • Current leverage: X
  • New leverage: Y

-> New Deposit amount: A * Y/X = B

-> Total withdraw collateral: A - B = C

-> if C > 0 -> decrease leverage -> [flashBorrow SOL, repay flashBorrowSOL, withdraw collateral, swap collateral to SOL, flash repay SOL]

if C < 0 - increase leverage -> [flash borrow SOL, swap into JitoSOL, deposit JitoSOL to reserve, borrow SOL from reserve, flash repay SOL]

Calculate withdraw collateral

  • total deposit A token JitoSOL
  • Current leverage X
  • withdraw B token

-> Actual withdraw from Reserve: B * X

-> Swap amount = B * X - B = C

-> [flash borrow SOL from reserve, repay flash borrow amount to reserve, withdraw JITOSOL, swap JITOSOL to SOL, flash repay SOL ]

Close multiply position

  • Borrow A SOL
  • Total deposit B SOL

-> [flash borrow A SOL, repay A SOL, withdraw B JitoSOL, swap Y JitoSOL to A SOL, repay A SOL]

Readme

Keywords

none

Package Sidebar

Install

npm i @iloop/sdk-mainnet

Weekly Downloads

1

Version

1.0.19

License

MIT

Unpacked Size

1.01 MB

Total Files

226

Last publish

Collaborators

  • nhtera