@moveindustries/near-intents-sdk 0.0.1 → 0.0.2

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 CHANGED
@@ -25,6 +25,7 @@ const res = await quoteDeposit({
25
25
  amount: "1000000", // 1.0 USDC, in the origin asset's smallest units
26
26
  recipient: "0xYourMovementAddress",
27
27
  refundTo: "0xYourEthereumAddress",
28
+ minAmountOut: "995000", // required floor in the destination asset's smallest units; throws if the quote's guaranteed output is lower. Pass "0" to opt out.
28
29
  // slippageTolerance: 100, // basis points, defaults to 100 (1%); raise it for `destinationAsset: "move"`
29
30
  });
30
31
  const { depositAddress, amountOut, deadline } = res.quote;
package/dist/quote.d.ts CHANGED
@@ -8,6 +8,7 @@ export type QuoteDepositParams = {
8
8
  recipient: string;
9
9
  refundTo: string;
10
10
  slippageTolerance?: number;
11
+ minAmountOut: string;
11
12
  deadline?: string;
12
13
  dry?: boolean;
13
14
  };
package/dist/quote.js CHANGED
@@ -15,7 +15,10 @@ export async function quoteDeposit(p) {
15
15
  const deadline = p.deadline ?? new Date(Date.now() + 600_000).toISOString();
16
16
  if (Date.parse(deadline) <= Date.now())
17
17
  throw new Error(`deadline is in the past: ${deadline}`);
18
- return OneClickService.getQuote({
18
+ if (!/^[0-9]+$/.test(p.minAmountOut)) {
19
+ throw new Error(`minAmountOut must be a non-negative integer string ("0" opts out of the floor): ${p.minAmountOut}`);
20
+ }
21
+ const res = await OneClickService.getQuote({
19
22
  dry: p.dry ?? false,
20
23
  swapType: QuoteRequest.swapType.EXACT_INPUT,
21
24
  slippageTolerance: p.slippageTolerance ?? 100,
@@ -29,4 +32,12 @@ export async function quoteDeposit(p) {
29
32
  refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
30
33
  deadline,
31
34
  });
35
+ // Guard against a poorly-priced quote: compare the caller's floor against the quote's
36
+ // guaranteed output (minAmountOut after slippage), not the expected amountOut, so the check
37
+ // holds even in the worst-case execution the quote permits. A floor of 0 opts out.
38
+ const floor = BigInt(p.minAmountOut);
39
+ if (floor > 0n && BigInt(res.quote.minAmountOut) < floor) {
40
+ throw new Error(`quote below floor: guaranteed minAmountOut ${res.quote.minAmountOut} < minAmountOut ${p.minAmountOut}`);
41
+ }
42
+ return res;
32
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moveindustries/near-intents-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Thin SDK: USDT/USDC -> Movement USDCx/MOVE over NEAR Intents 1Click.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",