Skip to content

Commit

Permalink
examples/quote/fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Velenir committed Dec 5, 2024
1 parent c047ad2 commit 484149e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/examples/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
constructSwapSDK,
OptimalRate,
DeltaPrice,
isFetcherError,
} from '..';

const fetcher = constructAxiosFetcher(axios);
Expand Down Expand Up @@ -55,11 +56,14 @@ async function deltaQuote() {
// partner: "..." // if available
});

if ('delta' in quote) {
try {
const deltaPrice = quote.delta;
await handleDeltaQuote({ amount, deltaPrice });
} else {
console.log(`Delta Quote failed: ${quote.errorType} - ${quote.details}`);
} catch (error) {
if (isFetcherError(error)) {
const data = error.response?.data;
console.log(`Delta Quote failed: ${data.errorType} - ${data.details}`);
}
}
}

Expand Down

0 comments on commit 484149e

Please sign in to comment.