Skip to content

Commit fba5204

Browse files
authored
chore: reduce Axelar estimate padding to 10% rather than 300% (#12118)
## Description Axelar estimation includes a padding based on the fee volatility of the target chain. ### Security Considerations If the estimate is too high because, for example, the price is falling rapidly, then - the operation will succeed - when refunds are supported we will get a refund If the estimate is too low because, for example, the gas price is increasing more than the padding within a 20 minutes period - the operation will suspend - it can be manually funded to proceed - the planner can be updated so that future requests in a particularly volatile period use more padding ### Scaling Considerations Need reduced fee to reduce operating costs to required levels. ### Documentation Considerations None ### Testing Considerations Test check for the value. 10% was determined by looking at one case of estimated vs. actual and determining that the typical variability is extremely small (0.001%) ### Upgrade Considerations This is a data value in plan generation only.
2 parents 53f6813 + cde102e commit fba5204

File tree

6 files changed

+45
-44
lines changed

6 files changed

+45
-44
lines changed

packages/portfolio-contract/test/rebalance.test.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const { brand: TOK_BRAND } = (() => ({ brand: Far('USD*') as Brand<'nat'> }))();
3535
const { brand: FEE_BRAND } = (() => ({ brand: Far('BLD') as Brand<'nat'> }))();
3636
const token = (v: bigint) => AmountMath.make(TOK_BRAND, v * USCALE);
3737
const ZERO = token(0n);
38-
const fixedFee = AmountMath.make(FEE_BRAND, 30n * USCALE);
38+
const fixedFee = AmountMath.make(FEE_BRAND, 11n * USCALE);
39+
const evmGas = 220000000n * USCALE;
3940
const subtract5bps = (scaled: bigint) =>
4041
// HACK subtract an extra 1n to match `rebalanceMinCostFlowSteps`.
4142
// See https://github.com/Agoric/agoric-private/issues/415
@@ -128,7 +129,7 @@ testWithAllModes('solver simple 2-pool case (A -> B 30)', async (t, mode) => {
128129
amount: token(30n),
129130
fee: fixedFee,
130131
detail: {
131-
evmGas: 600000000000000n,
132+
evmGas,
132133
},
133134
},
134135
// hub -> leaf
@@ -165,7 +166,7 @@ testWithAllModes(
165166
amount: amt33,
166167
fee: fixedFee,
167168
detail: {
168-
evmGas: 600000000000000n,
169+
evmGas,
169170
},
170171
},
171172
{
@@ -174,7 +175,7 @@ testWithAllModes(
174175
amount: amt33,
175176
fee: fixedFee,
176177
detail: {
177-
evmGas: 600000000000000n,
178+
evmGas,
178179
},
179180
},
180181
// hub -> leaf
@@ -222,7 +223,7 @@ testWithAllModes('solver all to one (B + C -> A)', async (t, mode) => {
222223
amount: token(90n),
223224
fee: fixedFee,
224225
detail: {
225-
evmGas: 600000000000000n,
226+
evmGas,
226227
},
227228
},
228229
{ src: '@Arbitrum', dest: A, amount: token(90n), fee: fixedFee },
@@ -253,7 +254,7 @@ testWithAllModes(
253254
amount: token(60n),
254255
fee: fixedFee,
255256
detail: {
256-
evmGas: 600000000000000n,
257+
evmGas,
257258
},
258259
},
259260
{
@@ -262,7 +263,7 @@ testWithAllModes(
262263
amount: token(40n),
263264
fee: fixedFee,
264265
detail: {
265-
evmGas: 600000000000000n,
266+
evmGas,
266267
},
267268
},
268269
{ src: '@Avalanche', dest: B, amount: token(60n), fee: fixedFee },
@@ -296,7 +297,7 @@ testWithAllModes(
296297
amount: token(100n),
297298
fee: fixedFee,
298299
detail: {
299-
evmGas: 600000000000000n,
300+
evmGas,
300301
},
301302
},
302303
{ src: '@Arbitrum', dest: A, amount: token(100n), fee: fixedFee },
@@ -326,7 +327,7 @@ testWithAllModes(
326327
amount: token(70n),
327328
fee: fixedFee,
328329
detail: {
329-
evmGas: 600000000000000n,
330+
evmGas,
330331
},
331332
},
332333
{
@@ -335,7 +336,7 @@ testWithAllModes(
335336
amount: token(30n),
336337
fee: fixedFee,
337338
detail: {
338-
evmGas: 600000000000000n,
339+
evmGas,
339340
},
340341
},
341342
{ src: '@Arbitrum', dest: A, amount: token(70n), fee: fixedFee },
@@ -366,7 +367,7 @@ testWithAllModes(
366367
amount: token(70n),
367368
fee: fixedFee,
368369
detail: {
369-
evmGas: 600000000000000n,
370+
evmGas,
370371
},
371372
},
372373
{
@@ -375,7 +376,7 @@ testWithAllModes(
375376
amount: token(30n),
376377
fee: fixedFee,
377378
detail: {
378-
evmGas: 600000000000000n,
379+
evmGas,
379380
},
380381
},
381382
{ src: '@Arbitrum', dest: A, amount: token(70n), fee: fixedFee },
@@ -443,7 +444,7 @@ testWithAllModes(
443444
amount: token(20n),
444445
fee: fixedFee,
445446
detail: {
446-
evmGas: 600000000000000n,
447+
evmGas,
447448
},
448449
},
449450
{ src: '@Ethereum', dest: C, amount: token(20n), fee: fixedFee },
@@ -492,7 +493,7 @@ testWithAllModes(
492493
amount: token(300n),
493494
fee: fixedFee,
494495
detail: {
495-
evmGas: 600000000000000n,
496+
evmGas,
496497
},
497498
},
498499
{
@@ -501,7 +502,7 @@ testWithAllModes(
501502
amount: token(200n),
502503
fee: fixedFee,
503504
detail: {
504-
evmGas: 600000000000000n,
505+
evmGas,
505506
},
506507
},
507508
{ src: '@Arbitrum', dest: A, amount: token(300n), fee: fixedFee },
@@ -553,7 +554,7 @@ testWithAllModes(
553554
amount: token(220n),
554555
fee: fixedFee,
555556
detail: {
556-
evmGas: 600000000000000n,
557+
evmGas,
557558
},
558559
},
559560
{
@@ -562,7 +563,7 @@ testWithAllModes(
562563
amount: token(160n),
563564
fee: fixedFee,
564565
detail: {
565-
evmGas: 600000000000000n,
566+
evmGas,
566567
},
567568
},
568569
{ src: '@Arbitrum', dest: A, amount: token(220n), fee: fixedFee },
@@ -626,7 +627,7 @@ testWithAllModes(
626627
amount: token(30n),
627628
fee: fixedFee,
628629
detail: {
629-
evmGas: 600000000000000n,
630+
evmGas,
630631
},
631632
},
632633
{ src: '@Avalanche', dest: B, amount: token(30n), fee: fixedFee },

packages/portfolio-contract/test/snapshots/portfolio.flows.test.ts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ Generated by [AVA](https://avajs.dev).
402402
value: 150n,
403403
},
404404
opts: {
405-
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,33,178,98,221,128,0],"type":1,"fee":{"amount":"150","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
405+
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,22,189,217,192,0],"type":1,"fee":{"amount":"150","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
406406
},
407407
},
408408
{
@@ -945,7 +945,7 @@ Generated by [AVA](https://avajs.dev).
945945
value: 300n,
946946
},
947947
opts: {
948-
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,33,178,98,221,128,0],"type":1,"fee":{"amount":"300","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
948+
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,22,189,217,192,0],"type":1,"fee":{"amount":"300","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
949949
},
950950
},
951951
{
@@ -1887,7 +1887,7 @@ Generated by [AVA](https://avajs.dev).
18871887
value: 150n,
18881888
},
18891889
opts: {
1890-
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,33,178,98,221,128,0],"type":1,"fee":{"amount":"150","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
1890+
memo: '{"destination_chain":"arbitrum","destination_address":"0xef8651dD30cF990A1e831224f2E0996023163A81","payload":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,22,189,217,192,0],"type":1,"fee":{"amount":"150","recipient":"axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"}}',
18911891
},
18921892
},
18931893
{
Binary file not shown.

packages/portfolio-contract/tools/plan-solve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ export const rebalanceMinCostFlowSteps = async (
416416
}
417417
/**
418418
* Pad each fee estimate in case the landscape changes between estimation and
419-
* execution.
419+
* execution. Add 10%
420420
*/
421-
const padFeeEstimate = (estimate: bigint): bigint => estimate * 3n;
421+
const padFeeEstimate = (estimate: bigint): bigint => (estimate * 110n) / 100n;
422422

423423
const steps: MovementDesc[] = await Promise.all(
424424
prioritized.map(async ({ edge, flow }) => {

services/ymax-planner/test/snapshots/deposit-tools.test.ts.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Generated by [AVA](https://avajs.dev).
4646
},
4747
dest: '@Arbitrum',
4848
detail: {
49-
evmGas: 3n,
49+
evmGas: 1n,
5050
},
5151
fee: {
5252
brand: Object @Alleged: fee brand (BLD) {},
53-
value: 3628305n,
53+
value: 1330378n,
5454
},
5555
src: '@noble',
5656
},
@@ -62,7 +62,7 @@ Generated by [AVA](https://avajs.dev).
6262
dest: 'Aave_Arbitrum',
6363
fee: {
6464
brand: Object @Alleged: fee brand (BLD) {},
65-
value: 838419n,
65+
value: 307420n,
6666
},
6767
src: '@Arbitrum',
6868
},
@@ -74,7 +74,7 @@ Generated by [AVA](https://avajs.dev).
7474
dest: 'Compound_Arbitrum',
7575
fee: {
7676
brand: Object @Alleged: fee brand (BLD) {},
77-
value: 455076n,
77+
value: 166861n,
7878
},
7979
src: '@Arbitrum',
8080
},
@@ -131,11 +131,11 @@ Generated by [AVA](https://avajs.dev).
131131
},
132132
dest: '@Avalanche',
133133
detail: {
134-
evmGas: 3n,
134+
evmGas: 1n,
135135
},
136136
fee: {
137137
brand: Object @Alleged: fee brand (BLD) {},
138-
value: 3628305n,
138+
value: 1330378n,
139139
},
140140
src: '@noble',
141141
},
@@ -146,11 +146,11 @@ Generated by [AVA](https://avajs.dev).
146146
},
147147
dest: '@Ethereum',
148148
detail: {
149-
evmGas: 3n,
149+
evmGas: 1n,
150150
},
151151
fee: {
152152
brand: Object @Alleged: fee brand (BLD) {},
153-
value: 3628305n,
153+
value: 1330378n,
154154
},
155155
src: '@noble',
156156
},
@@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev).
162162
dest: 'Compound_Ethereum',
163163
fee: {
164164
brand: Object @Alleged: fee brand (BLD) {},
165-
value: 455076n,
165+
value: 166861n,
166166
},
167167
src: '@Ethereum',
168168
},
@@ -174,7 +174,7 @@ Generated by [AVA](https://avajs.dev).
174174
dest: 'Aave_Avalanche',
175175
fee: {
176176
brand: Object @Alleged: fee brand (BLD) {},
177-
value: 838419n,
177+
value: 307420n,
178178
},
179179
src: '@Avalanche',
180180
},
@@ -200,11 +200,11 @@ Generated by [AVA](https://avajs.dev).
200200
},
201201
dest: '@Arbitrum',
202202
detail: {
203-
evmGas: 3n,
203+
evmGas: 1n,
204204
},
205205
fee: {
206206
brand: Object @Alleged: fee brand (BLD) {},
207-
value: 3628305n,
207+
value: 1330378n,
208208
},
209209
src: '@noble',
210210
},
@@ -216,7 +216,7 @@ Generated by [AVA](https://avajs.dev).
216216
dest: 'Aave_Arbitrum',
217217
fee: {
218218
brand: Object @Alleged: fee brand (BLD) {},
219-
value: 838419n,
219+
value: 307420n,
220220
},
221221
src: '@Arbitrum',
222222
},
@@ -228,7 +228,7 @@ Generated by [AVA](https://avajs.dev).
228228
dest: 'Compound_Arbitrum',
229229
fee: {
230230
brand: Object @Alleged: fee brand (BLD) {},
231-
value: 455076n,
231+
value: 166861n,
232232
},
233233
src: '@Arbitrum',
234234
},
@@ -254,11 +254,11 @@ Generated by [AVA](https://avajs.dev).
254254
},
255255
dest: '@Arbitrum',
256256
detail: {
257-
evmGas: 3n,
257+
evmGas: 1n,
258258
},
259259
fee: {
260260
brand: Object @Alleged: fee brand (BLD) {},
261-
value: 3628305n,
261+
value: 1330378n,
262262
},
263263
src: '@noble',
264264
},
@@ -278,7 +278,7 @@ Generated by [AVA](https://avajs.dev).
278278
dest: 'Aave_Arbitrum',
279279
fee: {
280280
brand: Object @Alleged: fee brand (BLD) {},
281-
value: 838419n,
281+
value: 307420n,
282282
},
283283
src: '@Arbitrum',
284284
},
@@ -290,7 +290,7 @@ Generated by [AVA](https://avajs.dev).
290290
dest: 'Compound_Arbitrum',
291291
fee: {
292292
brand: Object @Alleged: fee brand (BLD) {},
293-
value: 455076n,
293+
value: 166861n,
294294
},
295295
src: '@Arbitrum',
296296
},
@@ -317,7 +317,7 @@ Generated by [AVA](https://avajs.dev).
317317
dest: '@Arbitrum',
318318
fee: {
319319
brand: Object @Alleged: fee brand (BLD) {},
320-
value: 702981n,
320+
value: 257759n,
321321
},
322322
src: 'Aave_Arbitrum',
323323
},
@@ -329,7 +329,7 @@ Generated by [AVA](https://avajs.dev).
329329
dest: '@Arbitrum',
330330
fee: {
331331
brand: Object @Alleged: fee brand (BLD) {},
332-
value: 369243n,
332+
value: 135389n,
333333
},
334334
src: 'Compound_Arbitrum',
335335
},
@@ -341,7 +341,7 @@ Generated by [AVA](https://avajs.dev).
341341
dest: '@agoric',
342342
fee: {
343343
brand: Object @Alleged: fee brand (BLD) {},
344-
value: 453960n,
344+
value: 166452n,
345345
},
346346
src: '@Arbitrum',
347347
},
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)