Skip to content

Commit

Permalink
Adding and fixing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
slundqui committed Oct 17, 2024
1 parent 6a69123 commit ca80290
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/agent0/ethpy/hyperdrive/interface/_contract_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ async def _async_close_long(

contract_fn = interface.hyperdrive_contract.functions.closeLong(*fn_args)
tx_params = TxParams({"from": sender.address})

# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
preview_result = None
if preview_before_trade or slippage_tolerance is not None:
preview_result = contract_fn.call(
Expand Down Expand Up @@ -516,6 +519,8 @@ async def _async_open_short(

contract_fn = interface.hyperdrive_contract.functions.openShort(*fn_args)
tx_params = TxParams({"from": sender.address})
# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
preview_result = None
if preview_before_trade or slippage_tolerance is not None:
preview_result = contract_fn.call(
Expand Down Expand Up @@ -608,6 +613,8 @@ async def _async_close_short(

contract_fn = interface.hyperdrive_contract.functions.closeShort(*fn_args)
tx_params = TxParams({"from": sender.address})
# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
preview_result = None
if preview_before_trade or slippage_tolerance is not None:
preview_result = contract_fn.call(
Expand Down Expand Up @@ -715,6 +722,8 @@ async def _async_add_liquidity(

contract_fn = interface.hyperdrive_contract.functions.addLiquidity(*fn_args)
tx_params = TxParams({"from": sender.address})
# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
if preview_before_trade:
_ = contract_fn.call(
tx_params,
Expand Down Expand Up @@ -785,6 +794,8 @@ async def _async_remove_liquidity(
)
contract_fn = interface.hyperdrive_contract.functions.removeLiquidity(*fn_args)
tx_params = TxParams({"from": sender.address})
# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
if preview_before_trade is True:
_ = contract_fn.call(
tx_params,
Expand Down Expand Up @@ -855,11 +866,10 @@ async def _async_redeem_withdraw_shares(
interface.txn_signature, # extraData
),
)
# To catch any solidity errors, we always preview transactions on the current block
# before calling smart contract transact
# Since current_pool_state.block_number is a property, we want to get the static block here
contract_fn = interface.hyperdrive_contract.functions.redeemWithdrawalShares(*fn_args)
tx_params = TxParams({"from": sender.address})
# To catch any solidity errors, we preview transactions on the current block
# before calling smart contract transact
if preview_before_trade is True:
preview_result = contract_fn.call(
tx_params,
Expand Down

0 comments on commit ca80290

Please sign in to comment.