@riftresearch/sdk 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.d.ts +15 -1385
- package/dist/index.js +17 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -85,9 +85,7 @@ var Currencies = {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
// src/
|
|
89
|
-
import { treaty } from "@elysiajs/eden";
|
|
90
|
-
|
|
88
|
+
// src/errors.ts
|
|
91
89
|
class SwapRouterApiError extends Error {
|
|
92
90
|
status;
|
|
93
91
|
body;
|
|
@@ -98,9 +96,6 @@ class SwapRouterApiError extends Error {
|
|
|
98
96
|
this.body = body;
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
|
-
function createClient(baseUrl) {
|
|
102
|
-
return treaty(baseUrl);
|
|
103
|
-
}
|
|
104
99
|
// src/router.ts
|
|
105
100
|
import { match, P } from "ts-pattern";
|
|
106
101
|
var CBBTC_ADDRESS2 = "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf";
|
|
@@ -159,6 +154,14 @@ function getSupportedModes(from, to) {
|
|
|
159
154
|
}
|
|
160
155
|
// src/sdk.ts
|
|
161
156
|
import { erc20Abi } from "viem";
|
|
157
|
+
|
|
158
|
+
// src/client.ts
|
|
159
|
+
import { treaty } from "@elysiajs/eden";
|
|
160
|
+
function createClient(baseUrl) {
|
|
161
|
+
return treaty(baseUrl);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/sdk.ts
|
|
162
165
|
var GAS_LIMIT_MULTIPLIER_NUMERATOR = 3n;
|
|
163
166
|
var GAS_LIMIT_MULTIPLIER_DENOMINATOR = 2n;
|
|
164
167
|
|
|
@@ -202,6 +205,12 @@ class RiftSdk {
|
|
|
202
205
|
throw new SwapRouterApiError(message, status, value);
|
|
203
206
|
}
|
|
204
207
|
async getQuote(params) {
|
|
208
|
+
if (!Number.isFinite(params.slippageBps) || !Number.isInteger(params.slippageBps)) {
|
|
209
|
+
throw new Error("slippageBps must be an integer number of basis points");
|
|
210
|
+
}
|
|
211
|
+
if (params.slippageBps < 0 || params.slippageBps > 1e4) {
|
|
212
|
+
throw new Error("slippageBps must be between 0 and 10000");
|
|
213
|
+
}
|
|
205
214
|
const route = detectRoute(params.from, params.to);
|
|
206
215
|
const isMonochain = route.type === "dex_monochain";
|
|
207
216
|
const quoteRequest = {
|
|
@@ -209,6 +218,7 @@ class RiftSdk {
|
|
|
209
218
|
from: params.from,
|
|
210
219
|
to: params.to,
|
|
211
220
|
amount: params.amount,
|
|
221
|
+
slippageBps: params.slippageBps,
|
|
212
222
|
quoteQuality: params.quoteQuality
|
|
213
223
|
};
|
|
214
224
|
const riftQuote = this.unwrapEdenResult(await this.riftClient.quote.post(quoteRequest));
|
|
@@ -234,7 +244,7 @@ class RiftSdk {
|
|
|
234
244
|
this.logDebug("resolved refund address", { refundAddress });
|
|
235
245
|
if (this.preflightCheckBalances) {
|
|
236
246
|
this.logDebug("running preflight balance check");
|
|
237
|
-
await this.assertSufficientBalance(params.from, quote.from.
|
|
247
|
+
await this.assertSufficientBalance(params.from, quote.from.expected, context);
|
|
238
248
|
}
|
|
239
249
|
this.logDebug("creating swap", { quoteId: riftQuote.id });
|
|
240
250
|
const swapResponse = this.unwrapEdenResult(await this.riftClient.swap.post({
|
|
@@ -477,7 +487,6 @@ export {
|
|
|
477
487
|
detectRoute,
|
|
478
488
|
createRiftSdk,
|
|
479
489
|
createCurrency,
|
|
480
|
-
createClient,
|
|
481
490
|
SwapRouterApiError,
|
|
482
491
|
RiftSdk,
|
|
483
492
|
Currencies
|