@riftresearch/sdk 0.6.0 → 0.7.0
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 +1118 -54
- package/dist/index.js +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -202,6 +202,12 @@ class RiftSdk {
|
|
|
202
202
|
throw new SwapRouterApiError(message, status, value);
|
|
203
203
|
}
|
|
204
204
|
async getQuote(params) {
|
|
205
|
+
if (!Number.isFinite(params.slippageBps) || !Number.isInteger(params.slippageBps)) {
|
|
206
|
+
throw new Error("slippageBps must be an integer number of basis points");
|
|
207
|
+
}
|
|
208
|
+
if (params.slippageBps < 0 || params.slippageBps > 1e4) {
|
|
209
|
+
throw new Error("slippageBps must be between 0 and 10000");
|
|
210
|
+
}
|
|
205
211
|
const route = detectRoute(params.from, params.to);
|
|
206
212
|
const isMonochain = route.type === "dex_monochain";
|
|
207
213
|
const quoteRequest = {
|
|
@@ -209,6 +215,7 @@ class RiftSdk {
|
|
|
209
215
|
from: params.from,
|
|
210
216
|
to: params.to,
|
|
211
217
|
amount: params.amount,
|
|
218
|
+
slippageBps: params.slippageBps,
|
|
212
219
|
quoteQuality: params.quoteQuality
|
|
213
220
|
};
|
|
214
221
|
const riftQuote = this.unwrapEdenResult(await this.riftClient.quote.post(quoteRequest));
|
|
@@ -234,7 +241,7 @@ class RiftSdk {
|
|
|
234
241
|
this.logDebug("resolved refund address", { refundAddress });
|
|
235
242
|
if (this.preflightCheckBalances) {
|
|
236
243
|
this.logDebug("running preflight balance check");
|
|
237
|
-
await this.assertSufficientBalance(params.from, quote.from.
|
|
244
|
+
await this.assertSufficientBalance(params.from, quote.from.expected, context);
|
|
238
245
|
}
|
|
239
246
|
this.logDebug("creating swap", { quoteId: riftQuote.id });
|
|
240
247
|
const swapResponse = this.unwrapEdenResult(await this.riftClient.swap.post({
|