LoopingHook
Looping Hook contract, which uses the same implementation as MarginTradingHook contract.
View Functions
swapHelper
Get the swap helper contract that this contract swaps between quote and base assets.
lastOrderId
Last running order (take profit or stop loss) id.
getBaseAssetAndQuoteAsset
Get a unique base and quote assets from a pair of tokens.
getMarginPos
Get a looping position.
External Functions
openPos
Open a new looping position by swapping borrPool
's underlying token into collPool
's underlying token via swap data _data
.
The fucntion perform multicall
to InitCore:
borrow tokens
callback (perform swap from borrow token to collateral token)
deposit collateral tokens to lending pool
collateralize inTokens
The swap callback is routed back to this contract's coreCallback
which performs a swap using _data
on swapHelper
contract with slippage control amtOut
.
NOTE: _tokenIn
must be either _borrPool
's underlying token or _collPool
's underlying token.
Returns:
increasePos
Increase an existing position's size by taking token from position owner and/or borrow more tokens.
_collPool
and borrPool
are fixed from the existing position.
Returns:
addCollateral
Decrease position's leverage by adding more collateral token.
Parameters:
removeCollateral
Increase position's leverage by removing collateral token.
Parameters:
repayDebt
Decrease position's leverage by repaying borrow token.
Parameters:
Returns:
reducePos
Reduce an existing position's size by withdrawing collateral and repaying borrow token. The withdrawn collateral token can be swapped to repay borrow token using _data
. The user can specify which token to receive, if there is still left after swap.
Parameters:
Returns:
Last updated