-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapprove.py
More file actions
42 lines (35 loc) · 1.28 KB
/
approve.py
File metadata and controls
42 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import asyncio
from eth_account import Account
from eth_account.messages import encode_defunct
import httpx
from dotenv import load_dotenv
from predict_sdk import (
OrderBuilder,
ChainId,
Side,
BuildOrderInput,
LimitHelperInput,
)
def approve():
# Load environment variables
load_dotenv()
# Create a wallet to sign the message (must be the orders' `maker`)
private_key = os.getenv("WALLET_PRIVATE_KEY")
signer = Account.from_key(private_key)
builder = OrderBuilder.make(ChainId.BNB_MAINNET, signer)
# Set all approvals at once
# ⚠ Note: This SDK does not perform duplicate call checks. Avoid repeated calls.
result = builder.set_approvals(is_yield_bearing=False)
# USDT approve NegRiskCtfExchangen 0x365fb81bd4A24D6303cd2F19c349dE6894D8d58A max
# USDT approve CtfExchange 0x8BC070BEdAB741406F4B1Eb65A72bee27894B689 max
# ConditionalTokens(0x22DA1810B194ca018378464a58f6Ac2B10C9d244) ApprovalForAll CtfExchange,NegRiskCtfExchangen,NegRiskAdapter
if result.success:
print("All approvals set successfully!")
else:
print("Some approvals failed")
for tx in result.transactions:
if not tx.success:
print(f"Failed: {tx.cause}")
if __name__ == '__main__':
approve()