From 3279addc1b46c7aad730a929f478ca63dbccb02c Mon Sep 17 00:00:00 2001 From: Florian Bellotti Date: Wed, 6 Dec 2023 14:26:20 +0100 Subject: [PATCH] :sparkles: Adding gas fees in Price (#175) --- src/fixtures.ts | 2 ++ src/services.spec.ts | 2 ++ src/services.ts | 7 ++++++- src/types.ts | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fixtures.ts b/src/fixtures.ts index 560c098..40d2aae 100644 --- a/src/fixtures.ts +++ b/src/fixtures.ts @@ -39,6 +39,8 @@ export const aPrice = (): Price => ({ chainId: constants.StarknetChainId.SN_GOERLI, sourceName: 'AMM1', priceRatioUsd: 0, + gasFees: BigInt(0), + gasFeesInUsd: 0, }); export const aQuote = (): Quote => ({ diff --git a/src/services.spec.ts b/src/services.spec.ts index ffc1c99..1453afd 100644 --- a/src/services.spec.ts +++ b/src/services.spec.ts @@ -42,6 +42,7 @@ describe('Avnu services', () => { ...aPrice(), sellAmount: toBeHex(parseUnits('1', 18)), buyAmount: toBeHex(parseUnits('2', 18)), + gasFees: '0x0', }, ]; const queryParams = { ...aPriceRequest(), sellAmount: '0x0de0b6b3a7640000' }; @@ -64,6 +65,7 @@ describe('Avnu services', () => { ...aPrice(), sellAmount: toBeHex(parseUnits('1', 18)), buyAmount: toBeHex(parseUnits('2', 18)), + gasFees: '0x0', }, ]; const queryParams = { ...aPriceRequest(), sellAmount: '0x0de0b6b3a7640000' }; diff --git a/src/services.ts b/src/services.ts index 557b7e7..ba92342 100644 --- a/src/services.ts +++ b/src/services.ts @@ -63,7 +63,12 @@ const fetchPrices = (request: PriceRequest, options?: AvnuOptions): Promise parseResponse(response, options?.avnuPublicKey)) .then((prices) => - prices.map((price) => ({ ...price, sellAmount: BigInt(price.sellAmount), buyAmount: BigInt(price.buyAmount) })), + prices.map((price) => ({ + ...price, + sellAmount: BigInt(price.sellAmount), + buyAmount: BigInt(price.buyAmount), + gasFees: BigInt(price.gasFees), + })), ); }; diff --git a/src/types.ts b/src/types.ts index 375c9a4..459cf9f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -74,6 +74,8 @@ export interface Price { chainId: string; sourceName: string; priceRatioUsd: number; + gasFees: bigint; + gasFeesInUsd: number; } export interface Quote {