Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(earn): prepare transactions for supply when gas fee is covered #5483

Merged
merged 6 commits into from
May 29, 2024

Conversation

jh2oman
Copy link
Contributor

@jh2oman jh2oman commented May 28, 2024

Description

When gas fees are subsidized:

  1. use the simulateTransactions endpoint to estimate gas for the approve transaction.
  2. ignore limitations of not having enough gas when preparing transactions

Test plan

Verified that the transaction goes through when using the syndicate RPC node on mainnet and that the UI works regardless of whether or not the user has enough gas when the feature flag is on.

Related issues

https://linear.app/valora/issue/ACT-1193/new-enter-amount-screen

Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 86.40%. Comparing base (9810375) to head (7821108).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5483   +/-   ##
=======================================
  Coverage   86.40%   86.40%           
=======================================
  Files         761      761           
  Lines       31365    31374    +9     
  Branches     5390     5394    +4     
=======================================
+ Hits        27101    27109    +8     
- Misses       4033     4034    +1     
  Partials      231      231           
Files Coverage Δ
src/statsig/constants.ts 100.00% <ø> (ø)
src/viem/prepareTransactions.ts 99.11% <100.00%> (+<0.01%) ⬆️
src/earn/prepareTransactions.ts 89.02% <90.00%> (-0.31%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9810375...7821108. Read the comment docs.

})
mocked(estimateGas).mockResolvedValue(BigInt(1_000))

// max gas fee is 10 * 10k = 100k units, too high for either fee currency
Copy link
Contributor

Choose a reason for hiding this comment

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

where do the 10 and 10k come from? should this be 100 (maxFeePerGas) * 1k (gas) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was copy pasted from the previous test...I think you're right. I'll fix it in both!

],
})
)
jest.mocked(getFeatureGate).mockReturnValue(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

specify the feature gate here. E.g., jest.mocked(getFeatureGate).mockImplementation(gate => gate === <gate-name>), so this can be cleaned up when removing a gate. Also should this be reset in a beforeEach so it doesn't affect other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already had it reset in the beforeEach, but I'll do the mockImplementation in both

@jh2oman jh2oman enabled auto-merge May 29, 2024 17:32
@jh2oman jh2oman added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@jh2oman jh2oman added this pull request to the merge queue May 29, 2024
Merged via the queue into main with commit 666f310 May 29, 2024
16 checks passed
@jh2oman jh2oman deleted the prepare-cover-fee branch May 29, 2024 19:43
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.

2 participants