close_short_position

Documentation for eth_defi.one_delta.position.close_short_position function.

close_short_position(one_delta_deployment, *, collateral_token, borrow_token, atoken, pool_fee, wallet_address, exchange=Exchange.UNISWAP_V3, interest_mode=AaveV3InterestRateMode.VARIABLE, withdraw_collateral_amount=115792089237316195423570985008687907853269984665640564039457584007913129639935)[source]

Close a short position using flash swap then withdraw collateral from Aave.

NOTE: - only single-hop swap is supported at the moment - withdraw_collateral_amount should be used wisely in case there are multiple positions opened with same collateral, it will affect the collateral amount to be left on Aave to back other positions hence affecting the liquidation threshold as well.

Parameters
  • one_delta_deployment (eth_defi.one_delta.deployment.OneDeltaDeployment) – 1delta deployment

  • collateral_token (web3.contract.contract.Contract) – collateral token contract proxy

  • borrow_token (web3.contract.contract.Contract) – borrow token contract proxy

  • atoken (web3.contract.contract.Contract) – aToken contract proxy

  • pool_fee (int) – raw fee of the pool which is used for the swap

  • collateral_amount – amount of collateral to be supplied

  • borrow_amount – amount of borrow token to be borrowed

  • wallet_address (str) – wallet address of the user

  • exchange (eth_defi.one_delta.constants.Exchange) – exchange to be used for the swap

  • interest_mode (eth_defi.aave_v3.constants.AaveV3InterestRateMode) – interest mode, variable or stable

  • withdraw_collateral_amount (int) – the amount of collateral to be withdrawn, if 0 then only flash swap will be executed

Returns

multicall contract function to close the short position then withdraw collateral

Return type

web3.contract.contract.ContractFunction