@ravnexchange/sdk 0.2.4 → 0.2.5

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.
@@ -39,10 +39,13 @@ export interface ExecuteAndTrackHandlers {
39
39
  * (the same hash repeated, or just one, for one transaction). Not a batch id or a 4337
40
40
  * userOpHash: RAVN proves its fee from that transaction. When given, a token-paid RAVN fee rides
41
41
  * in the swap's own confirmation, and so does the swap's approval when it needs one; a
42
- * TRANSACTION's native-coin fee is always a plain transaction of its own (with sendDeposit, a
42
+ * TRANSACTION's native-coin fee only when its `batch` says so (a coin sell's fee minted to RAVN as
43
+ * WETH, Robinhood Chain and Arbitrum), else a plain transaction of its own (with sendDeposit, a
43
44
  * DEPOSIT's calls go together only when its `batch` says so). The batch's gas limit is your
44
45
  * wallet's (EIP-5792 carries none): give it headroom, as a wallet estimating it tight reverts
45
- * the whole batch. Reject only when nothing was sent: a rejection loses the swap's hash.
46
+ * the whole batch (no fee leaves without the swap). A heavy swap needs the most: Fly's on
47
+ * Robinhood Chain measured 430–560k gas (2026-10-20). Reject only when nothing was sent: a
48
+ * rejection loses the swap's hash.
46
49
  */
47
50
  sendCalls?(txs: TxLike[]): Promise<string[]>;
48
51
  /** Sign an EIP-712 typed-data payload. Only called for SIGNATURE executions. */
@@ -286,12 +286,13 @@ async function executeAndTrack(client, params, handlers, options = {}) {
286
286
  let txHash;
287
287
  let feeTxHash;
288
288
  let feeError;
289
- if (feeTx && BigInt(feeTx.value) === 0n && handlers.sendCalls) {
290
- // A token fee may ride in the swap's own confirmation, and the swap's approval with it:
291
- // atomic, so neither outlives a swap that reverted. Only here: ExecutionDTO doesn't name
292
- // its venue, and the first-party app never batches THORChain (Bifrost ignores a router
293
- // deposit whose tx.to is the user's own 7702 account) or Bebop (its settlement needs gas
294
- // headroom a batch leaves to the wallet); fee-beside routes are neither.
289
+ // RAVN says whether the fee may share the swap's confirmation (`batch`): a token fee, or a coin
290
+ // sell's fee minted to RAVN as WETH (a coin sent from a batch is an internal transfer, which
291
+ // proves nothing on those chains), never at a venue that can't take a batch (THORChain, Bebop,
292
+ // a two-hop route). An API answering without `batch` (before calls + batch): a token fee only.
293
+ const batchFee = execution.batch ?? BigInt(feeTx?.value ?? "1") === 0n;
294
+ if (feeTx && batchFee && handlers.sendCalls) {
295
+ // Atomic, so neither the fee nor the swap's approval outlives a swap that reverted.
295
296
  const batchApproval = await neededApproval(approval);
296
297
  const reset = batchApproval?.reset && { ...batchApproval.reset, chainId: batchApproval.chainId };
297
298
  const approvals = batchApproval ? [...(reset ? [reset] : []), batchApproval] : [];
package/dist/types.d.ts CHANGED
@@ -175,25 +175,28 @@ export type ExecutionDTO = {
175
175
  };
176
176
  /**
177
177
  * Only when your key sets a fee and the route has no fee of its own (Eco, Layerswap, Mayan's
178
- * routes paying no referrer) from an EVM chain: RAVN's fee, a transfer of the input token to
179
- * RAVN; `transaction` already leaves it out. From Solana there is none to send: the fee is a
180
- * transfer inside `transaction.serialized`. Skip it and the swap still fills; no fee is owed to
181
- * you. A wallet that batches (EIP-5792 `wallet_sendCalls`) or relays (smart account, 7702,
182
- * 4337) may send `fee.transaction` with `transaction` in one confirmation (one fee-bearing swap
183
- * per transaction: a second fee in it isn't proven), for an ERC-20 sell
184
- * (a native-coin fee must be a plain transaction of its own, so a contract wallet that can't
185
- * send one — a Safe, a 4337 account — can't pay it). Pass the on-chain hash of the transaction
186
- * that carried the fee (not an EIP-5792 batch id or a 4337 userOpHash) as `txHash` to getStatus
187
- * — not needed with no `statusRef` here, when the fee rode in the swap's own transaction. Sent
188
- * on its own, send it once the swap has confirmed. A fee paid on a swap the venue refunds
189
- * stays with RAVN.
178
+ * routes paying no referrer, Fly Trade's coin sells where its own fee can't be proven:
179
+ * Robinhood Chain, Arbitrum and others) from an EVM chain: RAVN's fee, a transfer of the input
180
+ * token to RAVN, or on Robinhood Chain and Arbitrum a coin sell's fee as WETH minted to RAVN
181
+ * (the coin sent to WETH's `depositTo`; `fee.token` in the quote is WETH); `transaction`
182
+ * already leaves it out. From Solana there is none to send: the fee is a transfer inside
183
+ * `transaction.serialized`. Skip it and the swap still fills; no fee is owed to you. A wallet
184
+ * that batches (EIP-5792 `wallet_sendCalls`) or relays (smart account, 7702, 4337) may send
185
+ * `fee.transaction` with `transaction` in one confirmation (one fee-bearing swap per
186
+ * transaction: a second fee in it isn't proven), for an ERC-20 sell, or a coin sell whose fee
187
+ * is WETH minted to RAVN (`batch` true; a native-coin fee must otherwise be a plain transaction
188
+ * of its own, so a contract wallet that can't send one — a Safe, a 4337 account — can't pay
189
+ * it). Pass the on-chain hash of the transaction that carried the fee (not an EIP-5792 batch id
190
+ * or a 4337 userOpHash) as `txHash` to getStatus — not needed with no `statusRef` here, when
191
+ * the fee rode in the swap's own transaction. Sent on its own, send it once the swap has
192
+ * confirmed. A fee paid on a swap the venue refunds stays with RAVN.
190
193
  */
191
194
  fee?: DepositFeeDTO;
192
195
  /** EVM: everything to send, in order (approval.reset, approval, the swap or the deposit
193
196
  * transfer, RAVN's fee). Each once the one before has succeeded (stop if one reverts), or, when
194
197
  * `batch` is true, all in one atomic wallet batch (EIP-5792 `wallet_sendCalls`,
195
198
  * `atomicRequired: true`): simulate it first, and send them one by one if that fails or the
196
- * last call needs more than ~400k gas. */
199
+ * swap's call needs more than ~400k gas. */
197
200
  calls?: CallDTO[];
198
201
  /** Whether `calls` (more than one) may go in one atomic wallet batch. */
199
202
  batch?: boolean;
@@ -249,7 +252,7 @@ export type ExecutionDTO = {
249
252
  * transfer, RAVN's fee). Each once the one before has succeeded (stop if one reverts), or, when
250
253
  * `batch` is true, all in one atomic wallet batch (EIP-5792 `wallet_sendCalls`,
251
254
  * `atomicRequired: true`): simulate it first, and send them one by one if that fails or the
252
- * last call needs more than ~400k gas. */
255
+ * swap's call needs more than ~400k gas. */
253
256
  calls?: CallDTO[];
254
257
  /** Whether `calls` (more than one) may go in one atomic wallet batch. */
255
258
  batch?: boolean;
@@ -264,14 +267,17 @@ export interface CallDTO {
264
267
  /** RAVN's integrator fee beside a deposit (or a transaction), in the input token, paid by your user
265
268
  * to RAVN; your share is paid out as usual. `deposit.amount` (the transaction) already leaves it out. */
266
269
  export interface DepositFeeDTO {
267
- /** Base units of the input token. */
270
+ /** Base units of the input token (the same in WETH, 18 decimals, where a coin sell's fee is
271
+ * minted as WETH). */
268
272
  amount: string;
269
273
  /** RAVN's fee address on the input chain. */
270
274
  address: string;
271
275
  chainId: number;
272
276
  /** EVM: send this transaction too, exactly as given (it carries a tag naming this swap): on its
273
277
  * own, or in the same wallet batch or relay as the deposit or swap (EIP-5792, smart account, 7702,
274
- * 4337) — an ERC-20 fee anywhere; a native-coin fee only beside a NEAR Intents deposit on
278
+ * 4337) — an ERC-20 fee anywhere, and a coin sell's fee minted to RAVN as WETH (Robinhood Chain,
279
+ * Arbitrum: the coin sent to WETH's `depositTo`, booked and paid out in WETH, proven by WETH's
280
+ * Transfer log wherever it rides); a native-coin fee only beside a NEAR Intents deposit on
275
281
  * Ethereum, Base or Polygon (proven from those chains' internal transfers). Any other native-coin
276
282
  * fee must be a plain transaction of its own (a contract wallet that can't send one can't pay it).
277
283
  * Then pass the on-chain hash of the transaction that carried it (not a batch id or a userOpHash)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravnexchange/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Typed client for the RAVN integrator API (/api/v1): quote, execute, submit-signature, status.",
5
5
  "keywords": ["ravn", "cross-chain", "swap", "swap-api", "dex-aggregator", "bitcoin", "native-btc", "solana", "evm", "crypto", "defi", "typescript", "sdk", "api-client"],
6
6
  "main": "./dist/index.js",