@defuse-protocol/intents-sdk 0.14.0 → 0.15.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/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // src/sdk.ts
2
2
  import {
3
- assert as assert11,
3
+ assert as assert13,
4
4
  PUBLIC_NEAR_RPC_URLS,
5
- RETRY_CONFIGS as RETRY_CONFIGS2,
6
- configsByEnvironment as configsByEnvironment7,
5
+ RETRY_CONFIGS as RETRY_CONFIGS3,
6
+ configsByEnvironment as configsByEnvironment8,
7
7
  nearFailoverRpcProvider,
8
- solverRelay as solverRelay5
8
+ solverRelay as solverRelay6
9
9
  } from "@defuse-protocol/internal-utils";
10
10
  import hotOmniSdk from "@hot-labs/omni-sdk";
11
11
  import { stringify } from "viem";
@@ -24,6 +24,7 @@ import {
24
24
  var RouteEnum = {
25
25
  HotBridge: "hot_bridge",
26
26
  PoaBridge: "poa_bridge",
27
+ OmniBridge: "omni_bridge",
27
28
  NearWithdrawal: "near_withdrawal",
28
29
  VirtualChain: "virtual_chain",
29
30
  InternalTransfer: "internal_transfer"
@@ -184,6 +185,7 @@ import {
184
185
  var BridgeNameEnum = {
185
186
  Hot: "hot",
186
187
  Poa: "poa",
188
+ Omni: "omni",
187
189
  None: null
188
190
  };
189
191
 
@@ -191,22 +193,22 @@ var BridgeNameEnum = {
191
193
  import { assert as assert3 } from "@defuse-protocol/internal-utils";
192
194
  var Chains = {
193
195
  Bitcoin: "bip122:000000000019d6689c085ae165831e93",
196
+ Zcash: "bip122:00040fe8ec8471911baa1db1266ea15d",
197
+ Dogecoin: "bip122:1a91e3dace36e2be3bf030a65679fe82",
194
198
  Ethereum: "eip155:1",
195
- Base: "eip155:8453",
196
- Arbitrum: "eip155:42161",
199
+ Optimism: "eip155:10",
197
200
  BNB: "eip155:56",
201
+ Gnosis: "eip155:100",
198
202
  Polygon: "eip155:137",
203
+ Base: "eip155:8453",
204
+ Arbitrum: "eip155:42161",
205
+ Avalanche: "eip155:43114",
206
+ Berachain: "eip155:80085",
199
207
  Near: "near:mainnet",
200
208
  Solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
201
209
  Tron: "tron:27Lqcw",
202
- Gnosis: "eip155:100",
203
210
  XRPL: "xrpl:0",
204
- Dogecoin: "bip122:1a91e3dace36e2be3bf030a65679fe82",
205
- Zcash: "zcash:0",
206
- Berachain: "eip155:80085",
207
211
  TON: "tvm:-239",
208
- Optimism: "eip155:10",
209
- Avalanche: "eip155:43114",
210
212
  Sui: "sui:mainnet",
211
213
  Aptos: "aptos:mainnet",
212
214
  Stellar: "stellar:pubnet",
@@ -770,19 +772,338 @@ var IntentsBridge = class {
770
772
  }
771
773
  };
772
774
 
773
- // src/bridges/poa-bridge/poa-bridge.ts
775
+ // src/bridges/omni-bridge/omni-bridge.ts
774
776
  import {
775
- assert as assert8,
777
+ assert as assert9,
778
+ RETRY_CONFIGS as RETRY_CONFIGS2,
776
779
  configsByEnvironment as configsByEnvironment4,
777
- poaBridge,
780
+ getNearNep141MinStorageBalance as getNearNep141MinStorageBalance3,
781
+ getNearNep141StorageBalance as getNearNep141StorageBalance3,
782
+ solverRelay as solverRelay4,
778
783
  utils as utils7
779
784
  } from "@defuse-protocol/internal-utils";
780
785
  import TTLCache from "@isaacs/ttlcache";
786
+ import { retry as retry2 } from "@lifeomic/attempt";
787
+ import {
788
+ ChainKind as ChainKind2,
789
+ OmniBridgeAPI,
790
+ getChain,
791
+ isEvmChain,
792
+ omniAddress as omniAddress2,
793
+ parseOriginChain
794
+ } from "omni-bridge-sdk";
781
795
 
782
- // src/bridges/poa-bridge/poa-bridge-utils.ts
783
- import { utils as utils6 } from "@defuse-protocol/internal-utils";
796
+ // src/bridges/omni-bridge/error.ts
797
+ import { BaseError as BaseError3 } from "@defuse-protocol/internal-utils";
798
+ var OmniTransferNotFoundError = class extends BaseError3 {
799
+ constructor(txHash) {
800
+ super("Omni transfer with given hash is not found in the relayer.", {
801
+ metaMessages: [`OriginTxHash: ${txHash}`],
802
+ name: "OmniTransferNotFoundError"
803
+ });
804
+ this.txHash = txHash;
805
+ }
806
+ };
807
+ var OmniTransferDestinationChainHashNotFoundError = class extends BaseError3 {
808
+ constructor(txHash, destinationChain) {
809
+ super("Relayer did not return destination chain hash for a transfer.", {
810
+ metaMessages: [
811
+ `OriginTxHash: ${txHash}`,
812
+ `DestinationChain: ${destinationChain}`
813
+ ],
814
+ name: "OmniTransferDestinationChainHashNotFoundError"
815
+ });
816
+ this.txHash = txHash;
817
+ this.destinationChain = destinationChain;
818
+ }
819
+ };
820
+ var TokenNotSupportedByOmniRelayerError = class extends BaseError3 {
821
+ constructor(token) {
822
+ super(`Omni Relayer doesn't accept fee in the transferred token ${token}`, {
823
+ metaMessages: [`Token: ${token}`],
824
+ name: "TokenNotSupportedByOmniRelayerError"
825
+ });
826
+ this.token = token;
827
+ }
828
+ };
829
+
830
+ // src/bridges/omni-bridge/omni-bridge-constants.ts
831
+ var NEAR_NATIVE_ASSET_ID3 = "nep141:wrap.near";
832
+ var OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
833
+
834
+ // src/bridges/omni-bridge/omni-bridge-utils.ts
835
+ import { assert as assert8, utils as utils6 } from "@defuse-protocol/internal-utils";
836
+ import { ChainKind, omniAddress } from "omni-bridge-sdk";
784
837
  function createWithdrawIntentPrimitive3(params) {
785
- const { contractId: tokenAccountId } = utils6.parseDefuseAssetId(
838
+ const { contractId: tokenAccountId, standard } = utils6.parseDefuseAssetId(
839
+ params.assetId
840
+ );
841
+ assert8(standard === "nep141", "Only NEP-141 is supported");
842
+ return {
843
+ intent: "ft_withdraw",
844
+ token: tokenAccountId,
845
+ receiver_id: OMNI_BRIDGE_CONTRACT,
846
+ amount: params.amount.toString(),
847
+ storage_deposit: params.storageDeposit > 0n ? params.storageDeposit.toString() : null,
848
+ msg: JSON.stringify({
849
+ recipient: omniAddress(
850
+ caip2ToChainKind(params.origin),
851
+ params.destinationAddress
852
+ ),
853
+ fee: params.transferredTokenFee.toString(),
854
+ native_token_fee: "0"
855
+ })
856
+ };
857
+ }
858
+ function caip2ToChainKind(network) {
859
+ switch (network) {
860
+ case Chains.Ethereum:
861
+ return ChainKind.Eth;
862
+ case Chains.Base:
863
+ return ChainKind.Base;
864
+ case Chains.Arbitrum:
865
+ return ChainKind.Arb;
866
+ case Chains.Solana:
867
+ return ChainKind.Sol;
868
+ case Chains.Bitcoin:
869
+ return ChainKind.Btc;
870
+ default:
871
+ throw new Error(`Unsupported Omni network = ${network}`);
872
+ }
873
+ }
874
+ function chainKindToCaip2(network) {
875
+ switch (network) {
876
+ case ChainKind.Eth:
877
+ return Chains.Ethereum;
878
+ case ChainKind.Base:
879
+ return Chains.Base;
880
+ case ChainKind.Arb:
881
+ return Chains.Arbitrum;
882
+ case ChainKind.Sol:
883
+ return Chains.Solana;
884
+ case ChainKind.Btc:
885
+ return Chains.Bitcoin;
886
+ default:
887
+ throw new Error(`Unsupported Caip2 network = ${network}`);
888
+ }
889
+ }
890
+
891
+ // src/bridges/omni-bridge/omni-bridge.ts
892
+ var _OmniBridge = class _OmniBridge {
893
+ // 86400000 - 1 day
894
+ constructor({
895
+ env,
896
+ nearProvider
897
+ }) {
898
+ this.storageDepositCache = new TTLCache({ ttl: 864e5 });
899
+ // TTL cache for supported tokens with 30-second TTL
900
+ this.supportedTokensCache = new TTLCache({ ttl: 864e5 });
901
+ this.env = env;
902
+ this.nearProvider = nearProvider;
903
+ this.omniBridgeAPI = new OmniBridgeAPI();
904
+ }
905
+ is(routeConfig) {
906
+ return routeConfig.route === RouteEnum.OmniBridge;
907
+ }
908
+ supports(params) {
909
+ try {
910
+ return this.parseAssetId(params.assetId) !== null;
911
+ } catch {
912
+ return false;
913
+ }
914
+ }
915
+ parseAssetId(assetId) {
916
+ const parsed = utils7.parseDefuseAssetId(assetId);
917
+ if (parsed.standard !== "nep141") return null;
918
+ const chain = parseOriginChain(parsed.contractId);
919
+ if (chain === null) return null;
920
+ return Object.assign(parsed, {
921
+ blockchain: chainKindToCaip2(chain),
922
+ bridgeName: BridgeNameEnum.Omni,
923
+ address: parsed.contractId
924
+ });
925
+ }
926
+ createWithdrawalIntents(args) {
927
+ const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
928
+ assert9(
929
+ assetInfo !== null,
930
+ `Asset ${args.withdrawalParams.assetId} is not supported`
931
+ );
932
+ const intents = [];
933
+ if (args.feeEstimation.quote !== null) {
934
+ intents.push({
935
+ intent: "token_diff",
936
+ diff: {
937
+ [args.feeEstimation.quote.defuse_asset_identifier_in]: `-${args.feeEstimation.quote.amount_in}`,
938
+ [args.feeEstimation.quote.defuse_asset_identifier_out]: args.feeEstimation.quote.amount_out
939
+ },
940
+ referral: args.referral
941
+ });
942
+ }
943
+ const intent = createWithdrawIntentPrimitive3({
944
+ assetId: args.withdrawalParams.assetId,
945
+ destinationAddress: args.withdrawalParams.destinationAddress,
946
+ amount: args.withdrawalParams.amount + args.feeEstimation.amount,
947
+ origin: assetInfo.blockchain,
948
+ storageDeposit: args.feeEstimation.quote ? BigInt(args.feeEstimation.quote.amount_out) : 0n,
949
+ transferredTokenFee: args.feeEstimation.amount
950
+ });
951
+ intents.push(intent);
952
+ return Promise.resolve(intents);
953
+ }
954
+ async validateWithdrawal(args) {
955
+ const assetInfo = this.parseAssetId(args.assetId);
956
+ assert9(assetInfo !== null, `Asset ${args.assetId} is not supported`);
957
+ const supportedTokens = await this.getCachedSupportedTokens();
958
+ if (!supportedTokens[assetInfo.contractId]) {
959
+ throw new TokenNotSupportedByOmniRelayerError(args.assetId);
960
+ }
961
+ assert9(
962
+ args.feeEstimation.amount > 0n,
963
+ `Fee must be greater than zero. Current fee is ${args.feeEstimation.amount}.`
964
+ );
965
+ return;
966
+ }
967
+ async estimateWithdrawalFee(args) {
968
+ const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
969
+ assert9(
970
+ assetInfo !== null,
971
+ `Asset ${args.withdrawalParams.assetId} is not supported`
972
+ );
973
+ const fee = await this.omniBridgeAPI.getFee(
974
+ omniAddress2(ChainKind2.Near, configsByEnvironment4[this.env].contractID),
975
+ omniAddress2(
976
+ caip2ToChainKind(assetInfo.blockchain),
977
+ args.withdrawalParams.destinationAddress
978
+ ),
979
+ omniAddress2(ChainKind2.Near, assetInfo.contractId)
980
+ );
981
+ assert9(
982
+ fee.transferred_token_fee !== null,
983
+ `Asset ${args.withdrawalParams.assetId} is not supported by the relayer`
984
+ );
985
+ const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
986
+ if (minStorageBalance <= userStorageBalance) {
987
+ return {
988
+ amount: BigInt(fee.transferred_token_fee),
989
+ quote: null
990
+ };
991
+ }
992
+ const feeAmount = minStorageBalance - userStorageBalance;
993
+ const feeQuote = await solverRelay4.getQuote({
994
+ quoteParams: {
995
+ defuse_asset_identifier_in: args.withdrawalParams.assetId,
996
+ defuse_asset_identifier_out: NEAR_NATIVE_ASSET_ID3,
997
+ exact_amount_out: feeAmount.toString(),
998
+ wait_ms: args.quoteOptions?.waitMs
999
+ },
1000
+ config: {
1001
+ baseURL: configsByEnvironment4[this.env].solverRelayBaseURL,
1002
+ logBalanceSufficient: false,
1003
+ logger: args.logger
1004
+ }
1005
+ });
1006
+ return {
1007
+ amount: BigInt(fee.transferred_token_fee) + BigInt(feeQuote.amount_in),
1008
+ quote: feeQuote
1009
+ };
1010
+ }
1011
+ async waitForWithdrawalCompletion(args) {
1012
+ return retry2(
1013
+ async () => {
1014
+ if (args.signal?.aborted) {
1015
+ throw args.signal.reason;
1016
+ }
1017
+ const transfer = (await this.omniBridgeAPI.findOmniTransfers({
1018
+ transaction_id: args.tx.hash,
1019
+ offset: args.index,
1020
+ limit: 1
1021
+ }))[0];
1022
+ if (!transfer) throw new OmniTransferNotFoundError(args.tx.hash);
1023
+ const destinationChain = getChain(
1024
+ transfer.transfer_message.recipient
1025
+ );
1026
+ let txHash = null;
1027
+ if (isEvmChain(destinationChain)) {
1028
+ txHash = transfer.finalised?.EVMLog?.transaction_hash;
1029
+ } else if (destinationChain === ChainKind2.Sol) {
1030
+ txHash = transfer.finalised?.Solana?.signature;
1031
+ } else {
1032
+ return { hash: null };
1033
+ }
1034
+ if (!txHash)
1035
+ throw new OmniTransferDestinationChainHashNotFoundError(
1036
+ args.tx.hash,
1037
+ ChainKind2[destinationChain].toLowerCase()
1038
+ );
1039
+ return { hash: txHash };
1040
+ },
1041
+ {
1042
+ ...args.retryOptions ?? RETRY_CONFIGS2.TWO_MINS_GRADUAL,
1043
+ handleError: (err, ctx) => {
1044
+ if (err instanceof OmniTransferNotFoundError || err === args.signal?.reason) {
1045
+ ctx.abort();
1046
+ }
1047
+ }
1048
+ }
1049
+ );
1050
+ }
1051
+ /**
1052
+ * Gets storage deposit for a token to avoid frequent RPC calls.
1053
+ * Cache expires after one day using TTL cache.
1054
+ */
1055
+ async getCachedStorageDepositValue(contractId) {
1056
+ const cached = this.storageDepositCache.get(contractId);
1057
+ if (cached != null) {
1058
+ return cached;
1059
+ }
1060
+ const data = await Promise.all([
1061
+ getNearNep141MinStorageBalance3({
1062
+ contractId,
1063
+ nearProvider: this.nearProvider
1064
+ }),
1065
+ getNearNep141StorageBalance3({
1066
+ contractId,
1067
+ accountId: OMNI_BRIDGE_CONTRACT,
1068
+ nearProvider: this.nearProvider
1069
+ })
1070
+ ]);
1071
+ this.storageDepositCache.set(contractId, data);
1072
+ return data;
1073
+ }
1074
+ /**
1075
+ * Gets cached tokens supported by the omni relayer, tokens not listed there can't be transferred.
1076
+ * Cache expires after one day using TTL cache.
1077
+ */
1078
+ async getCachedSupportedTokens() {
1079
+ const cached = this.supportedTokensCache.get(
1080
+ _OmniBridge.SUPPORTED_TOKENS_CACHE_KEY
1081
+ );
1082
+ if (cached != null) {
1083
+ return cached;
1084
+ }
1085
+ const data = await this.omniBridgeAPI.getAllowlistedTokens();
1086
+ this.supportedTokensCache.set(_OmniBridge.SUPPORTED_TOKENS_CACHE_KEY, data);
1087
+ return data;
1088
+ }
1089
+ };
1090
+ // 86400000 - 1 day
1091
+ _OmniBridge.SUPPORTED_TOKENS_CACHE_KEY = "SUPPORTED_TOKENS_CACHE_KEY";
1092
+ var OmniBridge = _OmniBridge;
1093
+
1094
+ // src/bridges/poa-bridge/poa-bridge.ts
1095
+ import {
1096
+ assert as assert10,
1097
+ configsByEnvironment as configsByEnvironment5,
1098
+ poaBridge,
1099
+ utils as utils9
1100
+ } from "@defuse-protocol/internal-utils";
1101
+ import TTLCache2 from "@isaacs/ttlcache";
1102
+
1103
+ // src/bridges/poa-bridge/poa-bridge-utils.ts
1104
+ import { utils as utils8 } from "@defuse-protocol/internal-utils";
1105
+ function createWithdrawIntentPrimitive4(params) {
1106
+ const { contractId: tokenAccountId } = utils8.parseDefuseAssetId(
786
1107
  params.assetId
787
1108
  );
788
1109
  return {
@@ -857,7 +1178,7 @@ function contractIdToCaip2(contractId) {
857
1178
  var PoaBridge = class {
858
1179
  constructor({ env }) {
859
1180
  // TTL cache for supported tokens with 30-second TTL
860
- this.supportedTokensCache = new TTLCache({ ttl: 30 * 1e3 });
1181
+ this.supportedTokensCache = new TTLCache2({ ttl: 30 * 1e3 });
861
1182
  this.env = env;
862
1183
  }
863
1184
  is(routeConfig) {
@@ -875,9 +1196,9 @@ var PoaBridge = class {
875
1196
  }
876
1197
  }
877
1198
  parseAssetId(assetId) {
878
- const parsed = utils7.parseDefuseAssetId(assetId);
1199
+ const parsed = utils9.parseDefuseAssetId(assetId);
879
1200
  if (parsed.contractId.endsWith(
880
- `.${configsByEnvironment4[this.env].poaTokenFactoryContractID}`
1201
+ `.${configsByEnvironment5[this.env].poaTokenFactoryContractID}`
881
1202
  )) {
882
1203
  return Object.assign(parsed, {
883
1204
  blockchain: contractIdToCaip2(parsed.contractId),
@@ -889,7 +1210,7 @@ var PoaBridge = class {
889
1210
  return null;
890
1211
  }
891
1212
  createWithdrawalIntents(args) {
892
- const intent = createWithdrawIntentPrimitive3({
1213
+ const intent = createWithdrawIntentPrimitive4({
893
1214
  ...args.withdrawalParams,
894
1215
  amount: args.withdrawalParams.amount + args.feeEstimation.amount,
895
1216
  destinationMemo: args.withdrawalParams.destinationMemo
@@ -904,7 +1225,7 @@ var PoaBridge = class {
904
1225
  */
905
1226
  async validateWithdrawal(args) {
906
1227
  const assetInfo = this.parseAssetId(args.assetId);
907
- assert8(assetInfo != null, "Asset is not supported");
1228
+ assert10(assetInfo != null, "Asset is not supported");
908
1229
  const { tokens } = await this.getCachedSupportedTokens(
909
1230
  [toPoaNetwork(assetInfo.blockchain)],
910
1231
  args.logger
@@ -925,16 +1246,16 @@ var PoaBridge = class {
925
1246
  }
926
1247
  async estimateWithdrawalFee(args) {
927
1248
  const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
928
- assert8(assetInfo != null, "Asset is not supported");
1249
+ assert10(assetInfo != null, "Asset is not supported");
929
1250
  const estimation = await poaBridge.httpClient.getWithdrawalEstimate(
930
1251
  {
931
- token: utils7.getTokenAccountId(args.withdrawalParams.assetId),
1252
+ token: utils9.getTokenAccountId(args.withdrawalParams.assetId),
932
1253
  address: args.withdrawalParams.destinationAddress,
933
1254
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
934
1255
  chain: toPoaNetwork(assetInfo.blockchain)
935
1256
  },
936
1257
  {
937
- baseURL: configsByEnvironment4[this.env].poaBridgeBaseURL,
1258
+ baseURL: configsByEnvironment5[this.env].poaBridgeBaseURL,
938
1259
  logger: args.logger
939
1260
  }
940
1261
  );
@@ -949,7 +1270,7 @@ var PoaBridge = class {
949
1270
  index: args.index,
950
1271
  signal: args.signal ?? new AbortController().signal,
951
1272
  retryOptions: args.retryOptions,
952
- baseURL: configsByEnvironment4[this.env].poaBridgeBaseURL,
1273
+ baseURL: configsByEnvironment5[this.env].poaBridgeBaseURL,
953
1274
  logger: args.logger
954
1275
  });
955
1276
  return { hash: withdrawalStatus.destinationTxHash };
@@ -967,7 +1288,7 @@ var PoaBridge = class {
967
1288
  const data = await poaBridge.httpClient.getSupportedTokens(
968
1289
  { chains },
969
1290
  {
970
- baseURL: configsByEnvironment4[this.env].poaBridgeBaseURL,
1291
+ baseURL: configsByEnvironment5[this.env].poaBridgeBaseURL,
971
1292
  logger
972
1293
  }
973
1294
  );
@@ -990,7 +1311,7 @@ var PUBLIC_STELLAR_RPC_URLS = {
990
1311
 
991
1312
  // src/intents/intent-executer-impl/intent-executer.ts
992
1313
  import {
993
- configsByEnvironment as configsByEnvironment5
1314
+ configsByEnvironment as configsByEnvironment6
994
1315
  } from "@defuse-protocol/internal-utils";
995
1316
 
996
1317
  // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
@@ -1372,7 +1693,7 @@ var IntentExecuter = class {
1372
1693
  relayParams: relayParamsFactory,
1373
1694
  ...intentParams
1374
1695
  }) {
1375
- const verifyingContract = configsByEnvironment5[this.env].contractID;
1696
+ const verifyingContract = configsByEnvironment6[this.env].contractID;
1376
1697
  let intentPayload = defaultIntentPayloadFactory({
1377
1698
  verifying_contract: verifyingContract,
1378
1699
  ...intentParams
@@ -1423,8 +1744,8 @@ async function mergeIntentPayloads(basePayload, intentPayloadFactory) {
1423
1744
 
1424
1745
  // src/intents/intent-relayer-impl/intent-relayer-public.ts
1425
1746
  import {
1426
- configsByEnvironment as configsByEnvironment6,
1427
- solverRelay as solverRelay4
1747
+ configsByEnvironment as configsByEnvironment7,
1748
+ solverRelay as solverRelay5
1428
1749
  } from "@defuse-protocol/internal-utils";
1429
1750
  var IntentRelayerPublic = class {
1430
1751
  constructor({ env }) {
@@ -1447,13 +1768,13 @@ var IntentRelayerPublic = class {
1447
1768
  multiPayloads,
1448
1769
  quoteHashes
1449
1770
  }, ctx = {}) {
1450
- const a = await solverRelay4.publishIntents(
1771
+ const a = await solverRelay5.publishIntents(
1451
1772
  {
1452
1773
  quote_hashes: quoteHashes,
1453
1774
  signed_datas: multiPayloads
1454
1775
  },
1455
1776
  {
1456
- baseURL: configsByEnvironment6[this.env].solverRelayBaseURL,
1777
+ baseURL: configsByEnvironment7[this.env].solverRelayBaseURL,
1457
1778
  logger: ctx.logger
1458
1779
  }
1459
1780
  );
@@ -1463,10 +1784,10 @@ var IntentRelayerPublic = class {
1463
1784
  throw a.unwrapErr();
1464
1785
  }
1465
1786
  async waitForSettlement(ticket, ctx = {}) {
1466
- const result = await solverRelay4.waitForIntentSettlement({
1787
+ const result = await solverRelay5.waitForIntentSettlement({
1467
1788
  intentHash: ticket,
1468
1789
  signal: new AbortController().signal,
1469
- baseURL: configsByEnvironment6[this.env].solverRelayBaseURL,
1790
+ baseURL: configsByEnvironment7[this.env].solverRelayBaseURL,
1470
1791
  logger: ctx.logger
1471
1792
  });
1472
1793
  return {
@@ -1474,7 +1795,7 @@ var IntentRelayerPublic = class {
1474
1795
  hash: result.txHash,
1475
1796
  // Usually relayer's account id is the verifying contract (`intents.near`),
1476
1797
  // but it is not set in stone and may change in the future.
1477
- accountId: configsByEnvironment6[this.env].contractID
1798
+ accountId: configsByEnvironment7[this.env].contractID
1478
1799
  }
1479
1800
  };
1480
1801
  }
@@ -1488,14 +1809,14 @@ var noopIntentSigner = {
1488
1809
  };
1489
1810
 
1490
1811
  // src/lib/array.ts
1491
- import { assert as assert9 } from "@defuse-protocol/internal-utils";
1812
+ import { assert as assert11 } from "@defuse-protocol/internal-utils";
1492
1813
  function zip(arr1, arr2) {
1493
- assert9(arr1.length === arr2.length, "Arrays must have the same length");
1814
+ assert11(arr1.length === arr2.length, "Arrays must have the same length");
1494
1815
  return arr1.map((v, i) => [v, arr2[i]]);
1495
1816
  }
1496
1817
 
1497
1818
  // src/lib/configure-rpc-config.ts
1498
- import { assert as assert10 } from "@defuse-protocol/internal-utils";
1819
+ import { assert as assert12 } from "@defuse-protocol/internal-utils";
1499
1820
 
1500
1821
  // src/lib/object.ts
1501
1822
  function pick(obj, keys) {
@@ -1519,7 +1840,7 @@ function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
1519
1840
  ).map(([caip2, urls]) => [getEIP155ChainId(caip2), urls])
1520
1841
  );
1521
1842
  for (const [chainId, urls] of Object.entries(evmRpcUrls)) {
1522
- assert10(
1843
+ assert12(
1523
1844
  urls.length > 0,
1524
1845
  `EVM RPC URLs for chain ${chainId} are not provided`
1525
1846
  );
@@ -1533,7 +1854,7 @@ function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
1533
1854
  userRpcUrls?.[Chains.Stellar] ?? {}
1534
1855
  );
1535
1856
  for (const [key, value] of Object.entries(stellarRpcUrls)) {
1536
- assert10(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
1857
+ assert12(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
1537
1858
  }
1538
1859
  return stellarRpcUrls;
1539
1860
  }
@@ -1545,6 +1866,9 @@ function createInternalTransferRoute() {
1545
1866
  function createNearWithdrawalRoute(msg) {
1546
1867
  return { route: RouteEnum.NearWithdrawal, msg };
1547
1868
  }
1869
+ function createOmniWithdrawalRoute() {
1870
+ return { route: RouteEnum.OmniBridge };
1871
+ }
1548
1872
  function createVirtualChainRoute(auroraEngineContractId, proxyTokenContractId) {
1549
1873
  return {
1550
1874
  route: RouteEnum.VirtualChain,
@@ -1585,6 +1909,8 @@ function determineRouteConfig(sdk, withdrawalParams) {
1585
1909
  route: RouteEnum.PoaBridge,
1586
1910
  chain: parseAssetId.blockchain
1587
1911
  };
1912
+ case BridgeNameEnum.Omni:
1913
+ return createOmniWithdrawalRoute();
1588
1914
  case BridgeNameEnum.None:
1589
1915
  return createNearWithdrawalRoute();
1590
1916
  default:
@@ -1599,7 +1925,7 @@ var IntentsSDK = class {
1599
1925
  this.env = args.env ?? "production";
1600
1926
  this.referral = args.referral;
1601
1927
  const nearRpcUrls = args.rpc?.[Chains.Near] ?? PUBLIC_NEAR_RPC_URLS;
1602
- assert11(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
1928
+ assert13(nearRpcUrls.length > 0, "NEAR RPC URLs are not provided");
1603
1929
  const nearProvider = nearFailoverRpcProvider({ urls: nearRpcUrls });
1604
1930
  const stellarRpcUrls = configureStellarRpcUrls(
1605
1931
  PUBLIC_STELLAR_RPC_URLS,
@@ -1632,6 +1958,10 @@ var IntentsSDK = class {
1632
1958
  }
1633
1959
  })
1634
1960
  }),
1961
+ new OmniBridge({
1962
+ env: this.env,
1963
+ nearProvider
1964
+ }),
1635
1965
  new DirectBridge({
1636
1966
  env: this.env,
1637
1967
  nearProvider
@@ -1651,6 +1981,7 @@ var IntentsSDK = class {
1651
1981
  assetId: args.withdrawalParams.assetId,
1652
1982
  amount: actualAmount,
1653
1983
  destinationAddress: args.withdrawalParams.destinationAddress,
1984
+ feeEstimation: args.feeEstimation,
1654
1985
  logger: args.logger
1655
1986
  });
1656
1987
  return bridge.createWithdrawalIntents({
@@ -1720,7 +2051,7 @@ var IntentsSDK = class {
1720
2051
  const routeConfig = determineRouteConfig(this, w);
1721
2052
  const route = routeConfig.route;
1722
2053
  const index = indexes.get(route);
1723
- assert11(index != null, "Index is not found for route");
2054
+ assert13(index != null, "Index is not found for route");
1724
2055
  indexes.set(route, index + 1);
1725
2056
  return {
1726
2057
  routeConfig,
@@ -1754,7 +2085,7 @@ var IntentsSDK = class {
1754
2085
  if (Array.isArray(args.withdrawalParams)) {
1755
2086
  return result;
1756
2087
  }
1757
- assert11(result.length === 1, "Unexpected result length");
2088
+ assert13(result.length === 1, "Unexpected result length");
1758
2089
  return result[0];
1759
2090
  }
1760
2091
  parseAssetId(assetId) {
@@ -1768,7 +2099,7 @@ var IntentsSDK = class {
1768
2099
  }
1769
2100
  async signAndSendIntent(args) {
1770
2101
  const intentSigner = args.signer ?? this.intentSigner;
1771
- assert11(intentSigner != null, "Intent signer is not provided");
2102
+ assert13(intentSigner != null, "Intent signer is not provided");
1772
2103
  const intentExecuter = new IntentExecuter({
1773
2104
  env: this.env,
1774
2105
  logger: args.logger,
@@ -1837,12 +2168,12 @@ var IntentsSDK = class {
1837
2168
  intentHash,
1838
2169
  logger
1839
2170
  }) {
1840
- return solverRelay5.getStatus(
2171
+ return solverRelay6.getStatus(
1841
2172
  {
1842
2173
  intent_hash: intentHash
1843
2174
  },
1844
2175
  {
1845
- baseURL: configsByEnvironment7[this.env].solverRelayBaseURL,
2176
+ baseURL: configsByEnvironment8[this.env].solverRelayBaseURL,
1846
2177
  logger
1847
2178
  }
1848
2179
  );
@@ -1873,7 +2204,7 @@ var IntentsSDK = class {
1873
2204
  withdrawalParams,
1874
2205
  intentTx,
1875
2206
  logger: args.logger,
1876
- retryOptions: RETRY_CONFIGS2.FIVE_MINS_STEADY
2207
+ retryOptions: RETRY_CONFIGS3.FIVE_MINS_STEADY
1877
2208
  });
1878
2209
  if (!Array.isArray(args.withdrawalParams)) {
1879
2210
  return {
@@ -1952,14 +2283,14 @@ var IntentSignerNearKeypair = class extends IntentSignerNEP413 {
1952
2283
  };
1953
2284
 
1954
2285
  // src/intents/intent-signer-impl/intent-signer-viem.ts
1955
- import { utils as utils8 } from "@defuse-protocol/internal-utils";
2286
+ import { utils as utils10 } from "@defuse-protocol/internal-utils";
1956
2287
  var IntentSignerViem = class {
1957
2288
  constructor(account) {
1958
2289
  this.account = account;
1959
2290
  }
1960
2291
  async signIntent(intent) {
1961
2292
  const payload = JSON.stringify({
1962
- signer_id: intent.signer_id ?? utils8.authHandleToIntentsUserId({
2293
+ signer_id: intent.signer_id ?? utils10.authHandleToIntentsUserId({
1963
2294
  identifier: this.account.address,
1964
2295
  method: "evm"
1965
2296
  }),
@@ -1977,7 +2308,7 @@ var IntentSignerViem = class {
1977
2308
  return {
1978
2309
  standard: "erc191",
1979
2310
  payload,
1980
- signature: utils8.transformERC191Signature(signature)
2311
+ signature: utils10.transformERC191Signature(signature)
1981
2312
  };
1982
2313
  }
1983
2314
  };
@@ -1995,7 +2326,7 @@ function createIntentSignerViem(config) {
1995
2326
 
1996
2327
  // index.ts
1997
2328
  import {
1998
- BaseError as BaseError3
2329
+ BaseError as BaseError4
1999
2330
  } from "@defuse-protocol/internal-utils";
2000
2331
  import {
2001
2332
  PoaWithdrawalInvariantError,
@@ -2017,7 +2348,7 @@ import {
2017
2348
  } from "@defuse-protocol/internal-utils";
2018
2349
  export {
2019
2350
  AssertionError,
2020
- BaseError3 as BaseError,
2351
+ BaseError4 as BaseError,
2021
2352
  BridgeNameEnum,
2022
2353
  Chains,
2023
2354
  FeeExceedsAmountError,