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
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
562883a
introducing legacy logic to the new fee and quote endpoint
bh2smith Oct 6, 2021
3cbd8d5
fix up order validation usage based on recent main
bh2smith Oct 6, 2021
da18bd5
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 6, 2021
a8333a0
fix some stuff up
bh2smith Oct 6, 2021
be4ee36
testing calculate_quote
bh2smith Oct 6, 2021
d2c834e
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 6, 2021
e7ab66d
fix the return type of legacy fee endpoint
bh2smith Oct 6, 2021
020e2ea
Merge branch 'impl-quote-endpoint' of github.com:gnosis/gp-v2-service…
bh2smith Oct 6, 2021
a9fce25
final touches on fe and quote endpoint
bh2smith Oct 7, 2021
8085b42
Ccargo fmt
bh2smith Oct 7, 2021
e88a17d
add u32::MAX to validity for {Buy/Sell}Resuest -> OrderQuoteRequest s…
bh2smith Oct 7, 2021
7d77e65
include warp reply converting suggestion
bh2smith Oct 7, 2021
69297bf
fix most suggestions
bh2smith Oct 7, 2021
fbc823c
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 7, 2021
5de8cad
introduce order quoter struct
bh2smith Oct 8, 2021
1063895
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 8, 2021
e943d8f
apply suggestions
bh2smith Oct 12, 2021
254b1a9
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 12, 2021
8002fc1
fix bad merge
bh2smith Oct 12, 2021
e6c6054
make all order quoter fields public
bh2smith Oct 12, 2021
9bcf01f
Update orderbook/src/api/get_fee_and_quote.rs
bh2smith Oct 12, 2021
5832486
Merge branch 'main' into impl-quote-endpoint
bh2smith Oct 13, 2021
010ffbd
make all fields of OrderQuote public
bh2smith Oct 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e/tests/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl OrderbookServices {
true,
solvable_orders_cache.clone(),
Duration::from_secs(600),
order_validator,
order_validator.clone(),
));
let maintenance = ServiceMaintenance {
maintainers: vec![db.clone(), event_updater],
Expand All @@ -236,6 +236,7 @@ impl OrderbookServices {
fee_calculator,
price_estimator.clone(),
API_HOST[7..].parse().expect("Couldn't parse API address"),
order_validator,
pending(),
);

Expand Down
16 changes: 15 additions & 1 deletion orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/OrderQuote"
$ref: "#/components/schemas/OrderQuoteResponse"
400:
description: Error quoting order.
content:
Expand Down Expand Up @@ -886,12 +886,15 @@ components:
buyTokenBalance:
$ref: "#/components/schemas/BuyTokenDestination"
default: "erc20"
from:
$ref: "#/components/schemas/Address"
required:
- sellToken
- buyToken
- validTo
- appData
- partiallyFillable
- from
OrderQuote:
description: |
An order quoted by the back end that can be directly signed and
Expand All @@ -905,3 +908,14 @@ components:
$ref: "#/components/schemas/Address"
required:
- from
OrderQuoteResponse:
type: object
properties:
quote:
$ref: "#/components/schemas/OrderQuote"
expirationDate:
description: |
Expiration date of the offered fee. Order service might not accept
the fee after this expiration date. Encoded as ISO 8601 UTC.
type: string
example: "1985-03-10T18:35:18.814523Z"
23 changes: 16 additions & 7 deletions orderbook/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub mod order_validation;
mod post_quote;

use crate::{
database::trades::TradeRetrieving, fee::EthAwareMinFeeCalculator, orderbook::Orderbook,
api::order_validation::OrderValidator, database::trades::TradeRetrieving,
fee::EthAwareMinFeeCalculator, orderbook::Orderbook,
};
use anyhow::Error as anyhowError;
use serde::de::DeserializeOwned;
Expand All @@ -31,6 +32,7 @@ pub fn handle_all_routes(
orderbook: Arc<Orderbook>,
fee_calculator: Arc<EthAwareMinFeeCalculator>,
price_estimator: Arc<dyn PriceEstimating>,
order_validator: Arc<OrderValidator>,
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
let create_order = create_order::create_order(orderbook.clone());
let get_orders = get_orders::get_orders(orderbook.clone());
Expand All @@ -41,12 +43,19 @@ pub fn handle_all_routes(
let get_trades = get_trades::get_trades(database);
let cancel_order = cancel_order::cancel_order(orderbook.clone());
let get_amount_estimate = get_markets::get_amount_estimate(price_estimator.clone());
let get_fee_and_quote_sell =
get_fee_and_quote::get_fee_and_quote_sell(fee_calculator.clone(), price_estimator.clone());
let get_fee_and_quote_buy =
get_fee_and_quote::get_fee_and_quote_buy(fee_calculator, price_estimator.clone());
let get_fee_and_quote_sell = get_fee_and_quote::get_fee_and_quote_sell(
fee_calculator.clone(),
price_estimator.clone(),
order_validator.clone(),
);
let get_fee_and_quote_buy = get_fee_and_quote::get_fee_and_quote_buy(
fee_calculator.clone(),
price_estimator.clone(),
order_validator.clone(),
);
let get_user_orders = get_user_orders::get_user_orders(orderbook);
let post_quote = post_quote::post_quote();
let post_quote =
post_quote::post_quote(fee_calculator, price_estimator.clone(), order_validator);
let cors = warp::cors()
.allow_any_origin()
.allow_methods(vec!["GET", "POST", "DELETE", "OPTIONS", "PUT", "PATCH"])
Expand Down Expand Up @@ -122,7 +131,7 @@ fn internal_error() -> Json {
}

pub trait WarpReplyConverting {
fn to_warp_reply(&self) -> (Json, StatusCode);
fn to_warp_reply(self) -> (Json, StatusCode);
}

pub fn convert_get_orders_error_to_reply(err: anyhowError) -> WithStatus<Json> {
Expand Down
Loading