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

Change quote request construction for fee and quote #234

Merged
merged 2 commits into from
May 31, 2022
Merged

Conversation

nlordell
Copy link
Contributor

@nlordell nlordell commented May 30, 2022

We recently added a regression to the "legacy" api/v1/feeAndQuote API endpoint.

Under the hood, this request uses the same logic as for api/v1/quote which recently introduced a cap on the valid_to field. This broke the aforementioned fee and quote route which was internally converting the request into a quote with valid_to set to u32::MAX.

This PR fixes this by changing the order quote construction to use a "sane" valid_to value: the default validity that is used in the CowSwap UI - which should be super unlikely to ever become "invalid" and break the legacy API.

Test Plan

api/v1/feeAndQuote should start working again!

% curl -s 'http://localhost:8080/api/v1/feeAndQuote/sell?sellToken=0xc778417E063141139Fce010982780140Aa0cD5Ab&buyToken=0xa7D1C04fAF998F9161fC9F800a99A809b84cfc9D&sellAmountBeforeFee=100000000000000000' | jq
{
  "fee": {
    "amount": "220417002424587",
    "expirationDate": "2022-05-30T15:16:45.916306Z"
  },
  "buyAmountAfterFee": "110754541550422939367"
}

@nlordell nlordell requested a review from a team as a code owner May 30, 2022 15:13
@codecov-commenter
Copy link

codecov-commenter commented May 30, 2022

Codecov Report

Merging #234 (156ea99) into main (5e2f927) will increase coverage by 0.01%.
The diff coverage is 95.12%.

❗ Current head 156ea99 differs from pull request most recent head 829c2de. Consider uploading reports for the commit 829c2de to get more accurate results

@@            Coverage Diff             @@
##             main     #234      +/-   ##
==========================================
+ Coverage   64.48%   64.49%   +0.01%     
==========================================
  Files         189      190       +1     
  Lines       39054    39061       +7     
==========================================
+ Hits        25183    25192       +9     
+ Misses      13871    13869       -2     

@nlordell nlordell enabled auto-merge (squash) May 31, 2022 12:26
@nlordell nlordell merged commit 519f957 into main May 31, 2022
@nlordell nlordell deleted the fee-and-x-route branch May 31, 2022 12:29
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants