@moveindustries/near-intents-sdk 0.0.1 → 0.0.3

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
@@ -19,12 +19,13 @@ configure({ jwt: process.env.ONE_CLICK_JWT }); // jwt optional; omit configure()
19
19
 
20
20
  // 1. Quote: USDC on Ethereum -> USDCx on Movement. Destination is pinned to Movement.
21
21
  const res = await quoteDeposit({
22
- originChain: "ethereum", // "ethereum" | "polygon" | "tron"
22
+ originChain: "ethereum", // "ethereum" | "polygon" | "tron" | "near"
23
23
  originAsset: "usdc", // "usdc" | "usdt" (tron is usdt-only)
24
24
  destinationAsset: "usdcx", // "usdcx" | "move"
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;
@@ -32,9 +33,11 @@ const { depositAddress, amountOut, deadline } = res.quote;
32
33
  // 2. (Optional) Build the unsigned deposit transfer; your wallet signs + broadcasts it.
33
34
  const depositTx = prepareDepositTx("ethereum", "usdc", res);
34
35
  // EVM: { family: "evm", to, value, data } Tron: { family: "tron", contractAddress, function, parameter }
36
+ // NEAR: { family: "near", receiverId, methodName: "ft_transfer", args, gas, deposit }
35
37
 
36
38
  // 3. (Optional) After broadcasting, hand 1Click the tx hash to speed up deposit detection.
37
39
  await submitDeposit(depositAddress!, "0xYourDepositTxHash");
40
+ // For a NEAR origin, also pass the signing account: submitDeposit(depositAddress!, txHash, { nearSenderAccount: "you.near" })
38
41
 
39
42
  // 4. Read execution status. Poll on your own cadence until isTerminal(status).
40
43
  const { status } = await getStatus(depositAddress!);
@@ -45,7 +48,7 @@ The SDK never signs, broadcasts, or holds keys — step 2 returns an *unsigned*
45
48
 
46
49
  ## Supported routes
47
50
 
48
- Backed by Movement's own solver: origins **Polygon, Ethereum, Tron** (USDC + USDT; Tron is USDT-only) → **USDCx** or **MOVE** on Movement.
51
+ Backed by Movement's own solver: origins **Polygon, Ethereum, Tron, NEAR** (USDC + USDT; Tron is USDT-only) → **USDCx** or **MOVE** on Movement.
49
52
 
50
53
  ## Install
51
54
 
package/dist/deposit.d.ts CHANGED
@@ -12,6 +12,18 @@ export type TronDepositTx = {
12
12
  function: "transfer(address,uint256)";
13
13
  parameter: [string, string];
14
14
  };
15
- export type DepositTx = EvmDepositTx | TronDepositTx;
15
+ /** Unsigned NEP-141 `ft_transfer` call. `deposit` is the mandatory 1-yoctoNEAR security deposit. */
16
+ export type NearDepositTx = {
17
+ family: "near";
18
+ receiverId: string;
19
+ methodName: "ft_transfer";
20
+ args: {
21
+ receiver_id: string;
22
+ amount: string;
23
+ };
24
+ gas: string;
25
+ deposit: "1";
26
+ };
27
+ export type DepositTx = EvmDepositTx | TronDepositTx | NearDepositTx;
16
28
  /** Unsigned transfer of the quote's `amountIn` to its `depositAddress`. The caller signs and broadcasts. */
17
29
  export declare function prepareDepositTx(origin: OriginKey, originAsset: StableKey, quote: QuoteResponse): DepositTx;
package/dist/deposit.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { resolveOrigin, family } from "./registry.js";
2
2
  const pad32 = (hex) => hex.replace(/^0x/, "").toLowerCase().padStart(64, "0");
3
+ /** 30 Tgas — generous for a plain `ft_transfer`, which calls no other contract. */
4
+ const NEAR_FT_TRANSFER_GAS = "30000000000000";
3
5
  /** Unsigned transfer of the quote's `amountIn` to its `depositAddress`. The caller signs and broadcasts. */
4
6
  export function prepareDepositTx(origin, originAsset, quote) {
5
7
  const { tokenAddress } = resolveOrigin(origin, originAsset);
@@ -8,8 +10,12 @@ export function prepareDepositTx(origin, originAsset, quote) {
8
10
  throw new Error("quote has no depositAddress (dry run?)");
9
11
  if (!tokenAddress)
10
12
  throw new Error(`no verified L1 token address for ${origin}/${originAsset} (see tasks.md precondition)`);
11
- if (family(origin) === "tron") {
13
+ const fam = family(origin);
14
+ if (fam === "tron") {
12
15
  return { family: "tron", contractAddress: tokenAddress, function: "transfer(address,uint256)", parameter: [depositAddress, amountIn] };
13
16
  }
17
+ if (fam === "near") {
18
+ return { family: "near", receiverId: tokenAddress, methodName: "ft_transfer", args: { receiver_id: depositAddress, amount: amountIn }, gas: NEAR_FT_TRANSFER_GAS, deposit: "1" };
19
+ }
14
20
  return { family: "evm", to: tokenAddress, value: "0x0", data: "0xa9059cbb" + pad32(depositAddress) + pad32(BigInt(amountIn).toString(16)) };
15
21
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { configure, quoteDeposit, type QuoteDepositParams } from "./quote.js";
2
- export { prepareDepositTx, type DepositTx, type EvmDepositTx, type TronDepositTx } from "./deposit.js";
2
+ export { prepareDepositTx, type DepositTx, type EvmDepositTx, type TronDepositTx, type NearDepositTx } from "./deposit.js";
3
3
  export { submitDeposit } from "./submit.js";
4
4
  export { getStatus, isTerminal } from "./status.js";
5
5
  export { listTokens, type SupportedToken } from "./tokens.js";
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
  }
@@ -48,8 +48,20 @@ export declare const ORIGINS: {
48
48
  readonly tokenAddress: "41a614f803b6fd780986a42c78ec9c7f77e6ded13c";
49
49
  };
50
50
  };
51
+ readonly near: {
52
+ readonly usdc: {
53
+ readonly assetId: "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1";
54
+ readonly decimals: 6;
55
+ readonly tokenAddress: "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1";
56
+ };
57
+ readonly usdt: {
58
+ readonly assetId: "nep141:usdt.tether-token.near";
59
+ readonly decimals: 6;
60
+ readonly tokenAddress: "usdt.tether-token.near";
61
+ };
62
+ };
51
63
  };
52
- export declare const family: (origin: OriginKey) => "evm" | "tron";
64
+ export declare const family: (origin: OriginKey) => "evm" | "tron" | "near";
53
65
  export declare function resolveOrigin(origin: string, originAsset: string): AssetEntry;
54
66
  export declare function resolveDest(destinationAsset: string): AssetEntry;
55
67
  export declare function normalizeRecipient(addr: string): string;
package/dist/registry.js CHANGED
@@ -2,11 +2,13 @@ export const MOVEMENT = {
2
2
  usdcx: { assetId: "nep141:movement-6f9a70ef4605e7d9174f1abf8d8d3c15012f48f3.omft.near", decimals: 6 },
3
3
  move: { assetId: "nep141:movement.omft.near", decimals: 8 },
4
4
  };
5
- // tokenAddress is the L1 token contract the deposit transfer targets. Provenance (the omft assetId hex
6
- // equals the L1 contract only on EVM — never derive a non-EVM contract from it):
5
+ // tokenAddress is the token contract the deposit transfer targets. Provenance (the omft assetId hex
6
+ // equals the token contract only on EVM — never derive a non-EVM contract from it):
7
7
  // ethereum USDC 0xa0b8…eb48 / USDT 0xdac1…1ec7 — canonical Ethereum contracts (also embedded in the assetId).
8
8
  // polygon USDC 0x3c49…3359 (native USDC, NOT USDC.e) / USDT 0xc213…8e8f — canonical Polygon contracts.
9
9
  // tron USDT 41a614f803… (TR7NHqje…) — canonical TRC-20 USDT; NOT the omft assetId hex (a bridge id).
10
+ // near USDC 17208628…6133a1 / USDT usdt.tether-token.near — canonical NEAR NEP-141 accounts; here the
11
+ // assetId's nep141: suffix already *is* the token contract (no bridge wrapping), unlike the others.
10
12
  export const ORIGINS = {
11
13
  ethereum: {
12
14
  usdc: { assetId: "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near", decimals: 6, tokenAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" },
@@ -19,8 +21,12 @@ export const ORIGINS = {
19
21
  tron: {
20
22
  usdt: { assetId: "nep141:tron-d28a265909efecdcee7c5028585214ea0b96f015.omft.near", decimals: 6, tokenAddress: "41a614f803b6fd780986a42c78ec9c7f77e6ded13c" },
21
23
  },
24
+ near: {
25
+ usdc: { assetId: "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", decimals: 6, tokenAddress: "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1" },
26
+ usdt: { assetId: "nep141:usdt.tether-token.near", decimals: 6, tokenAddress: "usdt.tether-token.near" },
27
+ },
22
28
  };
23
- export const family = (origin) => (origin === "tron" ? "tron" : "evm");
29
+ export const family = (origin) => origin === "tron" ? "tron" : origin === "near" ? "near" : "evm";
24
30
  export function resolveOrigin(origin, originAsset) {
25
31
  const e = ORIGINS[origin]?.[originAsset];
26
32
  if (!e)
package/dist/submit.d.ts CHANGED
@@ -3,7 +3,11 @@ import { type SubmitDepositTxResponse } from "@defuse-protocol/one-click-sdk-typ
3
3
  * Hand 1Click the deposit tx hash so it can start processing without waiting to
4
4
  * detect the deposit on the origin chain. Optional speed-up — status tracking works
5
5
  * without it. Goes between broadcasting the deposit and reading status.
6
+ *
7
+ * `nearSenderAccount` is required by the 1Click API for NEAR-origin deposits (the
8
+ * account that signed the `ft_transfer`); ignored for other origins.
6
9
  */
7
10
  export declare function submitDeposit(depositAddress: string, txHash: string, opts?: {
8
11
  memo?: string;
12
+ nearSenderAccount?: string;
9
13
  }): Promise<SubmitDepositTxResponse>;
package/dist/submit.js CHANGED
@@ -3,7 +3,10 @@ import { OneClickService } from "@defuse-protocol/one-click-sdk-typescript";
3
3
  * Hand 1Click the deposit tx hash so it can start processing without waiting to
4
4
  * detect the deposit on the origin chain. Optional speed-up — status tracking works
5
5
  * without it. Goes between broadcasting the deposit and reading status.
6
+ *
7
+ * `nearSenderAccount` is required by the 1Click API for NEAR-origin deposits (the
8
+ * account that signed the `ft_transfer`); ignored for other origins.
6
9
  */
7
10
  export async function submitDeposit(depositAddress, txHash, opts = {}) {
8
- return OneClickService.submitDepositTx({ depositAddress, txHash, memo: opts.memo });
11
+ return OneClickService.submitDepositTx({ depositAddress, txHash, memo: opts.memo, nearSenderAccount: opts.nearSenderAccount });
9
12
  }
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.3",
4
4
  "description": "Thin SDK: USDT/USDC -> Movement USDCx/MOVE over NEAR Intents 1Click.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",