-
Notifications
You must be signed in to change notification settings - Fork 5
/
create_swap_order.py
63 lines (48 loc) · 1.57 KB
/
create_swap_order.py
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
from utils import _set_paths
_set_paths()
from gmx_python_sdk.scripts.v2.order.create_swap_order import SwapOrder
from gmx_python_sdk.scripts.v2.order.order_argument_parser import (
OrderArgumentParser
)
from gmx_python_sdk.scripts.v2.gmx_utils import ConfigManager
config = ConfigManager(chain='arbitrum')
config.set_config()
parameters = {
"chain": 'arbitrum',
# token to use as collateral. Start token swaps into collateral token if
# different
"out_token_symbol": "ETH",
# the token to start with - WETH not supported yet
"start_token_symbol": "SOL",
# True for long, False for short
"is_long": False,
# Position size in in USD
"size_delta_usd": 0,
# if leverage is passed, will calculate number of tokens in
# start_token_symbol amount
"initial_collateral_delta": 0.05,
# as a percentage
"slippage_percent": 0.03
}
order_parameters = OrderArgumentParser(
config,
is_swap=True
).process_parameters_dictionary(
parameters
)
order = SwapOrder(
config=config,
market_key=order_parameters['swap_path'][-1],
start_token=order_parameters['start_token_address'],
out_token=order_parameters['out_token_address'],
collateral_address=order_parameters['start_token_address'],
index_token_address=order_parameters['out_token_address'],
is_long=False,
size_delta=0,
initial_collateral_delta_amount=(
order_parameters['initial_collateral_delta']
),
slippage_percent=order_parameters['slippage_percent'],
swap_path=order_parameters['swap_path'],
debug_mode=True
)