@sodax/sdk 2.1.0-rc.2 → 2.1.0-rc.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/dist/index.mjs CHANGED
@@ -4272,7 +4272,13 @@ var BTC_ADDRESS_TYPES = ["P2PKH", "P2SH", "P2WPKH", "P2TR"];
4272
4272
  // ../types/dist/hooks/hooks.js
4273
4273
  var HookKind = {
4274
4274
  /** Deposits delivered USDC into the recipient's HyperCore perps account (HyperEVM). */
4275
- HYPERCORE_DEPOSIT: "hyperCoreDeposit"
4275
+ HYPERCORE_DEPOSIT: "hyperCoreDeposit",
4276
+ /**
4277
+ * Requests an ERC-7540 deposit of delivered USDC into the Flint RWA vault (Ethereum), with the
4278
+ * recipient as the request's controller. Asynchronous: the request mints no shares — Flint's
4279
+ * curator settles a NAV and then claims the shares on the controller's behalf.
4280
+ */
4281
+ FLINT_DEPOSIT: "flintDeposit"
4276
4282
  };
4277
4283
  var spokeHooks = {
4278
4284
  [ChainKeys.HYPEREVM_MAINNET]: [
@@ -4283,6 +4289,20 @@ var spokeHooks = {
4283
4289
  // USDC on HyperEVM
4284
4290
  }
4285
4291
  ]
4292
+ // HookKind.FLINT_DEPOSIT is not registered yet: FlintDepositHook is not deployed to Ethereum
4293
+ // mainnet (icon-project/sodax-contracts#693). Registering it with a placeholder address would
4294
+ // route real intent output to that address, so the entry lands with the deployment:
4295
+ //
4296
+ // [ChainKeys.ETHEREUM_MAINNET]: [
4297
+ // {
4298
+ // kind: HookKind.FLINT_DEPOSIT,
4299
+ // address: '0x…',
4300
+ // supportedTokens: [spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.USDC.address],
4301
+ // },
4302
+ // ],
4303
+ //
4304
+ // Until then `getSpokeHook` returns undefined and `resolveDeliveryHook` throws, which is the
4305
+ // correct behaviour for a hook that does not exist on chain.
4286
4306
  };
4287
4307
  var getSpokeHook = (chainKey, kind) => spokeHooks[chainKey]?.find((h) => h.kind === kind);
4288
4308
  var getSpokeHooks = (chainKey) => spokeHooks[chainKey] ?? [];
@@ -4408,7 +4428,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
4408
4428
  }
4409
4429
 
4410
4430
  // ../types/dist/index.js
4411
- var CONFIG_VERSION = 222;
4431
+ var CONFIG_VERSION = 223;
4412
4432
  function isEvmSpokeChainConfig(value) {
4413
4433
  return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
4414
4434
  }
@@ -14603,7 +14623,7 @@ var EvmVaultTokenService = class {
14603
14623
  return amount * BigInt(10 ** (decimals - 18));
14604
14624
  }
14605
14625
  };
14606
- var Erc20Service = class {
14626
+ var Erc20Service = class _Erc20Service {
14607
14627
  constructor() {
14608
14628
  }
14609
14629
  static async getErc20Token(token, publicClient) {
@@ -14629,6 +14649,19 @@ var Erc20Service = class {
14629
14649
  });
14630
14650
  return { name, symbol, decimals, address: token };
14631
14651
  }
14652
+ /**
14653
+ * Read the current on-chain allowance of `spender` over `owner`'s balance.
14654
+ * @param params - Token, owner, spender, and publicClient for the chain.
14655
+ * @returns The raw allowance.
14656
+ */
14657
+ static async getAllowance(params) {
14658
+ return params.publicClient.readContract({
14659
+ address: params.token,
14660
+ abi: erc20Abi$1,
14661
+ functionName: "allowance",
14662
+ args: [params.owner, params.spender]
14663
+ });
14664
+ }
14632
14665
  /**
14633
14666
  * Check if spender has enough ERC20 allowance for given amount.
14634
14667
  * @param params - Token, amount, owner, spender, chainKey, and publicClient for the chain.
@@ -14642,12 +14675,7 @@ var Erc20Service = class {
14642
14675
  value: true
14643
14676
  };
14644
14677
  }
14645
- const allowedAmount = await params.publicClient.readContract({
14646
- address: params.token,
14647
- abi: erc20Abi$1,
14648
- functionName: "allowance",
14649
- args: [params.owner, params.spender]
14650
- });
14678
+ const allowedAmount = await _Erc20Service.getAllowance(params);
14651
14679
  return {
14652
14680
  ok: true,
14653
14681
  value: allowedAmount >= params.amount
@@ -14659,6 +14687,59 @@ var Erc20Service = class {
14659
14687
  };
14660
14688
  }
14661
14689
  }
14690
+ /**
14691
+ * Decide how many approve transactions this token needs for `amount`.
14692
+ *
14693
+ * Tokens of the 2017 TetherToken lineage reject an allowance change from one non-zero value to
14694
+ * another, so a wallet holding a stale allowance can never approve — every retry reverts the same
14695
+ * way. Such a token needs `approve(0)` first.
14696
+ *
14697
+ * Detection is behavioural: a simulated approve either reverts or it does not. That answers the
14698
+ * question that actually matters ("will this approve revert?") instead of "is this token USDT?",
14699
+ * so a token listed later, or upgraded later behind the same address, is covered without a code
14700
+ * change — and no token list is hardcoded.
14701
+ *
14702
+ * The probes only run once an allowance is already set. The common path (nothing approved yet)
14703
+ * costs a single read.
14704
+ */
14705
+ static async planApproval(params) {
14706
+ const single = (reason) => ({ approveAmount: params.amount, reason });
14707
+ if (params.token.toLowerCase() === params.nativeToken.toLowerCase()) {
14708
+ return single("native-token");
14709
+ }
14710
+ let allowance;
14711
+ try {
14712
+ allowance = await _Erc20Service.getAllowance(params);
14713
+ } catch {
14714
+ return single("allowance-read-failed");
14715
+ }
14716
+ if (allowance === 0n) {
14717
+ return single("zero-allowance");
14718
+ }
14719
+ if (await _Erc20Service.canApprove(params, params.amount)) {
14720
+ return single("probe-passed");
14721
+ }
14722
+ if (!await _Erc20Service.canApprove(params, 0n)) {
14723
+ return single("reset-not-viable");
14724
+ }
14725
+ return { resetAmount: 0n, approveAmount: params.amount, reason: "reset-required" };
14726
+ }
14727
+ /**
14728
+ * Simulate `approve(spender, amount)` as `owner`.
14729
+ *
14730
+ * `call` rather than `simulateContract`, because a TetherToken-lineage `approve` returns no value
14731
+ * and ABI decoding would fail even on a successful call. `account` is required: the guard reads
14732
+ * `allowed[msg.sender][spender]`.
14733
+ */
14734
+ static async canApprove(params, amount) {
14735
+ const { data } = _Erc20Service.encodeApprove(params.token, params.spender, amount);
14736
+ try {
14737
+ await params.publicClient.call({ account: params.owner, to: params.token, data });
14738
+ return true;
14739
+ } catch {
14740
+ return false;
14741
+ }
14742
+ }
14662
14743
  /**
14663
14744
  * Approve ERC20 amount spending
14664
14745
  * @param token - ERC20 token address
@@ -22415,7 +22496,17 @@ var IntentDataType = /* @__PURE__ */ ((IntentDataType2) => {
22415
22496
  })(IntentDataType || {});
22416
22497
  var HOOK_DELIVERY_ABI = {
22417
22498
  // HyperCoreDepositHook expects `abi.encode(address)` — the HyperCore account to credit.
22418
- [HookKind.HYPERCORE_DEPOSIT]: [{ name: "recipient", type: "address" }]
22499
+ [HookKind.HYPERCORE_DEPOSIT]: [{ name: "recipient", type: "address" }],
22500
+ // FlintDepositHook expects `abi.encode(address)` — the ERC-7540 controller the deposit request is
22501
+ // recorded against, i.e. the account that ends up owning the resulting flUSD shares. Same shape as
22502
+ // HyperCore's today; kept as its own entry so the two can diverge without touching each other.
22503
+ [HookKind.FLINT_DEPOSIT]: [{ name: "recipient", type: "address" }]
22504
+ };
22505
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
22506
+ var assertUnsupportedHook = (request) => {
22507
+ throw new Error(
22508
+ `[HookService.encodeDeliveryData] Unsupported delivery hook kind: ${request.kind}`
22509
+ );
22419
22510
  };
22420
22511
  var HookService = class _HookService {
22421
22512
  constructor() {
@@ -22424,17 +22515,28 @@ var HookService = class _HookService {
22424
22515
  * Encodes a hook's `deliveryData` payload. One common entry point for all hooks — the encoding is
22425
22516
  * selected by {@link HookRequest.kind} and uses that hook's schema from {@link HOOK_DELIVERY_ABI}.
22426
22517
  *
22518
+ * Rejects the zero address. Every hook treats its recipient as the account to credit, and a
22519
+ * zero recipient is unrecoverable on arrival: the receiver reverts, which rolls back the whole
22520
+ * cross-chain withdrawal inside `SpokeAssetManager.recvMessage` and leaves the message wedged —
22521
+ * every retry hits the same revert. Failing here keeps that mistake client-side, before an intent
22522
+ * exists. Malformed and non-EVM addresses already throw inside viem's encoder.
22523
+ *
22427
22524
  * @param request - The hook selection (and any hook-specific params).
22428
22525
  * @param recipient - The end recipient the hook should credit (the intent's `dstAddress`).
22429
22526
  */
22430
22527
  static encodeDeliveryData(request, recipient) {
22528
+ invariant(
22529
+ recipient.toLowerCase() !== ZERO_ADDRESS,
22530
+ "[HookService.encodeDeliveryData] recipient (dstAddress) must not be the zero address"
22531
+ );
22431
22532
  switch (request.kind) {
22432
22533
  case HookKind.HYPERCORE_DEPOSIT:
22433
22534
  return encodeAbiParameters(HOOK_DELIVERY_ABI[HookKind.HYPERCORE_DEPOSIT], [recipient]);
22535
+ case HookKind.FLINT_DEPOSIT:
22536
+ return encodeAbiParameters(HOOK_DELIVERY_ABI[HookKind.FLINT_DEPOSIT], [recipient]);
22537
+ default:
22538
+ return assertUnsupportedHook(request);
22434
22539
  }
22435
- throw new Error(
22436
- `[HookService.encodeDeliveryData] Unsupported delivery hook kind: ${request.kind}`
22437
- );
22438
22540
  }
22439
22541
  /**
22440
22542
  * Resolves a high-level {@link HookRequest} to the on-chain delivery pair: the deployed hook address
@@ -24802,6 +24904,12 @@ var SpokeService = class _SpokeService {
24802
24904
  /**
24803
24905
  * Approve ERC-20 spending on hub / EVM spoke or request a Stellar trustline using unified params.
24804
24906
  * Feature services map their action payloads into {@link SpokeApproveParams}.
24907
+ *
24908
+ * A signed ERC-20 approval can take **two** transactions: a token of the TetherToken lineage
24909
+ * rejects an allowance change from one non-zero value to another, so a stale allowance is zeroed
24910
+ * first and the user signs twice. The returned hash is always the last transaction's, so the
24911
+ * contract callers see is unchanged. An unsigned caller still gets exactly one transaction — use
24912
+ * {@link SpokeService.buildApproveTxs} to get the whole plan.
24805
24913
  */
24806
24914
  async approve(params) {
24807
24915
  try {
@@ -24809,53 +24917,168 @@ var SpokeService = class _SpokeService {
24809
24917
  isUndefinedOrValidWalletProviderForChainKey(params.srcChainKey, params.walletProvider),
24810
24918
  `Invalid wallet provider for chain key: ${params.srcChainKey}, walletProvider.chainType: ${params.walletProvider?.chainType}`
24811
24919
  );
24812
- if (isSpokeApproveParamsHub(params)) {
24813
- const result = await Erc20Service.approve({
24814
- ...params,
24815
- token: params.token,
24816
- amount: params.amount,
24817
- from: params.owner,
24818
- spender: params.spender
24819
- });
24920
+ if (isSpokeApproveParamsHub(params) || isSpokeApproveParamsEvmSpoke(params)) {
24921
+ if (params.raw) {
24922
+ const tx = await Erc20Service.approve({
24923
+ ...params,
24924
+ token: params.token,
24925
+ amount: params.amount,
24926
+ from: params.owner,
24927
+ spender: params.spender
24928
+ });
24929
+ return { ok: true, value: tx };
24930
+ }
24931
+ const result = await this.executeErc20ApprovalPlan(params);
24932
+ if (!result.ok) {
24933
+ return result;
24934
+ }
24820
24935
  return {
24821
24936
  ok: true,
24822
- value: result
24937
+ value: result.value
24823
24938
  };
24824
24939
  }
24825
- if (isSpokeApproveParamsEvmSpoke(params)) {
24826
- const result = await Erc20Service.approve({
24827
- ...params,
24828
- token: params.token,
24829
- amount: params.amount,
24830
- from: params.owner,
24831
- spender: params.spender
24832
- });
24940
+ if (isSpokeApproveParamsStellar(params)) {
24941
+ const result = await this.requestTrustlineForApproval(params);
24833
24942
  return {
24834
24943
  ok: true,
24835
24944
  value: result
24836
24945
  };
24837
24946
  }
24838
- if (isSpokeApproveParamsStellar(params)) {
24839
- const result = await this.stellar.requestTrustline({
24840
- ...params,
24841
- srcAddress: params.owner,
24842
- srcChainKey: params.srcChainKey,
24947
+ return {
24948
+ ok: false,
24949
+ error: new Error("[SpokeService.approve] Only hub (Sonic), EVM spokes, and Stellar are supported")
24950
+ };
24951
+ } catch (error) {
24952
+ return { ok: false, error };
24953
+ }
24954
+ }
24955
+ /**
24956
+ * The unsigned approval transactions, named rather than ordered (see {@link ApprovalTxs}).
24957
+ *
24958
+ * `resetTx` is present only when the token needs its stale allowance cleared first (see
24959
+ * {@link Erc20Service.planApproval}); broadcast it and wait for it to be mined before `approveTx`,
24960
+ * which is not valid until the reset has landed. Unsigned callers — the swaps API and the apps
24961
+ * built on it — need this, because {@link SpokeService.approve} can only hand back a single `tx`.
24962
+ *
24963
+ * Deliberately separate from {@link SpokeService.approve} rather than a mode of it: the two return
24964
+ * genuinely different shapes, and folding them together would put a union in the return type of
24965
+ * the method every feature approves through.
24966
+ */
24967
+ async buildApproveTxs(params) {
24968
+ try {
24969
+ if (isSpokeApproveParamsHub(params) || isSpokeApproveParamsEvmSpoke(params)) {
24970
+ const plan = await this.planErc20Approval(params, "buildApproveTxs");
24971
+ const encode3 = (amount) => Erc20Service.approve({
24843
24972
  token: params.token,
24844
- amount: params.amount
24973
+ amount,
24974
+ from: params.owner,
24975
+ spender: params.spender,
24976
+ raw: true
24845
24977
  });
24978
+ const resetTx = plan.resetAmount === void 0 ? void 0 : await encode3(plan.resetAmount);
24979
+ const approveTx = await encode3(plan.approveAmount);
24980
+ return { ok: true, value: resetTx === void 0 ? { approveTx } : { resetTx, approveTx } };
24981
+ }
24982
+ if (isSpokeApproveParamsStellar(params)) {
24983
+ const tx = await this.requestTrustlineForApproval({ ...params, raw: true });
24846
24984
  return {
24847
24985
  ok: true,
24848
- value: result
24986
+ value: { approveTx: tx }
24849
24987
  };
24850
24988
  }
24851
24989
  return {
24852
24990
  ok: false,
24853
- error: new Error("[SpokeService.approve] Only hub (Sonic), EVM spokes, and Stellar are supported")
24991
+ error: new Error("[SpokeService.buildApproveTxs] Only hub (Sonic), EVM spokes, and Stellar are supported")
24854
24992
  };
24855
24993
  } catch (error) {
24856
24994
  return { ok: false, error };
24857
24995
  }
24858
24996
  }
24997
+ /**
24998
+ * Sign and broadcast the approval plan for an ERC-20 on the hub or an EVM spoke.
24999
+ *
25000
+ * A token of the TetherToken lineage rejects an allowance change from one non-zero value to
25001
+ * another, so a wallet holding a stale allowance needs `approve(0)` first. The transactions cannot
25002
+ * be batched: each one is only valid once its predecessor has been mined. The hash of the last is
25003
+ * returned, so the contract callers see is unchanged.
25004
+ */
25005
+ async executeErc20ApprovalPlan(params) {
25006
+ const { walletProvider } = params;
25007
+ invariant(
25008
+ walletProvider !== void 0 && isEvmWalletProviderType(walletProvider),
25009
+ "[SpokeService.approve] Expected an EVM wallet provider for a signed approval"
25010
+ );
25011
+ const plan = await this.planErc20Approval(params, "approve");
25012
+ const sendApprove = (amount) => Erc20Service.approve({
25013
+ token: params.token,
25014
+ amount,
25015
+ from: params.owner,
25016
+ spender: params.spender,
25017
+ raw: false,
25018
+ walletProvider
25019
+ });
25020
+ if (plan.resetAmount !== void 0) {
25021
+ const resetHash = await sendApprove(plan.resetAmount);
25022
+ const receipt = await this.waitForTxReceipt({ txHash: resetHash, chainKey: params.srcChainKey });
25023
+ if (!receipt.ok || receipt.value.status !== "success") {
25024
+ return {
25025
+ ok: false,
25026
+ error: new Error(
25027
+ `[SpokeService.approve] allowance reset transaction ${resetHash} did not confirm. Retry the approval \u2014 once the reset has landed it takes a single transaction.`
25028
+ )
25029
+ };
25030
+ }
25031
+ }
25032
+ const txHash = await sendApprove(plan.approveAmount);
25033
+ return { ok: true, value: txHash };
25034
+ }
25035
+ /**
25036
+ * Stellar approves by adding a trustline — always a single transaction, with no allowance to plan
25037
+ * around. Shared by both entry points so the param mapping and its cast live in one place.
25038
+ */
25039
+ requestTrustlineForApproval(params) {
25040
+ return this.stellar.requestTrustline({
25041
+ ...params,
25042
+ srcAddress: params.owner,
25043
+ srcChainKey: params.srcChainKey,
25044
+ token: params.token,
25045
+ amount: params.amount
25046
+ });
25047
+ }
25048
+ /** Resolve the chain-specific inputs {@link Erc20Service.planApproval} needs, and record the plan. */
25049
+ async planErc20Approval(params, caller) {
25050
+ const plan = await Erc20Service.planApproval({
25051
+ token: params.token,
25052
+ owner: params.owner,
25053
+ spender: params.spender,
25054
+ amount: params.amount,
25055
+ nativeToken: this.config.getChainConfig(params.srcChainKey).nativeToken,
25056
+ publicClient: this.getEvmPublicClient(params.srcChainKey)
25057
+ });
25058
+ this.logApprovalPlan(caller, params.srcChainKey, params.token, plan);
25059
+ return plan;
25060
+ }
25061
+ /** The read client for an EVM chain, whether it is the hub or a spoke. */
25062
+ getEvmPublicClient(chainKey) {
25063
+ return isHubChainKeyType(chainKey) ? this.sonic.publicClient : this.evm.getPublicClient(chainKey);
25064
+ }
25065
+ /**
25066
+ * Log a plan only when it says something: an extra transaction the user will have to sign, or a
25067
+ * probe that could not reach a verdict. The ordinary single approve is the vast majority of calls
25068
+ * and stays silent.
25069
+ */
25070
+ logApprovalPlan(caller, chainKey, token, plan) {
25071
+ const isNoteworthy = plan.resetAmount !== void 0 || plan.reason === "reset-not-viable" || plan.reason === "allowance-read-failed";
25072
+ if (!isNoteworthy) {
25073
+ return;
25074
+ }
25075
+ this.config.logger.debug(`[SpokeService.${caller}] approval plan`, {
25076
+ chainKey,
25077
+ token,
25078
+ needsReset: plan.resetAmount !== void 0,
25079
+ reason: plan.reason
25080
+ });
25081
+ }
24859
25082
  /**
24860
25083
  * Estimate the gas for a raw transaction.
24861
25084
  * @param {TxReturnType<T, true>} params - The parameters for the raw transaction.
@@ -27188,9 +27411,13 @@ var SwapService = class {
27188
27411
  * - Stellar: approves the trustline (adds/increases it).
27189
27412
  * - Other chain types: returns an error — approval is not supported.
27190
27413
  *
27191
- * When `raw: true`, returns unsigned transaction data instead of broadcasting.
27414
+ * When `raw: true`, returns unsigned transaction data instead of broadcasting. That is always a
27415
+ * single transaction, which cannot express the two-step approval a TetherToken-lineage token
27416
+ * needs when a stale allowance already exists — use {@link SwapService.buildApproveTxs} for the
27417
+ * whole plan.
27192
27418
  * When `raw: false`, a matching wallet provider for `K` must be supplied and the transaction
27193
- * is signed and broadcast immediately.
27419
+ * is signed and broadcast immediately. Such an approval can take **two** transactions, so the
27420
+ * user may sign twice; the returned hash is the last one's.
27194
27421
  *
27195
27422
  * @param _params - Swap action params including the source chain key, input token, amount, and wallet provider.
27196
27423
  * @returns A `Result` wrapping the chain-specific transaction return type (`TxReturnType<K, Raw>`).
@@ -27260,6 +27487,62 @@ var SwapService = class {
27260
27487
  return { ok: false, error };
27261
27488
  }
27262
27489
  }
27490
+ /**
27491
+ * The unsigned approval transactions for the swap's source token, in the order they must be
27492
+ * broadcast.
27493
+ *
27494
+ * Two transactions when the source token needs its stale allowance cleared first, one otherwise.
27495
+ * {@link SwapService.approve} is unchanged and still returns a single transaction; this is the
27496
+ * entry point for unsigned callers that need to handle the two-step case. When `resetTx` is
27497
+ * present, broadcast it and wait for it to be mined first — `approveTx` is not valid until the
27498
+ * reset has landed.
27499
+ */
27500
+ async buildApproveTxs(_params) {
27501
+ const { params } = _params;
27502
+ const wrapApproveFailure = (cause) => approveFailed("swap", cause);
27503
+ try {
27504
+ if (isHubChainKeyType(params.srcChainKey) || isEvmSpokeOnlyChainKeyType(params.srcChainKey)) {
27505
+ const spender = isHubChainKeyType(params.srcChainKey) ? this.solver.intentsContract : this.config.getChainConfig(params.srcChainKey).addresses.assetManager;
27506
+ const result = await this.spoke.buildApproveTxs({
27507
+ srcChainKey: params.srcChainKey,
27508
+ owner: params.srcAddress,
27509
+ token: params.inputToken,
27510
+ amount: params.inputAmount,
27511
+ spender,
27512
+ raw: true
27513
+ });
27514
+ if (!result.ok) {
27515
+ return { ok: false, error: wrapApproveFailure(result.error) };
27516
+ }
27517
+ return {
27518
+ ok: true,
27519
+ value: result.value
27520
+ };
27521
+ }
27522
+ if (isStellarChainKeyType(params.srcChainKey)) {
27523
+ const result = await this.spoke.buildApproveTxs({
27524
+ srcChainKey: params.srcChainKey,
27525
+ token: params.inputToken,
27526
+ amount: params.inputAmount,
27527
+ owner: params.srcAddress,
27528
+ raw: true
27529
+ });
27530
+ if (!result.ok) {
27531
+ return { ok: false, error: wrapApproveFailure(result.error) };
27532
+ }
27533
+ return {
27534
+ ok: true,
27535
+ value: result.value
27536
+ };
27537
+ }
27538
+ return {
27539
+ ok: false,
27540
+ error: new Error("Approve only supported for hub (Sonic), EVM spokes, and Stellar")
27541
+ };
27542
+ } catch (error) {
27543
+ return { ok: false, error };
27544
+ }
27545
+ }
27263
27546
  /**
27264
27547
  * Creates a swap intent on the user's source spoke chain without submitting it to the solver.
27265
27548
  *
@@ -40575,15 +40858,22 @@ var LeverageYieldService = class {
40575
40858
  spender: params.vault
40576
40859
  };
40577
40860
  if (params.raw) {
40578
- const tx2 = await Erc20Service.approve({ ...baseApprove, raw: true });
40579
- return { ok: true, value: tx2 };
40580
- }
40581
- const tx = await Erc20Service.approve({
40582
- ...baseApprove,
40861
+ const tx = await Erc20Service.approve({ ...baseApprove, raw: true });
40862
+ return { ok: true, value: tx };
40863
+ }
40864
+ const result = await this.spoke.approve({
40865
+ srcChainKey: this.hubProvider.chainConfig.chain.key,
40866
+ token: baseApprove.token,
40867
+ amount: baseApprove.amount,
40868
+ owner: from,
40869
+ spender: baseApprove.spender,
40583
40870
  raw: false,
40584
40871
  walletProvider: params.walletProvider
40585
40872
  });
40586
- return { ok: true, value: tx };
40873
+ if (!result.ok) {
40874
+ return { ok: false, error: approveFailed("leverageYield", result.error, baseCtx) };
40875
+ }
40876
+ return { ok: true, value: result.value };
40587
40877
  } catch (error) {
40588
40878
  if (isLeverageYieldApproveError(error)) return { ok: false, error };
40589
40879
  return { ok: false, error: approveFailed("leverageYield", error, baseCtx) };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "2.1.0-rc.2",
7
+ "version": "2.1.0-rc.3",
8
8
  "license": "MIT",
9
9
  "description": "Sodax SDK",
10
10
  "keywords": [
@@ -67,9 +67,9 @@
67
67
  "rlp": "3.0.0",
68
68
  "viem": "2.29.2",
69
69
  "valibot": "1.4.1",
70
- "@sodax/libs": "2.1.0-rc.2",
71
- "@sodax/swaps-api": "2.1.0-rc.2",
72
- "@sodax/types": "2.1.0-rc.2"
70
+ "@sodax/libs": "2.1.0-rc.3",
71
+ "@sodax/swaps-api": "2.1.0-rc.3",
72
+ "@sodax/types": "2.1.0-rc.3"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@arethetypeswrong/cli": "0.17.4",