@@ -92,15 +92,25 @@ func TestPoolInitManual(t *testing.T) {
92
92
}
93
93
94
94
func TestPoolCreatePool(t *testing.T) {
95
+ /*
96
+ wanted swap ratio
97
+
98
+ 1 ugnot = 2 ubar (1gnot=2bar)
99
+ 1 ubar = 2 ubaz (1gnot = 4baz)
100
+ 1 ubaz = 5 ufoo (1gnot = 20foo)
101
+ 1 ugnot = 1 ugns (1gnot = 1gns)
102
+ 1 ugns = 10 uqux (1gnot = 10qux)
103
+
104
+ */
95
105
std.TestSetOrigCaller(pc01)
96
106
97
107
gsaOldGnsBalance := gns.BalanceOf(a2u(gsa))
98
108
99
- pl.CreatePool(gnotPath, barPath, uint16(100), 112046633483750523682330982) // tick = 131_230 , ratio = x0.00000200003896770816773820374223635809585175593384
100
- pl.CreatePool(barPath, bazPath, uint16(100), 112040957517951813098925484553 ) // tick = 6_931 , ratio = x1.99983634019692790850797337043331936001777648925781
101
- pl.CreatePool(bazPath, fooPath, uint16(100), 177157928842132501967358423881 ) // tick = 16_095 , ratio = x4.99990809049723150536692628520540893077850341796875
102
- pl.CreatePool(gnsPath, gnotPath, uint16(100), 79228110147883812484826847210100) // tick = 138_162 , ratio = x999998.67808714578859508037567138671875000000000000000000
103
- pl.CreatePool(gnsPath, quxPath, uint16(100), 250541420775534450580036817218 ) // tick = 23_027 , ratio = x9.99999779681069611569910193793475627899169921875000
109
+ pl.CreatePool(gnotPath, barPath, uint16(100), 112046559425783515914356180039) // tick = 6_932 , ratio = x2.00003632383094753777186269871890544891357421875000
110
+ pl.CreatePool(barPath, bazPath, uint16(100), 112046559425783515914356180039 ) // tick = 6_932 , ratio = x2.00003632383094753777186269871890544891357421875000
111
+ pl.CreatePool(bazPath, fooPath, uint16(100), 177166786517138269218369076073 ) // tick = 16_096 , ratio = x5.00040808130628189331901012337766587734222412109375
112
+ pl.CreatePool(gnsPath, gnotPath, uint16(100), 79228162514264337593543950337) // tick = 0 , ratio = x1.00000000000000000000000000000000000000000000000000
113
+ pl.CreatePool(gnsPath, quxPath, uint16(100), 250553947533412109193337304115 ) // tick = 23_028 , ratio = x10.00099779659037757539863378042355179786682128906250
104
114
105
115
gsaNewGnsBalance := gns.BalanceOf(a2u(gsa))
106
116
@@ -120,16 +130,16 @@ func TestPositionMintGnotBar(t *testing.T) {
120
130
testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000000000)
121
131
122
132
tokenId, liquidity, amount0, amount1 := pos.Mint(
123
- gnotPath, // token0 ( will be token1 )
124
- barPath, // token1 ( will be token0 )
125
- uint16(100), // fee
126
- int32(-132230), // tickLower
127
- int32(-130230), // tickUpper
128
- bigint(1000000000), // amount0Desired
129
- bigint(1000000000 ), // amount1Desired
130
- 0, // amount0Min
131
- 0, // amount1Min
132
- MAX_TIMEOUT, // deadline
133
+ gnotPath, // token0 ( will be token1 )
134
+ barPath, // token1 ( will be token0 )
135
+ uint16(100), // fee
136
+ int32(5932), // tickLower
137
+ int32(7932), // tickUpper
138
+ bigint(1000000000), // amount0Desired
139
+ bigint(10000000000 ), // amount1Desired
140
+ 0, // amount0Min
141
+ 0, // amount1Min
142
+ MAX_TIMEOUT, // deadline
133
143
)
134
144
std.TestSetOrigSend(std.Coins{}, nil)
135
145
std.TestSkipHeights(1)
@@ -144,16 +154,16 @@ func TestPositionMintBarBaz(t *testing.T) {
144
154
std.TestSetOrigCaller(lp01)
145
155
146
156
tokenId, liquidity, amount0, amount1 := pos.Mint(
147
- barPath, // token0
148
- bazPath, // token1
149
- uint16(100), // fee
150
- int32(5932), // tickLower
151
- int32(7932), // tickUpper
152
- bigint(1000), // amount0Desired
153
- bigint(999999 ), // amount1Desired
154
- 0, // amount0Min
155
- 0, // amount1Min
156
- MAX_TIMEOUT, // deadline
157
+ barPath, // token0
158
+ bazPath, // token1
159
+ uint16(100), // fee
160
+ int32(5932), // tickLower
161
+ int32(7932), // tickUpper
162
+ bigint(1000000000), // amount0Desired
163
+ bigint(10000000000 ), // amount1Desired
164
+ 0, // amount0Min
165
+ 0, // amount1Min
166
+ MAX_TIMEOUT, // deadline
157
167
)
158
168
std.TestSkipHeights(1)
159
169
@@ -167,16 +177,16 @@ func TestPositionMintBazFoo(t *testing.T) {
167
177
std.TestSetOrigCaller(lp01)
168
178
169
179
tokenId, liquidity, amount0, amount1 := pos.Mint(
170
- bazPath, // token0
171
- fooPath, // token1
172
- uint16(100), // fee
173
- int32(15096), // tickLower
174
- int32(17096), // tickUpper
175
- bigint(1000), // amount0Desired
176
- bigint(999999 ), // amount1Desired
177
- 0, // amount0Min
178
- 0, // amount1Min
179
- MAX_TIMEOUT, // deadline
180
+ bazPath, // token0
181
+ fooPath, // token1
182
+ uint16(100), // fee
183
+ int32(15096), // tickLower
184
+ int32(17096), // tickUpper
185
+ bigint(1000000000), // amount0Desired
186
+ bigint(10000000000 ), // amount1Desired
187
+ 0, // amount0Min
188
+ 0, // amount1Min
189
+ MAX_TIMEOUT, // deadline
180
190
)
181
191
std.TestSkipHeights(1)
182
192
@@ -201,8 +211,8 @@ func TestPositionMintGnsGnot(t *testing.T) {
201
211
gnsPath, // token0
202
212
gnotPath, // token1
203
213
uint16(100), // fee
204
- int32(137162), // tickLower
205
- int32(139162), // tickUpper
214
+ int32(-1000), // tickLower
215
+ int32(1000), // tickUpper
206
216
bigint(1000000000), // amount0Desired // gns
207
217
bigint(1000000000), // amount1Desired // 1000000000 ugnot ≈ 1000 GNOT
208
218
0, // amount0Min
@@ -222,16 +232,16 @@ func TestPositionMintGnsQux(t *testing.T) {
222
232
std.TestSetOrigCaller(lp01)
223
233
224
234
tokenId, liquidity, amount0, amount1 := pos.Mint(
225
- gnsPath, // token0
226
- quxPath, // token1
227
- uint16(100), // fee
228
- int32(22028), // tickLower
229
- int32(24028), // tickUpper
230
- bigint(1000), // amount0Desired
231
- bigint(999999 ), // amount1Desired
232
- 0, // amount0Min
233
- 0, // amount1Min
234
- MAX_TIMEOUT, // deadline
235
+ gnsPath, // token0
236
+ quxPath, // token1
237
+ uint16(100), // fee
238
+ int32(22028), // tickLower
239
+ int32(24028), // tickUpper
240
+ bigint(1000000000), // amount0Desired
241
+ bigint(1000000000000 ), // amount1Desired
242
+ 0, // amount0Min
243
+ 0, // amount1Min
244
+ MAX_TIMEOUT, // deadline
235
245
)
236
246
std.TestSkipHeights(1)
237
247
@@ -246,12 +256,12 @@ func TestRouterApiGetRatiosFromBase(t *testing.T) {
246
256
jsonStr := gjson.Parse(rou.ApiGetRatiosFromBase())
247
257
jsonArr := jsonStr.Get("response.data").Array()
248
258
249
- shouldEQ(t, jsonArr[0].String(), "{\"gnot\":79228162514264337593543950336}") // 1
250
- shouldEQ(t, jsonArr[1].String(), "{\"gno.land/r/bar\":158443568011643016923643 }") // 0.0000019998 ≈ 1.9998
251
- shouldEQ(t, jsonArr[2].String(), "{\"gno.land/r/baz\":316861205180147164580763 }") // 0.0000039994 ≈ 3.9994
252
- shouldEQ(t, jsonArr[3].String(), "{\"gno.land/r/foo\":1584276903344921384146016 }") // 0.0000199964 ≈ 19.9964
253
- shouldEQ(t, jsonArr[4].String(), "{\"gno.land/r/gns\":79228267247129223624113 }") // 0.000001 ≈ 1
254
- shouldEQ(t, jsonArr[5].String(), "{\"gno.land/r/qux\":792282497916421281862272 }") // 0.00001 ≈ 10
259
+ shouldEQ(t, jsonArr[0].String(), "{\"gnot\":79228162514264337593543950336}") // 1
260
+ shouldEQ(t, jsonArr[1].String(), "{\"gno.land/r/bar\":158443358563053804904957153915 }") // 1.9998363402
261
+ shouldEQ(t, jsonArr[2].String(), "{\"gno.land/r/baz\":316892472395878780113157316126 }") // 3.9997453221
262
+ shouldEQ(t, jsonArr[3].String(), "{\"gno.land/r/foo\":1584591679873480193510110926297 }") // 20.0003588319
263
+ shouldEQ(t, jsonArr[4].String(), "{\"gno.land/r/gns\":79228162514264337593543950334 }") // 1
264
+ shouldEQ(t, jsonArr[5].String(), "{\"gno.land/r/qux\":792360678733061968201039084134 }") // 10.0009977966
255
265
}
256
266
257
267
/* UTILS */
0 commit comments