-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathfunctions.py
More file actions
307 lines (211 loc) · 9.68 KB
/
functions.py
File metadata and controls
307 lines (211 loc) · 9.68 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
import random
from modules import *
from utils.networks import *
from config import LAYERZERO_WRAPED_NETWORKS
from settings import (SRC_CHAIN_BUNGEE, NATIVE_CHAIN_ID_FROM, NATIVE_CHAIN_ID_TO)
def get_client(account_name, private_key, network, proxy) -> Client:
return Client(account_name, private_key, network, proxy)
def get_interface_by_chain_id(chain_id):
return {
2: ArbitrumNova,
3: Base,
4: Linea,
8: Scroll,
11: ZkSync,
12: Zora,
13: Ethereum,
}[chain_id]
def get_network_by_chain_id(chain_id):
return {
0: ArbitrumRPC,
1: ArbitrumRPC,
2: Arbitrum_novaRPC,
3: BaseRPC,
4: LineaRPC,
5: MantaRPC,
6: PolygonRPC,
7: OptimismRPC,
8: ScrollRPC,
# 9: StarknetRPC,
10: Polygon_ZKEVM_RPC,
11: zkSyncEraRPC,
12: ZoraRPC,
13: EthereumRPC,
14: AvalancheRPC,
15: BSC_RPC,
16: MoonbeamRPC,
17: HarmonyRPC,
18: TelosRPC,
19: CeloRPC,
20: GnosisRPC,
21: CoreRPC,
22: TomoChainRPC,
23: ConfluxRPC,
24: OrderlyRPC,
25: HorizenRPC,
26: MetisRPC,
27: AstarRPC,
28: OpBNB_RPC,
29: MantleRPC,
30: MoonriverRPC,
31: KlaytnRPC,
32: KavaRPC,
33: FantomRPC,
34: AuroraRPC,
35: CantoRPC,
36: DFK_RPC,
37: FuseRPC,
38: GoerliRPC,
39: MeterRPC,
40: OKX_RPC,
41: ShimmerRPC,
42: TenetRPC,
43: XPLA_RPC,
44: LootChainRPC,
45: ZKFairRPC,
46: BeamRPC,
47: InEVM_RPC,
48: RaribleRPC,
49: BlastRPC,
}[chain_id]
async def cex_deposit_util(current_client, dapp_id:int, deposit_data:tuple):
class_name = {
1: OKX,
2: BingX,
3: Binance,
4: Bitget
}[dapp_id]
return await class_name(current_client).deposit(deposit_data=deposit_data)
async def okx_deposit(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_deposit(dapp_id=1)
async def bingx_deposit(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_deposit(dapp_id=2)
async def binance_deposit(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_deposit(dapp_id=3)
async def bitget_deposit(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_deposit(dapp_id=4)
async def bridge_utils(current_client, dapp_id, chain_from_id, bridge_data, need_fee=False):
class_bridge = {
1: Across,
2: Bungee,
3: Relay,
4: Nitro,
5: Orbiter,
6: Owlto,
7: Relay,
8: Rhino,
}[dapp_id]
return await class_bridge(current_client).bridge(chain_from_id, bridge_data, need_check=need_fee)
async def bridge_across(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=1)
async def bridge_bungee(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=2)
async def bridge_relay2(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=3)
async def bridge_nitro(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=4)
async def bridge_orbiter(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=5)
async def bridge_owlto(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=6)
async def bridge_relay(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=7)
async def bridge_rhino(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_bridge(dapp_id=8)
async def okx_withdraw(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_withdraw(dapp_id=1)
async def bingx_withdraw(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_withdraw(dapp_id=2)
async def binance_withdraw(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_withdraw(dapp_id=3)
async def bitget_withdraw(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.smart_cex_withdraw(dapp_id=4)
async def bridge_native(account_name, private_key, _, proxy, *args, **kwargs):
network = get_network_by_chain_id(13)
blockchain = get_interface_by_chain_id(random.choice(NATIVE_CHAIN_ID_TO))
worker = blockchain(get_client(account_name, private_key, network, proxy))
return await worker.deposit(*args, **kwargs)
async def transfer_eth(account_name, private_key, network, proxy):
blockchain = get_interface_by_chain_id(13)
worker = blockchain(get_client(account_name, private_key, network, proxy))
return await worker.transfer_eth()
async def transfer_eth_to_myself(account_name, private_key, network, proxy):
blockchain = get_interface_by_chain_id(13)
worker = blockchain(get_client(account_name, private_key, network, proxy))
return await worker.transfer_eth_to_myself()
async def wrap_eth(account_name, private_key, network, proxy, *args):
worker = SimpleEVM(get_client(account_name, private_key, network, proxy))
return await worker.wrap_eth(*args)
async def unwrap_eth(account_name, private_key, network, proxy, *args):
worker = SimpleEVM(get_client(account_name, private_key, network, proxy))
return await worker.unwrap_eth(*args)
# async def mint_deployed_token(account_name, private_key, network, proxy, *args, **kwargs):
# mint = ZkSync(account_name, private_key, network, proxy)
# await mint.mint_token()
async def swap_odos(account_name, private_key, network, proxy, **kwargs):
worker = Odos(get_client(account_name, private_key, network, proxy))
return await worker.swap(**kwargs)
async def swap_oneinch(account_name, private_key, network, proxy, **kwargs):
worker = OneInch(get_client(account_name, private_key, network, proxy))
return await worker.swap(**kwargs)
async def swap_izumi(account_name, private_key, network, proxy, **kwargs):
worker = Izumi(get_client(account_name, private_key, network, proxy))
return await worker.swap(**kwargs)
async def refuel_bungee(account_name, private_key, _, proxy):
chain_from_id = LAYERZERO_WRAPED_NETWORKS[random.choice(SRC_CHAIN_BUNGEE)]
network = get_network_by_chain_id(chain_from_id)
worker = Bungee(get_client(account_name, private_key, network, proxy))
return await worker.refuel()
async def withdraw_txsync(account_name, private_key, _, proxy):
blockchain = get_interface_by_chain_id(11)
network = get_network_by_chain_id(11)
worker = blockchain(get_client(account_name, private_key, network, proxy))
return await worker.withdraw()
async def swap_uniswap(account_name, private_key, network, proxy, **kwargs):
worker = Uniswap(get_client(account_name, private_key, network, proxy))
return await worker.swap(**kwargs)
async def mint_mintfun(account_name, private_key, network, proxy):
worker = MintFun(get_client(account_name, private_key, network, proxy))
return await worker.mint()
async def random_approve(account_nameaccount_name, private_key, network, proxy):
blockchain = get_interface_by_chain_id(13)
worker = blockchain(get_client(account_nameaccount_name, private_key, network, proxy))
return await worker.random_approve()
async def make_balance_to_average(account_name, private_key, network, proxy):
worker = Custom(get_client(account_name, private_key, network, proxy))
return await worker.balance_average()
async def okx_withdraw_util(current_client, **kwargs):
worker = OKX(current_client)
return await worker.withdraw(**kwargs)
async def bingx_withdraw_util(current_client, **kwargs):
worker = BingX(current_client)
return await worker.withdraw(**kwargs)
async def binance_withdraw_util(current_client, **kwargs):
worker = Binance(current_client)
return await worker.withdraw(**kwargs)
async def bitget_withdraw_util(current_client, **kwargs):
worker = Bitget(current_client)
return await worker.withdraw(**kwargs)
async def bingx_transfer(account_name, private_key, network, proxy):
worker = BingX(get_client(account_name, private_key, network, proxy))
return await worker.withdraw(transfer_mode=True)
async def bridge_zora(account_name, private_key, _, proxy):
network = get_network_by_chain_id(random.choice(NATIVE_CHAIN_ID_FROM))
worker = Zora(get_client(account_name, private_key, network, proxy))
return await worker.bridge()