-
Notifications
You must be signed in to change notification settings - Fork 5
/
testIt.out
192 lines (169 loc) · 13.9 KB
/
testIt.out
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
Compiled 1 Solidity file successfully (evm target: cancun).
Chadex
beforeEach
--- Setup Tokens and Chadex Contracts. Assuming gasPrice: 10.0 gwei, ethUsd: 2500.0 ---
Mapping contract 0x5FbDB2315678afecb367f032d93F642f64180aa3 => Token0:0x5FbD
Token0 deployed: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Mapping contract 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 => Token1:0xe7f1
Token1 deployed: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Mapping contract 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 => WETH:0x9fE4
WETH deployed: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
Mapping contract 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 => Chadex:0xCf7E
Chadex deployed: 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
> Transfer Token0 - gasUsed: 51394 ~ ETH 0.00051394 ~ USD 1
+ Token0:0x5FbD Transfer(from: deployer:0xf39F, to: user0:0x7099, tokens: 100.0)
> Transfer Token0 - gasUsed: 51382 ~ ETH 0.00051382 ~ USD 1
+ Token0:0x5FbD Transfer(from: deployer:0xf39F, to: user1:0x3C44, tokens: 100.0)
> Transfer Token0 - gasUsed: 51394 ~ ETH 0.00051394 ~ USD 1
+ Token0:0x5FbD Transfer(from: deployer:0xf39F, to: user2:0x90F7, tokens: 100.0)
> Transfer Token0 - gasUsed: 46594 ~ ETH 0.00046594 ~ USD 1
+ Token0:0x5FbD Transfer(from: deployer:0xf39F, to: user3:0x15d3, tokens: 100.0)
Tokens transferred
> Transfer Token1 - gasUsed: 51394 ~ ETH 0.00051394 ~ USD 1
+ Token1:0xe7f1 Transfer(from: deployer:0xf39F, to: user0:0x7099, tokens: 100.0)
> Transfer Token1 - gasUsed: 51382 ~ ETH 0.00051382 ~ USD 1
+ Token1:0xe7f1 Transfer(from: deployer:0xf39F, to: user1:0x3C44, tokens: 100.0)
> Transfer Token1 - gasUsed: 51394 ~ ETH 0.00051394 ~ USD 1
+ Token1:0xe7f1 Transfer(from: deployer:0xf39F, to: user2:0x90F7, tokens: 100.0)
> Transfer Token1 - gasUsed: 46594 ~ ETH 0.00046594 ~ USD 1
+ Token1:0xe7f1 Transfer(from: deployer:0xf39F, to: user3:0x15d3, tokens: 100.0)
> Send weth - gasUsed: 44784 ~ ETH 0.00044784 ~ USD 1
+ WETH:0x9fE4 Deposit(from: null:0x0000, to: user0:0x7099, tokens: 100.0)
> Send weth - gasUsed: 44784 ~ ETH 0.00044784 ~ USD 1
+ WETH:0x9fE4 Deposit(from: null:0x0000, to: user1:0x3C44, tokens: 100.0)
> Send weth - gasUsed: 44784 ~ ETH 0.00044784 ~ USD 1
+ WETH:0x9fE4 Deposit(from: null:0x0000, to: user2:0x90F7, tokens: 100.0)
> Send weth - gasUsed: 44784 ~ ETH 0.00044784 ~ USD 1
+ WETH:0x9fE4 Deposit(from: null:0x0000, to: user3:0x15d3, tokens: 100.0)
> user0->token0.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token0:0x5FbD Approval(owner: user0:0x7099, spender: Chadex:0xCf7E, tokens: 10.0)
> user0->token1.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token1:0xe7f1 Approval(owner: user0:0x7099, spender: Chadex:0xCf7E, tokens: 10.0)
> user0->weth.approve(chadex, 2.69) - gasUsed: 46174 ~ ETH 0.00046174 ~ USD 1
+ WETH:0x9fE4 Approval(owner: user0:0x7099, spender: Chadex:0xCf7E, tokens: 2.69)
> user1->token0.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token0:0x5FbD Approval(owner: user1:0x3C44, spender: Chadex:0xCf7E, tokens: 10.0)
> user1->token1.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token1:0xe7f1 Approval(owner: user1:0x3C44, spender: Chadex:0xCf7E, tokens: 10.0)
> user1->weth.approve(chadex, 2.69) - gasUsed: 46174 ~ ETH 0.00046174 ~ USD 1
+ WETH:0x9fE4 Approval(owner: user1:0x3C44, spender: Chadex:0xCf7E, tokens: 2.69)
> user2->token0.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token0:0x5FbD Approval(owner: user2:0x90F7, spender: Chadex:0xCf7E, tokens: 10.0)
> user2->token1.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token1:0xe7f1 Approval(owner: user2:0x90F7, spender: Chadex:0xCf7E, tokens: 10.0)
> user2->weth.approve(chadex, 2.69) - gasUsed: 46174 ~ ETH 0.00046174 ~ USD 1
+ WETH:0x9fE4 Approval(owner: user2:0x90F7, spender: Chadex:0xCf7E, tokens: 2.69)
> user3->token0.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token0:0x5FbD Approval(owner: user3:0x15d3, spender: Chadex:0xCf7E, tokens: 10.0)
> user3->token1.approve(chadex, 10.0) - gasUsed: 46151 ~ ETH 0.00046151 ~ USD 1
+ Token1:0xe7f1 Approval(owner: user3:0x15d3, spender: Chadex:0xCf7E, tokens: 10.0)
> user3->weth.approve(chadex, 2.69) - gasUsed: 46174 ~ ETH 0.00046174 ~ USD 1
+ WETH:0x9fE4 Approval(owner: user3:0x15d3, spender: Chadex:0xCf7E, tokens: 2.69)
00. Test 00 - Happy Path - Specified Set
Executing: [
{
"action": 2,
"buySell": 1,
"tokenz": [
"0x5FbDB2315678afecb367f032d93F642f64180aa3",
"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
],
"price": "690100000",
"targetPrice": "690100000",
"expiry": 1729053327,
"baseTokens": "1000000000000000000",
"skipCheck": false
}
]
* execute 0
↳ _getMoreInfo
↳ _trade
↳ _addOrder
> user0->chadex.execute(actionsA) - gasUsed: 430347 ~ ETH 0.00430347 ~ USD 10
+ Chadex:0xCf7E PairAdded(pairKey: 0x2c831da670a13afa44, maker: user0:0x7099, base: Token0:0x5FbD, quote: WETH:0x9fE4, decimalss: [18,18], timestamp: 1729049754)
+ Chadex:0xCf7E OrderAdded(pairKey: 0x2c831da670a13afa44, orderKey: 0xb488785b6bbb1a2d12, maker: user0:0x7099, buySell: 1, price: 0.6901, expiry: 1729053327, baseTokens: 1.0, quoteTokens: 0.6901, timestamp: 1729049754)
--- After Adding Orders ---
Account ETH TOK0[18] TOK1[18] WETH[18] Blah
-------------------- ------------------------ ------------------------ ------------------------ ------------------------ ---------------------------------------------
deployer:0xf39F 9999.987087683254300098 0.0 0.0 0.0
user0:0x7099 9899.999354584442499916 100.0 100.0 100.0
user1:0x3C44 9899.99980017939331932 100.0 100.0 100.0
user2:0x90F7 9899.999804108541453716 100.0 100.0 100.0
user3:0x15d3 9899.999806933981917809 100.0 100.0 100.0
Chadex:0xCf7E 0.0 0.0 0.0 0.0
Chadex: Chadex:0xCf7E
----- Pair 0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2 Token0:0x5FbD/WETH:0x9fE4 18 18 -----
# BUY Price OrderKey Next Maker Expiry(s) Tokens Total Available Base Total Available Quote
--- -------------- ---------- ---------- ------------ ---------- --------------------- ------------------------ ------------------------
# SELL Price OrderKey Next Maker Expiry(s) Tokens Total Available Base Total Available Quote
--- -------------- ---------- ---------- ------------ ---------- --------------------- ------------------------ ------------------------
0 0.6901 0xb488785b 0x00000000 user0:0x7099 59.99 1.0 10.0 6.901
price: 0.6901 head=0xb488785b tail=0xb488785b
Order key=0xb488785b next=0x00000000 maker=user0:0x7099 expiry=59.99s tokens=1.0
getBestOrder.price 690100000
getBestOrder.offers.queue[i].maker - account 0x70997970c51812dc3a010c7d01b50e0d17dc79c8
pairKey: 0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2, tokenz=["0x5FbDB2315678afecb367f032d93F642f64180aa3","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"], decimalss=[18,18], bestBuyOrder=["0","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000","0","0","0","0"], bestSellOrder=["690100000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x70997970C51812dc3A010C7d01b50e0d17dc79C8","1729053327","1000000000000000000","10000000000000000000","6901000000000000000"]
Executing: [
{
"action": 2,
"buySell": 0,
"tokenz": [
"0x5FbDB2315678afecb367f032d93F642f64180aa3",
"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
],
"price": "690100000",
"targetPrice": "690100000",
"expiry": 1729053327,
"baseTokens": "100000000000000000",
"skipCheck": false
}
]
* execute 0
↳ _getMoreInfo
↳ _trade
_trade.bestMatchingPrice 690100000
_trade.offers.head 0
_trade.offers.queue.length 1
_trade.offers.queue - i 0
_trade.offers.queue[i].maker 0x70997970c51812dc3a010c7d01b50e0d17dc79c8
_trade.offers.queue[i].expiry 1729053327
_trade.offers.queue[i].tokens 1000000000000000000
_trade.offers.queue[i] - balance & approved baseTokens 10000000000000000000
_trade.offers.queue[i] - effective baseTokens 1000000000000000000
_trade.offers.queue[i] - Requested Less - decrement tokens
_trade.offers.queue[i] - Remaining baseTokens 900000000000000000
_trade.offers.queue[i] - baseTokensToTransfer 100000000000000000
_trade.offers.queue[i] - quoteTokensToTransfer 69010000000000000
↳ _addOrder
> user3->chadex.execute(actions) - gasUsed: 356498 ~ ETH 0.00356498 ~ USD 8
+ WETH:0x9fE4 Transfer(from: user3:0x15d3, to: user0:0x7099, tokens: 0.06901)
+ Token0:0x5FbD Transfer(from: user0:0x7099, to: user3:0x15d3, tokens: 0.1)
+ Chadex:0xCf7E OrderAdded(pairKey: 0x2c831da670a13afa44, orderKey: 0x2d1b2a04c8e7af8244, maker: user3:0x15d3, buySell: 0, price: 0.6901, expiry: 1729053327, baseTokens: 0.1, quoteTokens: 0.06901, timestamp: 1729049755)
--- After Executing Against Orders ---
Account ETH TOK0[18] TOK1[18] WETH[18] Blah
-------------------- ------------------------ ------------------------ ------------------------ ------------------------ ---------------------------------------------
deployer:0xf39F 9999.987087683254300098 0.0 0.0 0.0
user0:0x7099 9899.999354584442499916 99.9 100.0 100.06901
user1:0x3C44 9899.99980017939331932 100.0 100.0 100.0
user2:0x90F7 9899.999804108541453716 100.0 100.0 100.0
user3:0x15d3 9899.999443366157426441 100.1 100.0 99.93099
Chadex:0xCf7E 0.0 0.0 0.0 0.0
Chadex: Chadex:0xCf7E
----- Pair 0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2 Token0:0x5FbD/WETH:0x9fE4 18 18 -----
# BUY Price OrderKey Next Maker Expiry(s) Tokens Total Available Base Total Available Quote
--- -------------- ---------- ---------- ------------ ---------- --------------------- ------------------------ ------------------------
0 0.6901 0x2d1b2a04 0x00000000 user3:0x15d3 59.99 0.1 3.797985799159542095 2.62099
price: 0.6901 head=0x2d1b2a04 tail=0x2d1b2a04
Order key=0x2d1b2a04 next=0x00000000 maker=user3:0x15d3 expiry=59.99s tokens=0.1
# SELL Price OrderKey Next Maker Expiry(s) Tokens Total Available Base Total Available Quote
--- -------------- ---------- ---------- ------------ ---------- --------------------- ------------------------ ------------------------
1 0.6901 0xb488785b 0x00000000 user0:0x7099 59.99 1.0 9.9 6.83199
price: 0.6901 head=0xb488785b tail=0xb488785b
Order key=0xb488785b next=0x00000000 maker=user0:0x7099 expiry=59.99s tokens=1.0
getBestOrder.price 690100000
getBestOrder.offers.queue[i].maker - account 0x15d34aaf54267db7d7c367839aaf71a00a2c6a65
getBestOrder.price 690100000
getBestOrder.offers.queue[i].maker - account 0x70997970c51812dc3a010c7d01b50e0d17dc79c8
pairKey: 0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2, tokenz=["0x5FbDB2315678afecb367f032d93F642f64180aa3","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"], decimalss=[18,18], bestBuyOrder=["690100000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65","1729053327","100000000000000000","3797985799159542095","2620990000000000000"], bestSellOrder=["690100000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000","0x70997970C51812dc3A010C7d01b50e0d17dc79C8","1729053327","900000000000000000","9900000000000000000","6831990000000000000"]
✔ 00. Test 00 (40ms)
1 passing (741ms)