Skip to content

Commit

Permalink
Merge pull request #334 from bob-collective/feat/quote-refill-fee
Browse files Browse the repository at this point in the history
feat: add refill to quote fee
  • Loading branch information
gregdhill authored Sep 3, 2024
2 parents 554db93 + ff94f5a commit 5de1c6a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobob/bob-sdk",
"version": "2.2.2",
"version": "2.2.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/gateway/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export class GatewayApiClient {
},
});

return await response.json();
const quote: GatewayQuote = await response.json();
return {
...quote,
fee: Math.max(0, quote.fee - (params.gasRefill || 0)),
};
}

// TODO: add error handling
Expand Down
16 changes: 15 additions & 1 deletion sdk/test/gateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Gateway Tests", () => {

nock(`${MAINNET_GATEWAY_BASE_URL}`)
.get(`/quote/${SYMBOL_LOOKUP[ChainId.BOB]["tbtc"].address}?satoshis=1000`)
.times(4)
.times(6)
.reply(200, mockQuote);

assert.deepEqual(await gatewaySDK.getQuote({
Expand All @@ -61,6 +61,20 @@ describe("Gateway Tests", () => {
toUserAddress: ZeroAddress,
amount: 1000,
}), mockQuote);
assert.deepEqual(await gatewaySDK.getQuote({
toChain: "BOB",
toToken: "tBTC",
toUserAddress: ZeroAddress,
amount: 1000,
gasRefill: 5,
}), { ...mockQuote, fee: 5 });
assert.deepEqual(await gatewaySDK.getQuote({
toChain: "BOB",
toToken: "tBTC",
toUserAddress: ZeroAddress,
amount: 1000,
gasRefill: 1000,
}), { ...mockQuote, fee: 0 });

// get the total available without amount
nock(`${MAINNET_GATEWAY_BASE_URL}`)
Expand Down

0 comments on commit 5de1c6a

Please sign in to comment.