Running the tx from the safe
The last step is running a tx submission to the multisign using the previous method.
1
def run_trade_sep_21():
2
safe = ApeSafe("0xMySafeAddress")
3
4
yfi = safe.contract("0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e")
5
usdc = safe.contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
6
link = safe.contract("0x514910771AF9Ca656af840dff83E8264EcF986CA")
7
gusd = safe.contract("0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd")
8
9
cowswap_sell(safe, yfi, gusd)
10
cowswap_sell(safe, usdc, gusd)
11
cowswap_sell(safe, link, gusd)
12
13
safe_tx = safe.multisend_from_receipts()
14
account = click.prompt("signer", type=click.Choice(accounts.load()))
15
safe_tx.sign(accounts.load(account).private_key)
16
safe.preview(safe_tx, events=False, call_trace=False)
17
safe.post_transaction(safe_tx)
Copied!
This run will not be the typical ape safe tx. When you run the code you are actually calling the api and creating an order. You can create as many orders as you want BUT they are not valid until you sign them. In our case, executing the tx in the multisign will do the trick.
Once the tx is signed, you can query the /solvable_orders endpoint to see your trades avaiable to solvers. You can check the output from https://api.cow.fi/mainnet/#/default/get_api_v1_solvable_orders.
After a few minutes I got two transfers, the first was yfi and link converted to gusd and on the second one usdc converted to gusd.
Copy link