Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Fee&OrderQuote Endpoint: Implemention with legacy logic. #1155

Merged
merged 23 commits into from
Oct 13, 2021

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Sep 24, 2021

Depends on #1169

based on the specification defined in #1143, we implement the fee calculating logic of the existing route along with the building of an Order Quote that is returned by this endpoint.

  • Note that this also involved a refactor of the legacy fee endpoint to make us of the new one. For this we move the generic response method into the new file making it generically operate on all of OrderQuoteResponse, BuyResponse and SellResponse. We had to open up a few fields in the OrderQuote to be public so that we could convert OrderQuoteResponse into the legacy Buy/SellResponse types. Furthermore, now, the legacy fee endpoint requires and order_validator and makes use of partial order validation on the Partial Order constructed from a legacy buy/sell request. Hopefully this minimal data doesn't lead to an order validation Error (or else we may have to introduce a validation override flag of some sort).

Test Plan

  • Run the api locally and make a request that returns an OrderQuoteResponse

With this api request

curl -X 'POST' \
  'http://localhost:8080/api/v1/quote' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "sellToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  "buyToken": "0x6810e776880c02933d47db1b9fc05908e5386b96",
  "receiver": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
  "validTo": 1632933600,
  "appData": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "partiallyFillable": false,
  "sellTokenBalance": "erc20",
  "buyTokenBalance": "erc20",
  "from": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
  "kind": "sell",
  "sellAmountBeforeFee": "99999999999999999999"
}'

We get back the following response

{
  "from": "0x9008d19f58aabd9ed0d60971565aa8510560ab41",
  "sellToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  "buyToken": "0x6810e776880c02933d47db1b9fc05908e5386b96",
  "receiver": "0x9008d19f58aabd9ed0d60971565aa8510560ab41",
  "sellAmount": "99999999999999999999",
  "buyAmount": "379816735088461143945",
  "validTo": 1632933600,
  "appData": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "feeAmount": "31686440800600000",
  "kind": "sell",
  "partiallyFillable": false,
  "sellTokenBalance": "erc20",
  "buyTokenBalance": "erc20"
}
  • Run the legacy API as well to ensure it still functions properly.

Base automatically changed from new-quote-endpoint to main September 24, 2021 15:29
@bh2smith bh2smith mentioned this pull request Sep 29, 2021
@bh2smith bh2smith force-pushed the impl-quote-endpoint branch 2 times, most recently from 10043bd to 647b760 Compare September 29, 2021 13:13
@bh2smith bh2smith changed the base branch from main to orderbook-interface September 29, 2021 13:13
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2021

Codecov Report

Merging #1155 (e6c6054) into main (49430ee) will increase coverage by 0.26%.
The diff coverage is 80.36%.

@@            Coverage Diff             @@
##             main    #1155      +/-   ##
==========================================
+ Coverage   67.43%   67.69%   +0.26%     
==========================================
  Files         135      135              
  Lines       27799    28101     +302     
==========================================
+ Hits        18746    19023     +277     
- Misses       9053     9078      +25     

@bh2smith bh2smith marked this pull request as ready for review September 29, 2021 19:34
@bh2smith bh2smith requested a review from a team September 29, 2021 19:34
Base automatically changed from orderbook-interface to main September 30, 2021 08:28
@bh2smith bh2smith force-pushed the impl-quote-endpoint branch from ec12a5a to 562883a Compare October 6, 2021 12:59
@bh2smith bh2smith requested a review from nlordell October 8, 2021 08:16
Copy link
Contributor

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

Like the new OrderQuoter type! Just feel like it should be in post_quote module (as that is where its used and the logic that uses it lives).

Some issues with the OpenAPI spec.

Otherwise looks great to me!

@bh2smith bh2smith requested a review from nlordell October 12, 2021 11:03
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
@bh2smith bh2smith requested a review from nlordell October 12, 2021 12:43
@bh2smith bh2smith added the api label Oct 13, 2021
@bh2smith bh2smith enabled auto-merge (squash) October 13, 2021 08:53
@bh2smith bh2smith merged commit 7c82182 into main Oct 13, 2021
@bh2smith bh2smith deleted the impl-quote-endpoint branch October 13, 2021 08:58
@bh2smith bh2smith mentioned this pull request Oct 13, 2021
@bh2smith bh2smith changed the title Fee&Quote Endpoint: Implemention with legacy logic. Fee&OrderQuote Endpoint: Implemention with legacy logic. Jan 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants