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

✨ Adding gas fees in Price #175

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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