@@ -199,40 +199,41 @@ def test_get_xyk_bounds():
199199 scaling = {tkn : 1 for tkn in (amm .asset_list + [amm .unique_id ])}
200200 amm_i = constraints .amm_i
201201
202- A , b , cones , cones_sizes = constraints .get_amm_bounds ("None" , scaling )
203- x = np .zeros (constraints .k )
204- # selling 5 B for 1 A should work
205- b_sell_amt , a_buy_amt = 5 , 1
206- x [amm_i .asset_net [0 ]] = - a_buy_amt
207- x [amm_i .asset_net [1 ]] = b_sell_amt
208- x [amm_i .asset_out [0 ]] = a_buy_amt
209- s = b - A @ x
210- if not check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
211- raise AssertionError ("Cone feasibility check failed for valid XYK bounds" )
212- # selling 1 A for 1 5 should not work
213- a_sell_amt , b_buy_amt = 1 , 5
214- x [amm_i .asset_net [1 ]] = - b_buy_amt
215- x [amm_i .asset_net [0 ]] = a_sell_amt
216- x [amm_i .asset_out [1 ]] = b_buy_amt
217- s = b - A @ x
218- if check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
219- raise AssertionError ("Cone feasibility check should fail" )
220- # selling 1 A for 1 B should work
221- a_sell_amt , b_buy_amt = 1 , 1
222- x [amm_i .asset_net [1 ]] = - b_buy_amt
223- x [amm_i .asset_net [0 ]] = a_sell_amt
224- x [amm_i .asset_out [1 ]] = b_buy_amt
225- s = b - A @ x
226- if not check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
227- raise AssertionError ("Cone feasibility check should succeed" )
228- # selling 1 B for 1 A should not work
229- b_sell_amt , a_buy_amt = 1 , 1
230- x [amm_i .asset_net [0 ]] = - a_buy_amt
231- x [amm_i .asset_net [1 ]] = b_sell_amt
232- x [amm_i .asset_out [0 ]] = a_buy_amt
233- s = b - A @ x
234- if check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
235- raise AssertionError ("Cone feasibility check should fail" )
202+ for approx in ["none" , "linear" ]: # mult = 10 should test full approximation, 0.1 should test linear approximation
203+ A , b , cones , cones_sizes = constraints .get_amm_bounds (approx , scaling )
204+ x = np .zeros (constraints .k )
205+ # selling 5 B for 1 A should work
206+ b_sell_amt , a_buy_amt = 5 , 1
207+ x [amm_i .asset_net [0 ]] = - a_buy_amt
208+ x [amm_i .asset_net [1 ]] = b_sell_amt
209+ x [amm_i .asset_out [0 ]] = a_buy_amt
210+ s = b - A @ x
211+ if not check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
212+ raise AssertionError ("Cone feasibility check failed for valid XYK bounds" )
213+ # selling 1 A for 1 5 should not work
214+ a_sell_amt , b_buy_amt = 1 , 5
215+ x [amm_i .asset_net [1 ]] = - b_buy_amt
216+ x [amm_i .asset_net [0 ]] = a_sell_amt
217+ x [amm_i .asset_out [1 ]] = b_buy_amt
218+ s = b - A @ x
219+ if check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
220+ raise AssertionError ("Cone feasibility check should fail" )
221+ # selling 1 A for 1 B should work
222+ a_sell_amt , b_buy_amt = 1 , 1
223+ x [amm_i .asset_net [1 ]] = - b_buy_amt
224+ x [amm_i .asset_net [0 ]] = a_sell_amt
225+ x [amm_i .asset_out [1 ]] = b_buy_amt
226+ s = b - A @ x
227+ if not check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
228+ raise AssertionError ("Cone feasibility check should succeed" )
229+ # selling 1 B for 1 A should not work
230+ b_sell_amt , a_buy_amt = 1 , 1
231+ x [amm_i .asset_net [0 ]] = - a_buy_amt
232+ x [amm_i .asset_net [1 ]] = b_sell_amt
233+ x [amm_i .asset_out [0 ]] = a_buy_amt
234+ s = b - A @ x
235+ if check_all_cone_feasibility (s , cones , cones_sizes , tol = 0 ):
236+ raise AssertionError ("Cone feasibility check should fail" )
236237
237238
238239def test_xyk_upgrade_approx ():
@@ -273,11 +274,11 @@ def test_stableswap_upgrade_approx():
273274 # current_approx is entirely linear
274275 current_approx = ["linear" , "linear" , "linear" ]
275276 examples = [ # [delta_mults, expected_approx]
276- [[1e-4 , 1e-6 , 1e-6 ], ["full" , "linear" , "linear" ]],
277- [[1e-6 , 1e-4 , 1e-6 ], ["full" , "full" , "linear" ]],
278- [[1e-6 , 1e-6 , 1e-4 ], ["full" , "linear" , "full" ]],
277+ [[1e-4 , 1e-7 , 1e-7 ], ["full" , "linear" , "linear" ]],
278+ [[1e-7 , 1e-4 , 1e-7 ], ["full" , "full" , "linear" ]],
279+ [[1e-7 , 1e-6 , 1e-4 ], ["full" , "linear" , "full" ]],
279280 [[1e-4 , 1e-4 , 1e-4 ], ["full" , "full" , "full" ]],
280- [[1e-6 , 1e-6 , 1e-6 ], ["linear" , "linear" , "linear" ]]
281+ [[1e-7 , 1e-7 , 1e-7 ], ["linear" , "linear" , "linear" ]]
281282 ]
282283 for delta_mults , expected_approx in examples :
283284 deltas = [amm .shares * delta_mults [0 ], amm .liquidity ["A" ] * delta_mults [1 ], amm .liquidity ["B" ] * delta_mults [2 ]]
@@ -289,11 +290,11 @@ def test_stableswap_upgrade_approx():
289290 # current_approx is mixed
290291 current_approx = ["full" , "linear" , "full" ]
291292 examples = [ # [delta_mults, expected_approx]
292- [[1e-4 , 1e-6 , 1e-6 ], ["full" , "linear" , "full" ]],
293- [[1e-6 , 1e-4 , 1e-6 ], ["full" , "full" , "full" ]],
294- [[1e-6 , 1e-6 , 1e-4 ], ["full" , "linear" , "full" ]],
293+ [[1e-4 , 1e-7 , 1e-7 ], ["full" , "linear" , "full" ]],
294+ [[1e-7 , 1e-4 , 1e-7 ], ["full" , "full" , "full" ]],
295+ [[1e-7 , 1e-7 , 1e-4 ], ["full" , "linear" , "full" ]],
295296 [[1e-4 , 1e-4 , 1e-4 ], ["full" , "full" , "full" ]],
296- [[1e-6 , 1e-6 , 1e-6 ], ["full" , "linear" , "full" ]]
297+ [[1e-7 , 1e-7 , 1e-7 ], ["full" , "linear" , "full" ]]
297298 ]
298299 for delta_mults , expected_approx in examples :
299300 deltas = [amm .shares * delta_mults [0 ], amm .liquidity ["A" ] * delta_mults [1 ], amm .liquidity ["B" ] * delta_mults [2 ]]
0 commit comments