Skip to content

Overpay squidrouter transaction value.#652

Merged
gianfra-t merged 11 commits into
stagingfrom
increase-squidrouter-fee-buffer
May 20, 2025
Merged

Overpay squidrouter transaction value.#652
gianfra-t merged 11 commits into
stagingfrom
increase-squidrouter-fee-buffer

Conversation

@gianfra-t
Copy link
Copy Markdown
Contributor

@gianfra-t gianfra-t commented May 19, 2025

Changes:

  • Increases the value amount pre-signed into the squidrouter transaction for resilience against price fluctuations.
  • Wait 180 minutes vs 15 minutes to execute the main Moonbeam cleanup transaction. This will give more Axelar more time to refund the excess fee payed, and avoid the need to execute a backup cleanup.

Closes #653

@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2025

Deploy Preview for pendulum-pay canceled.

Name Link
🔨 Latest commit 7203258
🔍 Latest deploy log https://app.netlify.com/projects/pendulum-pay/deploys/682caead8ae8c3000851e613

@gianfra-t gianfra-t marked this pull request as ready for review May 19, 2025 13:47
@gianfra-t gianfra-t requested a review from a team May 19, 2025 13:52
Copy link
Copy Markdown
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 50% a bit much? How about we do 10 to 20 percent? Also, you need to check if the amount would exceed what is provided by the funding account to the Ephemeral. It could be that this extra margin exceeds the amount of GLMR that will be sent to it.

@gianfra-t
Copy link
Copy Markdown
Contributor Author

That's a good point regarding the the funding account. I added the safe factor multiplication also into that check such that it is taken into account.

But about the amount itself, it may be a bit too much, but 20% may be a little too small to actually have a noticeable effect. It is true we should also increase the funding amount to keep the same level of coverage we have right now. What about 30%?

Copy link
Copy Markdown
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we choose the middle ground and go for 25% as the factor.
I wouldn't further increase the funding amount. I would imagine some check like

const overpaidFee = Math.min((new Big(route.transactionRequest.value)).mul(1 + SQUIDROUTER_FEE_OVERPAY),FUNDING_AMOUNT_GLMR - 1);

or similar, not sure how that constant is called anymore. Math.min or Math.max are not available on Big numbers IIRC so we need to implement something for that. But that's the gist.

Comment thread api/src/api/services/ramp/quote.service.ts Outdated
Comment thread api/src/api/services/transactions/squidrouter/offramp.ts Outdated
@gianfra-t
Copy link
Copy Markdown
Contributor Author

I Reduced it!

About the last part, I didn't understand. You mean capping the overpay fee to the max funding possible, instead of this? But then, for quotes that are right on the limit of what we support, the overpay will essentially be 0, which gets us in the same place as we started.

Copy link
Copy Markdown
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean capping the overpay fee to the max funding possible, instead of this? But then, for quotes that are right on the limit of what we support, the overpay will essentially be 0, which gets us in the same place as we started.

No, it would still be an improvement. Let's make an example.

  • We are always funding the ephemeral with 150 GLMR for Ethereum.
  • The squidrouter transaction for that particular ramp at that time denotes a gas/network fee of 40 GLMR.
  • We scale that 40 GLMR by the overpay percentage and end up with a squidrouter transaction that pays 50 GLMR to the network.

If we are at a time when the network fees are high, we would have the following

  • We are always funding the ephemeral with 150 GLMR for Ethereum.
  • The squidrouter transaction for that particular ramp at that time denotes a gas/network fee of 140 GLMR.
  • We scale that 140 GLMR by the overpay percentage but with a Math.min check so that it doesn't exceed the funding amount. The resulting amount would be 150 GLMR (though we should probably in the Math.min check do 'FUNDING_AMOUNT_GLMR' - 1 to ensure we still have some GLMR to pay for the transaction itself on Moonbeam).

We could also do it the way you want, ie. not hard-code a max funding amount but derive the funding amount from the required squidrouter gas fee + the overpay. But we don't really know how large this can get and we would possibly spend a lot on these transactions.

Comment thread api/src/api/services/ramp/quote.service.ts Outdated
@gianfra-t
Copy link
Copy Markdown
Contributor Author

gianfra-t commented May 20, 2025

Mmm yes I understand with the behavior you were describing, I was saying it doesn't change much but of course that is for the cases where the fee is close to the funding cap. My rationale was that exactly at those moments the fees become more volatile, this is just an assumption of course.

Let's not delve into too much detail since this is already a temporary fix, and we don't quite know the problem enough to derive a perfect solution. I'll change it to the initial suggestion.

@gianfra-t gianfra-t merged commit 384ab81 into staging May 20, 2025
5 checks passed
@ebma ebma deleted the increase-squidrouter-fee-buffer branch May 20, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase the squidrouter GLMR gas fee by margin of 20%

2 participants