@sodax/sdk 2.3.0-rc.2 → 2.3.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.cjs CHANGED
@@ -5083,10 +5083,7 @@ var robinhoodSupportedTokens = {
5083
5083
  vault: SodaTokens.sodaUSDC.address
5084
5084
  },
5085
5085
  // Tokenized stocks, ETFs and commodity ETPs — Robinhood's own "<Company> •
5086
- // Robinhood Token" product. No dedicated Sonic vault exists for any of these
5087
- // yet, so `vault` mirrors `hubAsset` (same convention as the Solana xStock
5088
- // entries). DJT, GLD and RDDT are intentionally omitted — no Chainlink price
5089
- // feed exists for them, so the solver cannot price or swap them.
5086
+ // Robinhood Token" product. Each `vault` is that equity's Sonic vault in `SodaTokens`.
5090
5087
  SPCX: {
5091
5088
  symbol: "SPCX",
5092
5089
  isRwa: true,
@@ -6811,6 +6808,19 @@ var relayConfig = {
6811
6808
  };
6812
6809
 
6813
6810
  // ../types/dist/moneyMarket/moneyMarket.js
6811
+ var moneyMarketEquitySymbols = [
6812
+ "AAPL",
6813
+ "MSFT",
6814
+ "NVDA",
6815
+ "GOOGL",
6816
+ "AMZN",
6817
+ "META",
6818
+ "TSLA",
6819
+ "SPCX",
6820
+ "SPY",
6821
+ "QQQ",
6822
+ "GLD"
6823
+ ];
6814
6824
  var moneyMarketHubVaults = [
6815
6825
  SodaTokens.sodaBNB,
6816
6826
  SodaTokens.sodaAVAX,
@@ -6837,10 +6847,10 @@ var moneyMarketHubVaults = [
6837
6847
  SodaTokens.sodaKAIA,
6838
6848
  SodaTokens.sodaSTX,
6839
6849
  SodaTokens.sodaSUSDS,
6840
- SodaTokens.sodaHBAR,
6841
6850
  SodaTokens.sodaJITOSOL,
6842
6851
  SodaTokens.sodaUSDS,
6843
- SodaTokens.sodaUSSD
6852
+ SodaTokens.sodaUSSD,
6853
+ ...moneyMarketEquitySymbols.map((symbol) => SodaTokens[symbol])
6844
6854
  ];
6845
6855
  var moneyMarketSupportedTokens = {
6846
6856
  [ChainKeys.AVALANCHE_MAINNET]: [
@@ -6961,8 +6971,8 @@ var moneyMarketSupportedTokens = {
6961
6971
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.POL,
6962
6972
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.HYPE,
6963
6973
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.NEAR,
6964
- spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.HBAR,
6965
- spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.USDS
6974
+ spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.USDS,
6975
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens[symbol])
6966
6976
  ],
6967
6977
  [ChainKeys.SUI_MAINNET]: [
6968
6978
  spokeChainConfig[ChainKeys.SUI_MAINNET].supportedTokens.SUI,
@@ -7057,13 +7067,15 @@ var moneyMarketSupportedTokens = {
7057
7067
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.HYPE,
7058
7068
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.NEAR,
7059
7069
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.USDS,
7060
- spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.XLM
7070
+ spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.XLM,
7071
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens[symbol])
7061
7072
  ],
7062
7073
  [ChainKeys.ROBINHOOD_MAINNET]: [
7063
7074
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.ETH,
7064
7075
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.bnUSD,
7065
7076
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.SODA,
7066
- spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.USDG
7077
+ spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.USDG,
7078
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens[symbol])
7067
7079
  ]
7068
7080
  };
7069
7081
  var moneyMarketReserveAssets = [
@@ -8160,7 +8172,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
8160
8172
  }
8161
8173
 
8162
8174
  // ../types/dist/index.js
8163
- var CONFIG_VERSION = 2030002;
8175
+ var CONFIG_VERSION = 2030003;
8164
8176
  var RC_STABLE = 99;
8165
8177
  var MIN_CONFIG_VERSION = 1e6;
8166
8178
  var MAX_CONFIG_VERSION = 99999999;
@@ -34027,14 +34039,18 @@ var SwapService = class {
34027
34039
  * Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
34028
34040
  *
34029
34041
  * Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
34030
- * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
34031
- * {@link estimateSwapSpeedTier} for the rules.
34042
+ * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. RWA vaults
34043
+ * (tokenized stocks) are collateral-only reserves sourced through their own markets, so they never
34044
+ * count as sodaAssets. See {@link estimateSwapSpeedTier} for the rules.
34032
34045
  *
34033
34046
  * @param params `{ srcToken, dstToken }` spoke token pair to estimate
34034
34047
  * @returns the estimated `tier` bucket and `estimatedSeconds`
34035
34048
  */
34036
34049
  getSwapSpeedTier(params) {
34037
- return estimateSwapSpeedTier(params, (vault) => this.config.isMoneyMarketReserveAsset(vault));
34050
+ return estimateSwapSpeedTier(
34051
+ params,
34052
+ (vault) => this.config.isMoneyMarketReserveAsset(vault) && !isRealWorldAsset({ chainKey: HUB_CHAIN_KEY, address: vault })
34053
+ );
34038
34054
  }
34039
34055
  };
34040
34056
 
@@ -44780,6 +44796,11 @@ function formatBasisPoints(value) {
44780
44796
  }
44781
44797
 
44782
44798
  // src/moneyMarket/MoneyMarketService.ts
44799
+ var RESERVE_ACTIVE = 1n << 56n;
44800
+ var RESERVE_FROZEN = 1n << 57n;
44801
+ var RESERVE_BORROWING_ENABLED = 1n << 58n;
44802
+ var RESERVE_PAUSED = 1n << 60n;
44803
+ var isReserveBorrowable = (configuration) => (configuration & (RESERVE_ACTIVE | RESERVE_FROZEN | RESERVE_BORROWING_ENABLED | RESERVE_PAUSED)) === (RESERVE_ACTIVE | RESERVE_BORROWING_ENABLED);
44783
44804
  var MoneyMarketService = class _MoneyMarketService {
44784
44805
  // dependent services
44785
44806
  hubProvider;
@@ -45326,6 +45347,12 @@ var MoneyMarketService = class _MoneyMarketService {
45326
45347
  field: "token"
45327
45348
  });
45328
45349
  const encodedDstAddress = encodeAddress(dstChainKey, dstAddress);
45350
+ const { configuration } = await this.data.getReserveData(this.getBorrowReserve(dstToken.vault));
45351
+ mmInvariant(
45352
+ isReserveBorrowable(configuration),
45353
+ `${dstToken.symbol} cannot be borrowed: its money-market reserve is inactive, frozen, paused or has borrowing disabled`,
45354
+ { ...baseCtx, field: "token" }
45355
+ );
45329
45356
  const srcEffectiveAddress = isBitcoinChainKeyType(srcChainKey) ? await this.spoke.bitcoin.getEffectiveWalletAddress(params.srcAddress) : params.srcAddress;
45330
45357
  const fromHubWallet = await this.hubProvider.getUserHubWalletAddress(srcEffectiveAddress, srcChainKey);
45331
45358
  const payload = this.buildBorrowData(
@@ -45743,6 +45770,11 @@ var MoneyMarketService = class _MoneyMarketService {
45743
45770
  );
45744
45771
  return encodeContractCalls(calls);
45745
45772
  }
45773
+ /** The pool reserve a borrow of `vault` draws on: bnUSD is borrowed from its debt reserve, then wrapped into the vault. */
45774
+ getBorrowReserve(vault) {
45775
+ const { bnUSD, bnUSDVault } = this.config.moneyMarket;
45776
+ return vault.toLowerCase() === bnUSDVault.toLowerCase() ? bnUSD : vault;
45777
+ }
45746
45778
  /**
45747
45779
  * Encode the hub-side calldata for a borrow operation.
45748
45780
  *
@@ -45780,41 +45812,26 @@ var MoneyMarketService = class _MoneyMarketService {
45780
45812
  const lendingPool = this.config.moneyMarket.lendingPool;
45781
45813
  const translatedInAmount = EvmVaultTokenService.translateIncomingDecimals(toHubAsset.decimals, amount);
45782
45814
  const feeAmount = calculateFeeAmount(translatedInAmount, this.partnerFee);
45783
- const calls = [];
45815
+ const calls = [
45816
+ _MoneyMarketService.encodeBorrow(
45817
+ {
45818
+ asset: this.getBorrowReserve(vaultAddress),
45819
+ amount: translatedInAmount,
45820
+ interestRateMode: 2n,
45821
+ referralCode: 0,
45822
+ onBehalfOf: fromHubAddress
45823
+ },
45824
+ lendingPool
45825
+ )
45826
+ ];
45784
45827
  if (bnUSDVault.toLowerCase() === vaultAddress.toLowerCase()) {
45785
- calls.push(
45786
- _MoneyMarketService.encodeBorrow(
45787
- {
45788
- asset: bnUSD,
45789
- amount: translatedInAmount,
45790
- interestRateMode: 2n,
45791
- referralCode: 0,
45792
- onBehalfOf: fromHubAddress
45793
- },
45794
- lendingPool
45795
- )
45796
- );
45797
45828
  calls.push(Erc20Service.encodeApprove(bnUSD, bnUSDVault, translatedInAmount));
45798
45829
  calls.push(EvmVaultTokenService.encodeDeposit(bnUSDVault, bnUSD, translatedInAmount));
45799
45830
  if (this.partnerFee && feeAmount) {
45800
45831
  calls.push(Erc20Service.encodeTransfer(bnUSDVault, this.partnerFee.address, feeAmount));
45801
45832
  }
45802
- } else {
45803
- calls.push(
45804
- _MoneyMarketService.encodeBorrow(
45805
- {
45806
- asset: vaultAddress,
45807
- amount: translatedInAmount,
45808
- interestRateMode: 2n,
45809
- referralCode: 0,
45810
- onBehalfOf: fromHubAddress
45811
- },
45812
- lendingPool
45813
- )
45814
- );
45815
- if (this.partnerFee && feeAmount) {
45816
- calls.push(Erc20Service.encodeTransfer(vaultAddress, this.partnerFee.address, feeAmount));
45817
- }
45833
+ } else if (this.partnerFee && feeAmount) {
45834
+ calls.push(Erc20Service.encodeTransfer(vaultAddress, this.partnerFee.address, feeAmount));
45818
45835
  }
45819
45836
  if (!this.config.isSodaVaultHubAsset(assetAddress)) {
45820
45837
  calls.push(EvmVaultTokenService.encodeWithdraw(vaultAddress, assetAddress, translatedInAmount - feeAmount));
@@ -50607,10 +50624,8 @@ var Sodax = class {
50607
50624
  });
50608
50625
  }
50609
50626
  /**
50610
- * Initializes the Sodax instance with dynamic configuration.
50611
- * You should use this option if you do not want to update package versions when new chains and tokens are added.
50612
- * NOTE: Default configuration will be used if initialization fails.
50613
- * @param sodax - The Sodax instance to initialize.
50627
+ * Currently returns success without fetching backend config: chains and tokens stay those packaged with
50628
+ * this release, plus constructor overrides. For tokens listed later, use the `sodax.api.*` clients or upgrade.
50614
50629
  */
50615
50630
  async initialize() {
50616
50631
  return this.config.initialize();
package/dist/index.d.cts CHANGED
@@ -8840,7 +8840,8 @@ type ConfigServiceConstructorParams = {
8840
8840
  radfiSigner?: RadfiSigner;
8841
8841
  };
8842
8842
  /**
8843
- * ConfigApiService - Service for fetching configuration data from the backend API or fallbacking to default values
8843
+ * ConfigService - Holds the SDK config (packaged defaults merged with constructor overrides) and the lookups built
8844
+ * from it. `initialize()` does not fetch backend config yet, so supported chains and tokens are the packaged ones.
8844
8845
  */
8845
8846
  declare class ConfigService {
8846
8847
  private sodax;
@@ -13577,8 +13578,8 @@ declare const SPEED_TIER_THRESHOLDS: {
13577
13578
  * (sodaAsset)?". It is queried with `XToken.vault`, not `XToken.hubAsset`: the reserve set is
13578
13579
  * built from `moneyMarketHubVaults` addresses, so a hub asset only matches for the Sonic vault
13579
13580
  * shares themselves, where `hubAsset === vault`. In the service this is wired to
13580
- * `config.isMoneyMarketReserveAsset`. The predicate is injected so this function stays pure and
13581
- * unit-testable without a ConfigService.
13581
+ * `config.isMoneyMarketReserveAsset`, excluding RWA vaults (collateral-only reserves). The predicate
13582
+ * is injected so this function stays pure and unit-testable without a ConfigService.
13582
13583
  *
13583
13584
  * The fast 15s base applies when either token is sodaAsset-related; otherwise the base is 35s.
13584
13585
  */
@@ -14368,8 +14369,9 @@ declare class SwapService {
14368
14369
  * Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
14369
14370
  *
14370
14371
  * Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
14371
- * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
14372
- * {@link estimateSwapSpeedTier} for the rules.
14372
+ * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. RWA vaults
14373
+ * (tokenized stocks) are collateral-only reserves sourced through their own markets, so they never
14374
+ * count as sodaAssets. See {@link estimateSwapSpeedTier} for the rules.
14373
14375
  *
14374
14376
  * @param params `{ srcToken, dstToken }` spoke token pair to estimate
14375
14377
  * @returns the estimated `tier` bucket and `estimatedSeconds`
@@ -18084,6 +18086,8 @@ declare class MoneyMarketService {
18084
18086
  * @returns ABI-encoded multicall data ready to be sent to the hub wallet router.
18085
18087
  */
18086
18088
  buildSupplyData(srcChainKey: SpokeChainKey, fromToken: string, amount: bigint, toHubAddress: Address): Hex;
18089
+ /** The pool reserve a borrow of `vault` draws on: bnUSD is borrowed from its debt reserve, then wrapped into the vault. */
18090
+ private getBorrowReserve;
18087
18091
  /**
18088
18092
  * Encode the hub-side calldata for a borrow operation.
18089
18093
  *
@@ -20376,10 +20380,8 @@ declare class Sodax {
20376
20380
  readonly spoke: SpokeService;
20377
20381
  constructor(options?: SodaxOptions);
20378
20382
  /**
20379
- * Initializes the Sodax instance with dynamic configuration.
20380
- * You should use this option if you do not want to update package versions when new chains and tokens are added.
20381
- * NOTE: Default configuration will be used if initialization fails.
20382
- * @param sodax - The Sodax instance to initialize.
20383
+ * Currently returns success without fetching backend config: chains and tokens stay those packaged with
20384
+ * this release, plus constructor overrides. For tokens listed later, use the `sodax.api.*` clients or upgrade.
20383
20385
  */
20384
20386
  initialize(): Promise<Result<void>>;
20385
20387
  }
package/dist/index.d.ts CHANGED
@@ -8840,7 +8840,8 @@ type ConfigServiceConstructorParams = {
8840
8840
  radfiSigner?: RadfiSigner;
8841
8841
  };
8842
8842
  /**
8843
- * ConfigApiService - Service for fetching configuration data from the backend API or fallbacking to default values
8843
+ * ConfigService - Holds the SDK config (packaged defaults merged with constructor overrides) and the lookups built
8844
+ * from it. `initialize()` does not fetch backend config yet, so supported chains and tokens are the packaged ones.
8844
8845
  */
8845
8846
  declare class ConfigService {
8846
8847
  private sodax;
@@ -13577,8 +13578,8 @@ declare const SPEED_TIER_THRESHOLDS: {
13577
13578
  * (sodaAsset)?". It is queried with `XToken.vault`, not `XToken.hubAsset`: the reserve set is
13578
13579
  * built from `moneyMarketHubVaults` addresses, so a hub asset only matches for the Sonic vault
13579
13580
  * shares themselves, where `hubAsset === vault`. In the service this is wired to
13580
- * `config.isMoneyMarketReserveAsset`. The predicate is injected so this function stays pure and
13581
- * unit-testable without a ConfigService.
13581
+ * `config.isMoneyMarketReserveAsset`, excluding RWA vaults (collateral-only reserves). The predicate
13582
+ * is injected so this function stays pure and unit-testable without a ConfigService.
13582
13583
  *
13583
13584
  * The fast 15s base applies when either token is sodaAsset-related; otherwise the base is 35s.
13584
13585
  */
@@ -14368,8 +14369,9 @@ declare class SwapService {
14368
14369
  * Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
14369
14370
  *
14370
14371
  * Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
14371
- * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
14372
- * {@link estimateSwapSpeedTier} for the rules.
14372
+ * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. RWA vaults
14373
+ * (tokenized stocks) are collateral-only reserves sourced through their own markets, so they never
14374
+ * count as sodaAssets. See {@link estimateSwapSpeedTier} for the rules.
14373
14375
  *
14374
14376
  * @param params `{ srcToken, dstToken }` spoke token pair to estimate
14375
14377
  * @returns the estimated `tier` bucket and `estimatedSeconds`
@@ -18084,6 +18086,8 @@ declare class MoneyMarketService {
18084
18086
  * @returns ABI-encoded multicall data ready to be sent to the hub wallet router.
18085
18087
  */
18086
18088
  buildSupplyData(srcChainKey: SpokeChainKey, fromToken: string, amount: bigint, toHubAddress: Address): Hex;
18089
+ /** The pool reserve a borrow of `vault` draws on: bnUSD is borrowed from its debt reserve, then wrapped into the vault. */
18090
+ private getBorrowReserve;
18087
18091
  /**
18088
18092
  * Encode the hub-side calldata for a borrow operation.
18089
18093
  *
@@ -20376,10 +20380,8 @@ declare class Sodax {
20376
20380
  readonly spoke: SpokeService;
20377
20381
  constructor(options?: SodaxOptions);
20378
20382
  /**
20379
- * Initializes the Sodax instance with dynamic configuration.
20380
- * You should use this option if you do not want to update package versions when new chains and tokens are added.
20381
- * NOTE: Default configuration will be used if initialization fails.
20382
- * @param sodax - The Sodax instance to initialize.
20383
+ * Currently returns success without fetching backend config: chains and tokens stay those packaged with
20384
+ * this release, plus constructor overrides. For tokens listed later, use the `sodax.api.*` clients or upgrade.
20383
20385
  */
20384
20386
  initialize(): Promise<Result<void>>;
20385
20387
  }
package/dist/index.mjs CHANGED
@@ -5056,10 +5056,7 @@ var robinhoodSupportedTokens = {
5056
5056
  vault: SodaTokens.sodaUSDC.address
5057
5057
  },
5058
5058
  // Tokenized stocks, ETFs and commodity ETPs — Robinhood's own "<Company> •
5059
- // Robinhood Token" product. No dedicated Sonic vault exists for any of these
5060
- // yet, so `vault` mirrors `hubAsset` (same convention as the Solana xStock
5061
- // entries). DJT, GLD and RDDT are intentionally omitted — no Chainlink price
5062
- // feed exists for them, so the solver cannot price or swap them.
5059
+ // Robinhood Token" product. Each `vault` is that equity's Sonic vault in `SodaTokens`.
5063
5060
  SPCX: {
5064
5061
  symbol: "SPCX",
5065
5062
  isRwa: true,
@@ -6784,6 +6781,19 @@ var relayConfig = {
6784
6781
  };
6785
6782
 
6786
6783
  // ../types/dist/moneyMarket/moneyMarket.js
6784
+ var moneyMarketEquitySymbols = [
6785
+ "AAPL",
6786
+ "MSFT",
6787
+ "NVDA",
6788
+ "GOOGL",
6789
+ "AMZN",
6790
+ "META",
6791
+ "TSLA",
6792
+ "SPCX",
6793
+ "SPY",
6794
+ "QQQ",
6795
+ "GLD"
6796
+ ];
6787
6797
  var moneyMarketHubVaults = [
6788
6798
  SodaTokens.sodaBNB,
6789
6799
  SodaTokens.sodaAVAX,
@@ -6810,10 +6820,10 @@ var moneyMarketHubVaults = [
6810
6820
  SodaTokens.sodaKAIA,
6811
6821
  SodaTokens.sodaSTX,
6812
6822
  SodaTokens.sodaSUSDS,
6813
- SodaTokens.sodaHBAR,
6814
6823
  SodaTokens.sodaJITOSOL,
6815
6824
  SodaTokens.sodaUSDS,
6816
- SodaTokens.sodaUSSD
6825
+ SodaTokens.sodaUSSD,
6826
+ ...moneyMarketEquitySymbols.map((symbol) => SodaTokens[symbol])
6817
6827
  ];
6818
6828
  var moneyMarketSupportedTokens = {
6819
6829
  [ChainKeys.AVALANCHE_MAINNET]: [
@@ -6934,8 +6944,8 @@ var moneyMarketSupportedTokens = {
6934
6944
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.POL,
6935
6945
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.HYPE,
6936
6946
  spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.NEAR,
6937
- spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.HBAR,
6938
- spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.USDS
6947
+ spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens.USDS,
6948
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.STELLAR_MAINNET].supportedTokens[symbol])
6939
6949
  ],
6940
6950
  [ChainKeys.SUI_MAINNET]: [
6941
6951
  spokeChainConfig[ChainKeys.SUI_MAINNET].supportedTokens.SUI,
@@ -7030,13 +7040,15 @@ var moneyMarketSupportedTokens = {
7030
7040
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.HYPE,
7031
7041
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.NEAR,
7032
7042
  spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.USDS,
7033
- spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.XLM
7043
+ spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.XLM,
7044
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens[symbol])
7034
7045
  ],
7035
7046
  [ChainKeys.ROBINHOOD_MAINNET]: [
7036
7047
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.ETH,
7037
7048
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.bnUSD,
7038
7049
  spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.SODA,
7039
- spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.USDG
7050
+ spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.USDG,
7051
+ ...moneyMarketEquitySymbols.map((symbol) => spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens[symbol])
7040
7052
  ]
7041
7053
  };
7042
7054
  var moneyMarketReserveAssets = [
@@ -8133,7 +8145,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
8133
8145
  }
8134
8146
 
8135
8147
  // ../types/dist/index.js
8136
- var CONFIG_VERSION = 2030002;
8148
+ var CONFIG_VERSION = 2030003;
8137
8149
  var RC_STABLE = 99;
8138
8150
  var MIN_CONFIG_VERSION = 1e6;
8139
8151
  var MAX_CONFIG_VERSION = 99999999;
@@ -34000,14 +34012,18 @@ var SwapService = class {
34000
34012
  * Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
34001
34013
  *
34002
34014
  * Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
34003
- * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
34004
- * {@link estimateSwapSpeedTier} for the rules.
34015
+ * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. RWA vaults
34016
+ * (tokenized stocks) are collateral-only reserves sourced through their own markets, so they never
34017
+ * count as sodaAssets. See {@link estimateSwapSpeedTier} for the rules.
34005
34018
  *
34006
34019
  * @param params `{ srcToken, dstToken }` spoke token pair to estimate
34007
34020
  * @returns the estimated `tier` bucket and `estimatedSeconds`
34008
34021
  */
34009
34022
  getSwapSpeedTier(params) {
34010
- return estimateSwapSpeedTier(params, (vault) => this.config.isMoneyMarketReserveAsset(vault));
34023
+ return estimateSwapSpeedTier(
34024
+ params,
34025
+ (vault) => this.config.isMoneyMarketReserveAsset(vault) && !isRealWorldAsset({ chainKey: HUB_CHAIN_KEY, address: vault })
34026
+ );
34011
34027
  }
34012
34028
  };
34013
34029
 
@@ -44753,6 +44769,11 @@ function formatBasisPoints(value) {
44753
44769
  }
44754
44770
 
44755
44771
  // src/moneyMarket/MoneyMarketService.ts
44772
+ var RESERVE_ACTIVE = 1n << 56n;
44773
+ var RESERVE_FROZEN = 1n << 57n;
44774
+ var RESERVE_BORROWING_ENABLED = 1n << 58n;
44775
+ var RESERVE_PAUSED = 1n << 60n;
44776
+ var isReserveBorrowable = (configuration) => (configuration & (RESERVE_ACTIVE | RESERVE_FROZEN | RESERVE_BORROWING_ENABLED | RESERVE_PAUSED)) === (RESERVE_ACTIVE | RESERVE_BORROWING_ENABLED);
44756
44777
  var MoneyMarketService = class _MoneyMarketService {
44757
44778
  // dependent services
44758
44779
  hubProvider;
@@ -45299,6 +45320,12 @@ var MoneyMarketService = class _MoneyMarketService {
45299
45320
  field: "token"
45300
45321
  });
45301
45322
  const encodedDstAddress = encodeAddress(dstChainKey, dstAddress);
45323
+ const { configuration } = await this.data.getReserveData(this.getBorrowReserve(dstToken.vault));
45324
+ mmInvariant(
45325
+ isReserveBorrowable(configuration),
45326
+ `${dstToken.symbol} cannot be borrowed: its money-market reserve is inactive, frozen, paused or has borrowing disabled`,
45327
+ { ...baseCtx, field: "token" }
45328
+ );
45302
45329
  const srcEffectiveAddress = isBitcoinChainKeyType(srcChainKey) ? await this.spoke.bitcoin.getEffectiveWalletAddress(params.srcAddress) : params.srcAddress;
45303
45330
  const fromHubWallet = await this.hubProvider.getUserHubWalletAddress(srcEffectiveAddress, srcChainKey);
45304
45331
  const payload = this.buildBorrowData(
@@ -45716,6 +45743,11 @@ var MoneyMarketService = class _MoneyMarketService {
45716
45743
  );
45717
45744
  return encodeContractCalls(calls);
45718
45745
  }
45746
+ /** The pool reserve a borrow of `vault` draws on: bnUSD is borrowed from its debt reserve, then wrapped into the vault. */
45747
+ getBorrowReserve(vault) {
45748
+ const { bnUSD, bnUSDVault } = this.config.moneyMarket;
45749
+ return vault.toLowerCase() === bnUSDVault.toLowerCase() ? bnUSD : vault;
45750
+ }
45719
45751
  /**
45720
45752
  * Encode the hub-side calldata for a borrow operation.
45721
45753
  *
@@ -45753,41 +45785,26 @@ var MoneyMarketService = class _MoneyMarketService {
45753
45785
  const lendingPool = this.config.moneyMarket.lendingPool;
45754
45786
  const translatedInAmount = EvmVaultTokenService.translateIncomingDecimals(toHubAsset.decimals, amount);
45755
45787
  const feeAmount = calculateFeeAmount(translatedInAmount, this.partnerFee);
45756
- const calls = [];
45788
+ const calls = [
45789
+ _MoneyMarketService.encodeBorrow(
45790
+ {
45791
+ asset: this.getBorrowReserve(vaultAddress),
45792
+ amount: translatedInAmount,
45793
+ interestRateMode: 2n,
45794
+ referralCode: 0,
45795
+ onBehalfOf: fromHubAddress
45796
+ },
45797
+ lendingPool
45798
+ )
45799
+ ];
45757
45800
  if (bnUSDVault.toLowerCase() === vaultAddress.toLowerCase()) {
45758
- calls.push(
45759
- _MoneyMarketService.encodeBorrow(
45760
- {
45761
- asset: bnUSD,
45762
- amount: translatedInAmount,
45763
- interestRateMode: 2n,
45764
- referralCode: 0,
45765
- onBehalfOf: fromHubAddress
45766
- },
45767
- lendingPool
45768
- )
45769
- );
45770
45801
  calls.push(Erc20Service.encodeApprove(bnUSD, bnUSDVault, translatedInAmount));
45771
45802
  calls.push(EvmVaultTokenService.encodeDeposit(bnUSDVault, bnUSD, translatedInAmount));
45772
45803
  if (this.partnerFee && feeAmount) {
45773
45804
  calls.push(Erc20Service.encodeTransfer(bnUSDVault, this.partnerFee.address, feeAmount));
45774
45805
  }
45775
- } else {
45776
- calls.push(
45777
- _MoneyMarketService.encodeBorrow(
45778
- {
45779
- asset: vaultAddress,
45780
- amount: translatedInAmount,
45781
- interestRateMode: 2n,
45782
- referralCode: 0,
45783
- onBehalfOf: fromHubAddress
45784
- },
45785
- lendingPool
45786
- )
45787
- );
45788
- if (this.partnerFee && feeAmount) {
45789
- calls.push(Erc20Service.encodeTransfer(vaultAddress, this.partnerFee.address, feeAmount));
45790
- }
45806
+ } else if (this.partnerFee && feeAmount) {
45807
+ calls.push(Erc20Service.encodeTransfer(vaultAddress, this.partnerFee.address, feeAmount));
45791
45808
  }
45792
45809
  if (!this.config.isSodaVaultHubAsset(assetAddress)) {
45793
45810
  calls.push(EvmVaultTokenService.encodeWithdraw(vaultAddress, assetAddress, translatedInAmount - feeAmount));
@@ -50580,10 +50597,8 @@ var Sodax = class {
50580
50597
  });
50581
50598
  }
50582
50599
  /**
50583
- * Initializes the Sodax instance with dynamic configuration.
50584
- * You should use this option if you do not want to update package versions when new chains and tokens are added.
50585
- * NOTE: Default configuration will be used if initialization fails.
50586
- * @param sodax - The Sodax instance to initialize.
50600
+ * Currently returns success without fetching backend config: chains and tokens stay those packaged with
50601
+ * this release, plus constructor overrides. For tokens listed later, use the `sodax.api.*` clients or upgrade.
50587
50602
  */
50588
50603
  async initialize() {
50589
50604
  return this.config.initialize();
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "2.3.0-rc.2",
7
+ "version": "2.3.0-rc.3",
8
8
  "license": "MIT",
9
9
  "description": "Sodax SDK",
10
10
  "keywords": [
@@ -67,10 +67,10 @@
67
67
  "rlp": "3.0.0",
68
68
  "viem": "2.29.2",
69
69
  "valibot": "1.4.2",
70
- "@sodax/libs": "2.3.0-rc.2",
71
- "@sodax/swaps-api": "2.3.0-rc.2",
72
- "@sodax/bridge-api": "2.3.0-rc.2",
73
- "@sodax/types": "2.3.0-rc.2"
70
+ "@sodax/bridge-api": "2.3.0-rc.3",
71
+ "@sodax/libs": "2.3.0-rc.3",
72
+ "@sodax/swaps-api": "2.3.0-rc.3",
73
+ "@sodax/types": "2.3.0-rc.3"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@arethetypeswrong/cli": "0.17.4",