@iloop/sdk
v1.8.1
Published
Downloads
1,257
Readme
#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]