Skip to content

Commit

Permalink
✨ Adding gas fees in Price (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-bellotti authored Dec 6, 2023
1 parent bb2985b commit 3279add
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
2 changes: 2 additions & 0 deletions src/services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' };
Expand All @@ -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' };
Expand Down
7 changes: 6 additions & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ const fetchPrices = (request: PriceRequest, options?: AvnuOptions): Promise<Pric
})
.then((response) => parseResponse<Price[]>(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),
})),
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface Price {
chainId: string;
sourceName: string;
priceRatioUsd: number;
gasFees: bigint;
gasFeesInUsd: number;
}

export interface Quote {
Expand Down

0 comments on commit 3279add

Please sign in to comment.