@sodax/sdk 1.3.1-beta-rc2 → 1.3.1-beta-rc3

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.cjs CHANGED
@@ -7963,7 +7963,7 @@ var spokeChainConfig = {
7963
7963
  },
7964
7964
  [BITCOIN_MAINNET_CHAIN_ID]: {
7965
7965
  addresses: {
7966
- assetManager: "bc1p4z9555xw0266vhq2x5un4zdmm9dt9zyet32fs7wa7u5ckdxusd9qsw4xfx"
7966
+ assetManager: "bc1pxguu2r4p9jcxp3gj7dh4r4jd9qzccwpyap3nj5nlapy28s76lhrqw522fz"
7967
7967
  },
7968
7968
  chain: baseChainInfo[BITCOIN_MAINNET_CHAIN_ID],
7969
7969
  bnUSD: "no",
@@ -7991,9 +7991,9 @@ var spokeChainConfig = {
7991
7991
  xChainId: BITCOIN_MAINNET_CHAIN_ID
7992
7992
  }
7993
7993
  },
7994
- radfiApiUrl: "https://staging.api.radfi.co/api",
7994
+ radfiApiUrl: "https://api.canary.radfi.co/api",
7995
7995
  radfiApiKey: "",
7996
- radfiUmsUrl: "https://staging.ums.radfi.co/api",
7996
+ radfiUmsUrl: "https://ums.radfi.co/api",
7997
7997
  network: "MAINNET",
7998
7998
  rpcUrl: "https://mempool.space/api"
7999
7999
  },
@@ -26654,6 +26654,26 @@ function isSolanaRawSpokeProviderConfig(value) {
26654
26654
  function isNearRawSpokeProviderConfig(value) {
26655
26655
  return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "NEAR";
26656
26656
  }
26657
+ function isSubmitSwapTxResponse(value) {
26658
+ return typeof value === "object" && value !== null && typeof value.success === "boolean" && typeof value.message === "string";
26659
+ }
26660
+ function isSubmitSwapTxStatusResponse(value) {
26661
+ if (typeof value !== "object" || value === null) return false;
26662
+ const obj = value;
26663
+ if (typeof obj.success !== "boolean") return false;
26664
+ if (typeof obj.data !== "object" || obj.data === null) return false;
26665
+ const data = obj.data;
26666
+ if (typeof data.txHash !== "string") return false;
26667
+ if (typeof data.srcChainId !== "string") return false;
26668
+ if (typeof data.status !== "string") return false;
26669
+ if (typeof data.failedAttempts !== "number") return false;
26670
+ if (data.result !== void 0) {
26671
+ if (typeof data.result !== "object" || data.result === null) return false;
26672
+ const result = data.result;
26673
+ if (typeof result.dstIntentTxHash !== "string") return false;
26674
+ }
26675
+ return true;
26676
+ }
26657
26677
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
26658
26678
  do {
26659
26679
  try {
@@ -26865,10 +26885,11 @@ var BackendApiService = class {
26865
26885
  * @returns Promise<T>
26866
26886
  */
26867
26887
  async makeRequest(endpoint, config) {
26868
- const url = `${this.baseURL}${endpoint}`;
26888
+ const url = config.baseURL ? `${config.baseURL}${endpoint}` : `${this.baseURL}${endpoint}`;
26869
26889
  const headers = { ...this.defaultHeaders, ...config.headers };
26870
26890
  const controller = new AbortController();
26871
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
26891
+ const timeout = config.timeout ?? this.timeout;
26892
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
26872
26893
  try {
26873
26894
  const response = await fetch(url, {
26874
26895
  method: config.method,
@@ -26887,7 +26908,7 @@ var BackendApiService = class {
26887
26908
  clearTimeout(timeoutId);
26888
26909
  if (error instanceof Error) {
26889
26910
  if (error.name === "AbortError") {
26890
- throw new Error(`Request timeout after ${this.timeout}ms`);
26911
+ throw new Error(`Request timeout after ${timeout}ms`);
26891
26912
  }
26892
26913
  console.error("[BackendApiService] Request error:", error.message);
26893
26914
  throw error;
@@ -26903,16 +26924,50 @@ var BackendApiService = class {
26903
26924
  * @param txHash - The intent created transaction hash from the hub chain
26904
26925
  * @returns Promise<IntentResponse>
26905
26926
  */
26906
- async getIntentByTxHash(txHash) {
26907
- return this.makeRequest(`/intent/tx/${txHash}`, { method: "GET" });
26927
+ async getIntentByTxHash(txHash, config) {
26928
+ return this.makeRequest(`/intent/tx/${txHash}`, { ...config, method: "GET" });
26908
26929
  }
26909
26930
  /**
26910
26931
  * Get intent details by intent hash
26911
26932
  * @param intentHash - Intent hash
26912
26933
  * @returns Promise<IntentResponse>
26913
26934
  */
26914
- async getIntentByHash(intentHash) {
26915
- return this.makeRequest(`/intent/${intentHash}`, { method: "GET" });
26935
+ async getIntentByHash(intentHash, config) {
26936
+ return this.makeRequest(`/intent/${intentHash}`, { ...config, method: "GET" });
26937
+ }
26938
+ // Swap submit-tx endpoints
26939
+ /**
26940
+ * Submit a swap transaction to be processed (relay, post execution to solver, etc.)
26941
+ * @param params - Swap transaction submission data
26942
+ * @returns Promise<SubmitSwapTxResponse>
26943
+ */
26944
+ async submitSwapTx(params, config) {
26945
+ const data = await this.makeRequest("/swaps/submit-tx", {
26946
+ ...config,
26947
+ method: "POST",
26948
+ body: JSON.stringify(params)
26949
+ });
26950
+ if (!isSubmitSwapTxResponse(data)) {
26951
+ throw new Error("Invalid submitSwapTx response: unexpected response shape");
26952
+ }
26953
+ return data;
26954
+ }
26955
+ /**
26956
+ * Get the processing status of a submitted swap transaction
26957
+ * @param params - Query parameters containing txHash and optional srcChainId
26958
+ * @returns Promise<SubmitSwapTxStatusResponse>
26959
+ */
26960
+ async getSubmitSwapTxStatus(params, config) {
26961
+ const queryParams = new URLSearchParams();
26962
+ queryParams.append("txHash", params.txHash);
26963
+ if (params.srcChainId) queryParams.append("srcChainId", params.srcChainId);
26964
+ const queryString = queryParams.toString();
26965
+ const endpoint = `/swaps/submit-tx/status?${queryString}`;
26966
+ const data = await this.makeRequest(endpoint, { ...config, method: "GET" });
26967
+ if (!isSubmitSwapTxStatusResponse(data)) {
26968
+ throw new Error("Invalid submitSwapTxStatus response: unexpected response shape");
26969
+ }
26970
+ return data;
26916
26971
  }
26917
26972
  // Solver endpoints
26918
26973
  /**
@@ -26920,13 +26975,13 @@ var BackendApiService = class {
26920
26975
  * @param params - Object containing offset and limit parameters for pagination
26921
26976
  * @returns Promise<OrderbookResponse>
26922
26977
  */
26923
- async getOrderbook(params) {
26978
+ async getOrderbook(params, config) {
26924
26979
  const queryParams = new URLSearchParams();
26925
26980
  queryParams.append("offset", params.offset);
26926
26981
  queryParams.append("limit", params.limit);
26927
26982
  const queryString = queryParams.toString();
26928
26983
  const endpoint = `/solver/orderbook?${queryString}`;
26929
- return this.makeRequest(endpoint, { method: "GET" });
26984
+ return this.makeRequest(endpoint, { ...config, method: "GET" });
26930
26985
  }
26931
26986
  /**
26932
26987
  * Get all intents created by a specific user address with optional filters.
@@ -26940,7 +26995,7 @@ var BackendApiService = class {
26940
26995
  *
26941
26996
  * @returns {Promise<UserIntentsResponse>} Promise resolving to an array of intent responses for the user.
26942
26997
  */
26943
- async getUserIntents(params) {
26998
+ async getUserIntents(params, config) {
26944
26999
  const { userAddress, startDate, endDate, limit, offset } = params;
26945
27000
  const queryParams = new URLSearchParams();
26946
27001
  if (startDate) queryParams.append("startDate", new Date(startDate).toISOString());
@@ -26949,7 +27004,7 @@ var BackendApiService = class {
26949
27004
  if (offset) queryParams.append("offset", offset);
26950
27005
  const queryString = queryParams.toString();
26951
27006
  const endpoint = queryString.length > 0 ? `/intent/user/${userAddress}?${queryString}` : `/intent/user/${userAddress}`;
26952
- return this.makeRequest(endpoint, { method: "GET" });
27007
+ return this.makeRequest(endpoint, { ...config, method: "GET" });
26953
27008
  }
26954
27009
  // Money Market endpoints
26955
27010
  /**
@@ -26957,23 +27012,23 @@ var BackendApiService = class {
26957
27012
  * @param userAddress - User's wallet address
26958
27013
  * @returns Promise<MoneyMarketPosition>
26959
27014
  */
26960
- async getMoneyMarketPosition(userAddress) {
26961
- return this.makeRequest(`/moneymarket/position/${userAddress}`, { method: "GET" });
27015
+ async getMoneyMarketPosition(userAddress, config) {
27016
+ return this.makeRequest(`/moneymarket/position/${userAddress}`, { ...config, method: "GET" });
26962
27017
  }
26963
27018
  /**
26964
27019
  * Get all money market assets
26965
27020
  * @returns Promise<MoneyMarketAsset[]>
26966
27021
  */
26967
- async getAllMoneyMarketAssets() {
26968
- return this.makeRequest("/moneymarket/asset/all", { method: "GET" });
27022
+ async getAllMoneyMarketAssets(config) {
27023
+ return this.makeRequest("/moneymarket/asset/all", { ...config, method: "GET" });
26969
27024
  }
26970
27025
  /**
26971
27026
  * Get specific money market asset details
26972
27027
  * @param reserveAddress - Reserve contract address
26973
27028
  * @returns Promise<MoneyMarketAsset>
26974
27029
  */
26975
- async getMoneyMarketAsset(reserveAddress) {
26976
- return this.makeRequest(`/moneymarket/asset/${reserveAddress}`, { method: "GET" });
27030
+ async getMoneyMarketAsset(reserveAddress, config) {
27031
+ return this.makeRequest(`/moneymarket/asset/${reserveAddress}`, { ...config, method: "GET" });
26977
27032
  }
26978
27033
  /**
26979
27034
  * Get borrowers for a specific money market asset
@@ -26981,13 +27036,13 @@ var BackendApiService = class {
26981
27036
  * @param params - Object containing offset and limit parameters for pagination
26982
27037
  * @returns Promise<MoneyMarketAssetBorrowers>
26983
27038
  */
26984
- async getMoneyMarketAssetBorrowers(reserveAddress, params) {
27039
+ async getMoneyMarketAssetBorrowers(reserveAddress, params, config) {
26985
27040
  const queryParams = new URLSearchParams();
26986
27041
  queryParams.append("offset", params.offset);
26987
27042
  queryParams.append("limit", params.limit);
26988
27043
  const queryString = queryParams.toString();
26989
27044
  const endpoint = `/moneymarket/asset/${reserveAddress}/borrowers?${queryString}`;
26990
- return this.makeRequest(endpoint, { method: "GET" });
27045
+ return this.makeRequest(endpoint, { ...config, method: "GET" });
26991
27046
  }
26992
27047
  /**
26993
27048
  * Get suppliers for a specific money market asset
@@ -26995,69 +27050,76 @@ var BackendApiService = class {
26995
27050
  * @param params - Object containing offset and limit parameters for pagination
26996
27051
  * @returns Promise<MoneyMarketAssetSuppliers>
26997
27052
  */
26998
- async getMoneyMarketAssetSuppliers(reserveAddress, params) {
27053
+ async getMoneyMarketAssetSuppliers(reserveAddress, params, config) {
26999
27054
  const queryParams = new URLSearchParams();
27000
27055
  queryParams.append("offset", params.offset);
27001
27056
  queryParams.append("limit", params.limit);
27002
27057
  const queryString = queryParams.toString();
27003
27058
  const endpoint = `/moneymarket/asset/${reserveAddress}/suppliers?${queryString}`;
27004
- return this.makeRequest(endpoint, { method: "GET" });
27059
+ return this.makeRequest(endpoint, { ...config, method: "GET" });
27005
27060
  }
27006
27061
  /**
27007
27062
  * Get all money market borrowers
27008
27063
  * @param params - Object containing offset and limit parameters for pagination
27009
27064
  * @returns Promise<MoneyMarketBorrowers>
27010
27065
  */
27011
- async getAllMoneyMarketBorrowers(params) {
27066
+ async getAllMoneyMarketBorrowers(params, config) {
27012
27067
  const queryParams = new URLSearchParams();
27013
27068
  queryParams.append("offset", params.offset);
27014
27069
  queryParams.append("limit", params.limit);
27015
27070
  const queryString = queryParams.toString();
27016
27071
  const endpoint = `/moneymarket/borrowers?${queryString}`;
27017
- return this.makeRequest(endpoint, { method: "GET" });
27072
+ return this.makeRequest(endpoint, { ...config, method: "GET" });
27018
27073
  }
27019
27074
  /**
27020
27075
  * Get all supported config
27021
27076
  * @returns Promise<GetAllConfigApiResponse>
27022
27077
  */
27023
- async getAllConfig() {
27024
- return this.makeRequest("/config/all", { method: "GET" });
27078
+ async getAllConfig(config) {
27079
+ return this.makeRequest("/config/all", { ...config, method: "GET" });
27025
27080
  }
27026
27081
  /**
27027
27082
  * Get all supported spoke chains
27028
27083
  * @returns Promise<GetChainsApiResponse>
27029
27084
  */
27030
- async getChains() {
27031
- return this.makeRequest("/config/spoke/chains", { method: "GET" });
27085
+ async getChains(config) {
27086
+ return this.makeRequest("/config/spoke/chains", { ...config, method: "GET" });
27032
27087
  }
27033
27088
  /**
27034
27089
  * Get all supported swap tokens
27035
27090
  * @returns Promise<GetSwapTokensApiResponse>
27036
27091
  */
27037
- async getSwapTokens() {
27038
- return this.makeRequest("/config/swap/tokens", { method: "GET" });
27092
+ async getSwapTokens(config) {
27093
+ return this.makeRequest("/config/swap/tokens", { ...config, method: "GET" });
27039
27094
  }
27040
27095
  /**
27041
27096
  * Get supported swap tokens for a specific spoke chain
27042
27097
  * @param chainId - Spoke chain id
27043
27098
  * @returns Promise<GetSwapTokensByChainIdApiResponse>
27044
27099
  */
27045
- async getSwapTokensByChainId(chainId) {
27046
- return this.makeRequest(`/config/swap/${chainId}/tokens`, { method: "GET" });
27100
+ async getSwapTokensByChainId(chainId, config) {
27101
+ return this.makeRequest(`/config/swap/${chainId}/tokens`, {
27102
+ ...config,
27103
+ method: "GET"
27104
+ });
27047
27105
  }
27048
27106
  /**
27049
27107
  * Get all supported money market tokens
27050
27108
  * @returns Promise<GetMoneyMarketTokensApiResponse>
27051
27109
  */
27052
- async getMoneyMarketTokens() {
27053
- return this.makeRequest("/config/money-market/tokens", { method: "GET" });
27110
+ async getMoneyMarketTokens(config) {
27111
+ return this.makeRequest("/config/money-market/tokens", {
27112
+ ...config,
27113
+ method: "GET"
27114
+ });
27054
27115
  }
27055
27116
  /**
27056
27117
  * Get all supported money market tokens
27057
27118
  * @returns Promise<GetMoneyMarketTokensApiResponse>
27058
27119
  */
27059
- async getMoneyMarketReserveAssets() {
27120
+ async getMoneyMarketReserveAssets(config) {
27060
27121
  return this.makeRequest("/config/money-market/reserve-assets", {
27122
+ ...config,
27061
27123
  method: "GET"
27062
27124
  });
27063
27125
  }
@@ -27066,8 +27128,9 @@ var BackendApiService = class {
27066
27128
  * @param chainId - Spoke chain id
27067
27129
  * @returns Promise<GetMoneyMarketTokensByChainIdApiResponse>
27068
27130
  */
27069
- async getMoneyMarketTokensByChainId(chainId) {
27131
+ async getMoneyMarketTokensByChainId(chainId, config) {
27070
27132
  return this.makeRequest(`/config/money-market/${chainId}/tokens`, {
27133
+ ...config,
27071
27134
  method: "GET"
27072
27135
  });
27073
27136
  }
@@ -27075,30 +27138,39 @@ var BackendApiService = class {
27075
27138
  * Get all supported hub assets (assets representing spoke token deposit)
27076
27139
  * @returns Promise<GetHubAssetsApiResponse>
27077
27140
  */
27078
- async getHubAssets() {
27079
- return this.makeRequest("/config/hub/assets", { method: "GET" });
27141
+ async getHubAssets(config) {
27142
+ return this.makeRequest("/config/hub/assets", { ...config, method: "GET" });
27080
27143
  }
27081
27144
  /**
27082
27145
  * Get supported hub assets (assets representing spoke token deposit) for a specific spoke chain
27083
27146
  * @param chainId - Spoke chain id
27084
27147
  * @returns Promise<GetHubAssetsByChainIdApiResponse>
27085
27148
  */
27086
- async getHubAssetsByChainId(chainId) {
27087
- return this.makeRequest(`/config/hub/${chainId}/assets`, { method: "GET" });
27149
+ async getHubAssetsByChainId(chainId, config) {
27150
+ return this.makeRequest(`/config/hub/${chainId}/assets`, {
27151
+ ...config,
27152
+ method: "GET"
27153
+ });
27088
27154
  }
27089
27155
  /**
27090
27156
  * Get the intent relay chain id map
27091
27157
  * @returns Promise<GetRelayChainIdMapApiResponse>
27092
27158
  */
27093
- async getRelayChainIdMap() {
27094
- return this.makeRequest("/config/relay/chain-id-map", { method: "GET" });
27159
+ async getRelayChainIdMap(config) {
27160
+ return this.makeRequest("/config/relay/chain-id-map", {
27161
+ ...config,
27162
+ method: "GET"
27163
+ });
27095
27164
  }
27096
27165
  /**
27097
27166
  * Get the spoke chain config
27098
27167
  * @returns Promise<GetSpokeChainConfigApiResponse>
27099
27168
  */
27100
- async getSpokeChainConfig() {
27101
- return this.makeRequest("/config/spoke/all-chains-configs", { method: "GET" });
27169
+ async getSpokeChainConfig(config) {
27170
+ return this.makeRequest("/config/spoke/all-chains-configs", {
27171
+ ...config,
27172
+ method: "GET"
27173
+ });
27102
27174
  }
27103
27175
  /**
27104
27176
  * Set custom headers for API requests
@@ -31235,6 +31307,8 @@ exports.isStellarRawSpokeProvider = isStellarRawSpokeProvider;
31235
31307
  exports.isStellarRawSpokeProviderConfig = isStellarRawSpokeProviderConfig;
31236
31308
  exports.isStellarSpokeProvider = isStellarSpokeProvider;
31237
31309
  exports.isStellarSpokeProviderType = isStellarSpokeProviderType;
31310
+ exports.isSubmitSwapTxResponse = isSubmitSwapTxResponse;
31311
+ exports.isSubmitSwapTxStatusResponse = isSubmitSwapTxStatusResponse;
31238
31312
  exports.isSuiRawSpokeProvider = isSuiRawSpokeProvider;
31239
31313
  exports.isSuiSpokeProvider = isSuiSpokeProvider;
31240
31314
  exports.isSuiSpokeProviderType = isSuiSpokeProviderType;