Skip to content

Commit

Permalink
chore: polygon swap works
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrzn committed Apr 22, 2024
1 parent ead9ca1 commit eed7484
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
14 changes: 0 additions & 14 deletions autotx/tests/integration/test_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,3 @@ def test_swap_multiple_tokens(configuration):
shib_balance = manager.balance_of(shib_address)
shib_balance = manager.balance_of(shib_address)
assert shib_balance > 0


# def test_swap_through_eoa(configuration):
# (user, _, client, _) = configuration
# network_info = NetworkInfo(client.w3.eth.chain_id)
# gno_address = ETHAddress(network_info.tokens["gno"])
# swap(
# client,
# user,
# 3,
# ETHAddress(NATIVE_TOKEN_ADDRESS),
# gno_address,
# network_info.chain_id
# )
2 changes: 2 additions & 0 deletions autotx/utils/ethereum/helpers/fill_dev_account_with_erc20.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def fill_dev_account_with_erc20(
tokens_to_transfer = {"usdc": 3500, "dai": 3500, "wbtc": 0.1}
if network_info.chain_id is ChainId.GNOSIS:
tokens_to_transfer = {"usdc": 2000, "gno": 5, "cow": 4000 }
if network_info.chain_id is ChainId.POLYGON:
tokens_to_transfer = {"usdc": 2000, "wbtc": 0.01, "dai": 2000 }

native_token_address = ETHAddress(NATIVE_TOKEN_ADDRESS)
for token in network_info.tokens:
Expand Down
7 changes: 4 additions & 3 deletions autotx/utils/ethereum/helpers/swap_from_eoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ def swap(
) -> None:
txs = build_swap_transaction(
client,
Decimal(amount),
Decimal(str(amount)),
from_token,
to_token,
ETHAddress(user.address),
False,
chain
)

for i, tx in enumerate(txs):
for tx in txs:
gas = 1500000 if chain is ChainId.GNOSIS else int(tx.tx["gas"], 0)
transaction = user.sign_transaction( # type: ignore
{
**tx.tx,
"nonce": client.w3.eth.get_transaction_count(user.address),
"gas": 1500000
"gas": gas
}
)

Expand Down
1 change: 1 addition & 0 deletions autotx/utils/ethereum/lifi/swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def get_quote(
"data": quote["transactionRequest"]["data"],
"data": quote["transactionRequest"]["gasPrice"],
"gas": quote["transactionRequest"]["gasLimit"],
"gasPrice": quote["transactionRequest"]["gasPrice"],
"value": Wei(int(quote["transactionRequest"]["value"], 0)),
"chainId": quote["transactionRequest"]["chainId"]
}
Expand Down
1 change: 1 addition & 0 deletions autotx/utils/ethereum/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class NetworkConfiguration:
"usdc": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
"dai": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
"usdt": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
"wbtc": "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6"
},
),
ChainId.BASE_MAINNET: NetworkConfiguration(
Expand Down

0 comments on commit eed7484

Please sign in to comment.