one_delta.position
Documentation for eth_defi.one_delta.position Python module.
1delta integration position handlers.
Open and close short positions using 1delta protocol
Functions
|
Approve all the tokens needed for the position. |
|
Close a short position using flash swap then withdraw collateral from Aave. |
|
Supply collateral to Aave and open a short position using flash swap. |
|
Reduce a short position size. |
- approve(one_delta_deployment, *, collateral_token, borrow_token, atoken, vtoken, aave_v3_deployment, collateral_amount=115792089237316195423570985008687907853269984665640564039457584007913129639935, borrow_amount=115792089237316195423570985008687907853269984665640564039457584007913129639935, atoken_amount=115792089237316195423570985008687907853269984665640564039457584007913129639935, vtoken_amount=115792089237316195423570985008687907853269984665640564039457584007913129639935)
Approve all the tokens needed for the position.
- 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
vtoken (web3.contract.contract.Contract) – vToken contract proxy
collateral_amount (int) – amount of collateral to be approved
borrow_amount (int) – amount of borrow token to be approved
atoken_amount (int) – amount of aToken to be approved
vtoken_amount (int) – amount of vToken to be approved
aave_v3_deployment (eth_defi.aave_v3.deployment.AaveV3Deployment) – Aave V3 deployment
- Returns
list of approval functions
- Return type
list[web3.contract.contract.ContractFunction]
- open_short_position(one_delta_deployment, *, collateral_token, borrow_token, pool_fee, collateral_amount, borrow_amount, wallet_address, min_collateral_amount_out=0, exchange=Exchange.UNISWAP_V3, interest_mode=AaveV3InterestRateMode.VARIABLE, do_supply=True)
Supply collateral to Aave and open a short position using flash swap. This function can also be used to increase existing short position of the same pair.
NOTE: only single-hop swap is supported at the moment
- 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
pool_fee (int) – raw fee of the pool which is used for the swap
collateral_amount (int) – amount of collateral to be supplied
borrow_amount (int) – amount of borrow token to be borrowed
wallet_address (str) – wallet address of the user
min_collateral_amount_out (int) – minimum amount of collateral to be received
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
do_supply (bool) – default to True, if False, only flash swap will be executed
- Returns
multicall contract function to supply collateral and open the short position
- Return type
web3.contract.contract.ContractFunction
- 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)
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
- reduce_short_position(one_delta_deployment, *, collateral_token, borrow_token, atoken, pool_fee, wallet_address, reduce_borrow_amount=None, reduce_collateral_amount=None, min_borrow_amount_out=None, max_collateral_amount_in=None, withdraw_collateral_amount=None, exchange=Exchange.UNISWAP_V3, interest_mode=AaveV3InterestRateMode.VARIABLE)
Reduce a short position size.
NOTE: only single-hop swap is supported at the moment
- 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
pool_fee (int) – raw fee of the pool which is used for the swap
wallet_address (str) – wallet address of the user
reduce_borrow_amount (int | None) – amount of borrow token to be reduced
reduce_collateral_amount (int | None) – amount of collateral to be reduced
min_borrow_amount_out (int | None) – minimum amount of borrow token to be received
min_collateral_amount_out – minimum amount of collateral to be received
withdraw_collateral_amount (int | None) – the amount of collateral to be withdrawn, if 0 then only flash swap will be executed
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
atoken (web3.contract.contract.Contract) –
max_collateral_amount_in (int | None) –
- Returns
multicall contract function to reduce short position then withdraw collateral
- Return type
web3.contract.contract.ContractFunction