@sodax/sdk 1.0.0-rc.3 → 1.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { CHAIN_IDS, ICON_MAINNET_CHAIN_ID, spokeChainConfig, SUI_MAINNET_CHAIN_ID, STELLAR_MAINNET_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID, ETHEREUM_MAINNET_CHAIN_ID, LIGHTLINK_MAINNET_CHAIN_ID, HYPEREVM_MAINNET_CHAIN_ID, NIBIRU_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID, defaultSodaxConfig, hubChainConfig, getIntentRelayChainId, getMoneyMarketConfig, getSolverConfig, ChainIdToIntentRelayChainId } from '@sodax/types';
1
+ import { CHAIN_IDS, ICON_MAINNET_CHAIN_ID, spokeChainConfig, SUI_MAINNET_CHAIN_ID, STELLAR_MAINNET_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID, ETHEREUM_MAINNET_CHAIN_ID, LIGHTLINK_MAINNET_CHAIN_ID, HYPEREVM_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID, defaultSodaxConfig, CONFIG_VERSION, hubChainConfig, getIntentRelayChainId, getMoneyMarketConfig, getSolverConfig, ChainIdToIntentRelayChainId } from '@sodax/types';
2
2
  export * from '@sodax/types';
3
3
  import { getAbiItem, defineChain, encodeAbiParameters, parseAbiParameters, fromHex, toHex, encodeFunctionData, erc20Abi as erc20Abi$1, encodePacked, parseEventLogs, keccak256, createPublicClient, http, decodeAbiParameters, isAddress } from 'viem';
4
- import { mainnet, lightlinkPhoenix, nibiru, polygon, bsc, optimism, base, arbitrum, avalanche, sonic } from 'viem/chains';
4
+ import { mainnet, lightlinkPhoenix, polygon, bsc, optimism, base, arbitrum, avalanche, sonic } from 'viem/chains';
5
5
  import * as IconSdkRaw from 'icon-sdk-js';
6
6
  import { ChainGrpcWasmApi, TxGrpcApi, toBase64, fromBase64 } from '@injectivelabs/sdk-ts';
7
7
  import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
@@ -6792,8 +6792,6 @@ function getEvmViemChain(id) {
6792
6792
  return bsc;
6793
6793
  case POLYGON_MAINNET_CHAIN_ID:
6794
6794
  return polygon;
6795
- case NIBIRU_MAINNET_CHAIN_ID:
6796
- return nibiru;
6797
6795
  case HYPEREVM_MAINNET_CHAIN_ID:
6798
6796
  return hyper;
6799
6797
  case LIGHTLINK_MAINNET_CHAIN_ID:
@@ -6869,9 +6867,16 @@ var ConfigService = class {
6869
6867
  }
6870
6868
  async initialize() {
6871
6869
  try {
6872
- this.sodaxConfig = await this.backendApiService.getAllConfig();
6873
- this.loadSodaxConfigDataStructures(this.sodaxConfig);
6874
- this.initialized = true;
6870
+ const response = await this.backendApiService.getAllConfig();
6871
+ if (!response.version || response.version < CONFIG_VERSION) {
6872
+ console.warn(
6873
+ `Dynamic config version is less than the current version, resorting to the default one. Current version: ${CONFIG_VERSION}, response version: ${response.version}`
6874
+ );
6875
+ } else {
6876
+ this.sodaxConfig = response;
6877
+ this.loadSodaxConfigDataStructures(this.sodaxConfig);
6878
+ this.initialized = true;
6879
+ }
6875
6880
  return {
6876
6881
  ok: true,
6877
6882
  value: void 0
@@ -7971,6 +7976,29 @@ var EvmVaultTokenService = class {
7971
7976
  var Erc20Service = class {
7972
7977
  constructor() {
7973
7978
  }
7979
+ static async getErc20Token(token, publicClient) {
7980
+ const [name, symbol, decimals] = await publicClient.multicall({
7981
+ contracts: [
7982
+ {
7983
+ address: token,
7984
+ abi: erc20Abi$1,
7985
+ functionName: "name"
7986
+ },
7987
+ {
7988
+ address: token,
7989
+ abi: erc20Abi$1,
7990
+ functionName: "symbol"
7991
+ },
7992
+ {
7993
+ address: token,
7994
+ abi: erc20Abi$1,
7995
+ functionName: "decimals"
7996
+ }
7997
+ ],
7998
+ allowFailure: false
7999
+ });
8000
+ return { name, symbol, decimals, address: token };
8001
+ }
7974
8002
  /**
7975
8003
  * Check if spender has enough ERC20 allowance for given amount
7976
8004
  * @param token - ERC20 token address
@@ -9618,6 +9646,370 @@ function formatUserSummaryAndIncentives({
9618
9646
  calculatedUserIncentives
9619
9647
  };
9620
9648
  }
9649
+
9650
+ // src/shared/abis/erc20-bnusd.abi.ts
9651
+ var erc20BnusdAbi = [
9652
+ {
9653
+ inputs: [{ internalType: "address", name: "admin", type: "address" }],
9654
+ stateMutability: "nonpayable",
9655
+ type: "constructor"
9656
+ },
9657
+ {
9658
+ anonymous: false,
9659
+ inputs: [
9660
+ { indexed: true, internalType: "address", name: "owner", type: "address" },
9661
+ { indexed: true, internalType: "address", name: "spender", type: "address" },
9662
+ { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
9663
+ ],
9664
+ name: "Approval",
9665
+ type: "event"
9666
+ },
9667
+ {
9668
+ anonymous: false,
9669
+ inputs: [
9670
+ { indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
9671
+ { indexed: true, internalType: "bytes32", name: "label", type: "bytes32" },
9672
+ { indexed: false, internalType: "uint256", name: "bucketCapacity", type: "uint256" }
9673
+ ],
9674
+ name: "FacilitatorAdded",
9675
+ type: "event"
9676
+ },
9677
+ {
9678
+ anonymous: false,
9679
+ inputs: [
9680
+ { indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
9681
+ { indexed: false, internalType: "uint256", name: "oldCapacity", type: "uint256" },
9682
+ { indexed: false, internalType: "uint256", name: "newCapacity", type: "uint256" }
9683
+ ],
9684
+ name: "FacilitatorBucketCapacityUpdated",
9685
+ type: "event"
9686
+ },
9687
+ {
9688
+ anonymous: false,
9689
+ inputs: [
9690
+ { indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
9691
+ { indexed: false, internalType: "uint256", name: "oldLevel", type: "uint256" },
9692
+ { indexed: false, internalType: "uint256", name: "newLevel", type: "uint256" }
9693
+ ],
9694
+ name: "FacilitatorBucketLevelUpdated",
9695
+ type: "event"
9696
+ },
9697
+ {
9698
+ anonymous: false,
9699
+ inputs: [{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" }],
9700
+ name: "FacilitatorRemoved",
9701
+ type: "event"
9702
+ },
9703
+ {
9704
+ anonymous: false,
9705
+ inputs: [
9706
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
9707
+ { indexed: true, internalType: "bytes32", name: "previousAdminRole", type: "bytes32" },
9708
+ { indexed: true, internalType: "bytes32", name: "newAdminRole", type: "bytes32" }
9709
+ ],
9710
+ name: "RoleAdminChanged",
9711
+ type: "event"
9712
+ },
9713
+ {
9714
+ anonymous: false,
9715
+ inputs: [
9716
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
9717
+ { indexed: true, internalType: "address", name: "account", type: "address" },
9718
+ { indexed: true, internalType: "address", name: "sender", type: "address" }
9719
+ ],
9720
+ name: "RoleGranted",
9721
+ type: "event"
9722
+ },
9723
+ {
9724
+ anonymous: false,
9725
+ inputs: [
9726
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
9727
+ { indexed: true, internalType: "address", name: "account", type: "address" },
9728
+ { indexed: true, internalType: "address", name: "sender", type: "address" }
9729
+ ],
9730
+ name: "RoleRevoked",
9731
+ type: "event"
9732
+ },
9733
+ {
9734
+ anonymous: false,
9735
+ inputs: [
9736
+ { indexed: true, internalType: "address", name: "from", type: "address" },
9737
+ { indexed: true, internalType: "address", name: "to", type: "address" },
9738
+ { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
9739
+ ],
9740
+ name: "Transfer",
9741
+ type: "event"
9742
+ },
9743
+ {
9744
+ inputs: [],
9745
+ name: "BUCKET_MANAGER_ROLE",
9746
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9747
+ stateMutability: "view",
9748
+ type: "function"
9749
+ },
9750
+ {
9751
+ inputs: [],
9752
+ name: "DEFAULT_ADMIN_ROLE",
9753
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9754
+ stateMutability: "view",
9755
+ type: "function"
9756
+ },
9757
+ {
9758
+ inputs: [],
9759
+ name: "DOMAIN_SEPARATOR",
9760
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9761
+ stateMutability: "view",
9762
+ type: "function"
9763
+ },
9764
+ {
9765
+ inputs: [],
9766
+ name: "FACILITATOR_MANAGER_ROLE",
9767
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9768
+ stateMutability: "view",
9769
+ type: "function"
9770
+ },
9771
+ {
9772
+ inputs: [],
9773
+ name: "PERMIT_TYPEHASH",
9774
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9775
+ stateMutability: "view",
9776
+ type: "function"
9777
+ },
9778
+ {
9779
+ inputs: [
9780
+ { internalType: "address", name: "facilitatorAddress", type: "address" },
9781
+ { internalType: "string", name: "facilitatorLabel", type: "string" },
9782
+ { internalType: "uint128", name: "bucketCapacity", type: "uint128" }
9783
+ ],
9784
+ name: "addFacilitator",
9785
+ outputs: [],
9786
+ stateMutability: "nonpayable",
9787
+ type: "function"
9788
+ },
9789
+ {
9790
+ inputs: [
9791
+ { internalType: "address", name: "", type: "address" },
9792
+ { internalType: "address", name: "", type: "address" }
9793
+ ],
9794
+ name: "allowance",
9795
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
9796
+ stateMutability: "view",
9797
+ type: "function"
9798
+ },
9799
+ {
9800
+ inputs: [
9801
+ { internalType: "address", name: "spender", type: "address" },
9802
+ { internalType: "uint256", name: "amount", type: "uint256" }
9803
+ ],
9804
+ name: "approve",
9805
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
9806
+ stateMutability: "nonpayable",
9807
+ type: "function"
9808
+ },
9809
+ {
9810
+ inputs: [{ internalType: "address", name: "", type: "address" }],
9811
+ name: "balanceOf",
9812
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
9813
+ stateMutability: "view",
9814
+ type: "function"
9815
+ },
9816
+ {
9817
+ inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
9818
+ name: "burn",
9819
+ outputs: [],
9820
+ stateMutability: "nonpayable",
9821
+ type: "function"
9822
+ },
9823
+ {
9824
+ inputs: [],
9825
+ name: "decimals",
9826
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
9827
+ stateMutability: "view",
9828
+ type: "function"
9829
+ },
9830
+ {
9831
+ inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
9832
+ name: "getFacilitator",
9833
+ outputs: [
9834
+ {
9835
+ components: [
9836
+ { internalType: "uint128", name: "bucketCapacity", type: "uint128" },
9837
+ { internalType: "uint128", name: "bucketLevel", type: "uint128" },
9838
+ { internalType: "string", name: "label", type: "string" }
9839
+ ],
9840
+ internalType: "struct IGhoToken.Facilitator",
9841
+ name: "",
9842
+ type: "tuple"
9843
+ }
9844
+ ],
9845
+ stateMutability: "view",
9846
+ type: "function"
9847
+ },
9848
+ {
9849
+ inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
9850
+ name: "getFacilitatorBucket",
9851
+ outputs: [
9852
+ { internalType: "uint256", name: "", type: "uint256" },
9853
+ { internalType: "uint256", name: "", type: "uint256" }
9854
+ ],
9855
+ stateMutability: "view",
9856
+ type: "function"
9857
+ },
9858
+ {
9859
+ inputs: [],
9860
+ name: "getFacilitatorsList",
9861
+ outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
9862
+ stateMutability: "view",
9863
+ type: "function"
9864
+ },
9865
+ {
9866
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
9867
+ name: "getRoleAdmin",
9868
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
9869
+ stateMutability: "view",
9870
+ type: "function"
9871
+ },
9872
+ {
9873
+ inputs: [
9874
+ { internalType: "bytes32", name: "role", type: "bytes32" },
9875
+ { internalType: "address", name: "account", type: "address" }
9876
+ ],
9877
+ name: "grantRole",
9878
+ outputs: [],
9879
+ stateMutability: "nonpayable",
9880
+ type: "function"
9881
+ },
9882
+ {
9883
+ inputs: [
9884
+ { internalType: "bytes32", name: "role", type: "bytes32" },
9885
+ { internalType: "address", name: "account", type: "address" }
9886
+ ],
9887
+ name: "hasRole",
9888
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
9889
+ stateMutability: "view",
9890
+ type: "function"
9891
+ },
9892
+ {
9893
+ inputs: [
9894
+ { internalType: "address", name: "account", type: "address" },
9895
+ { internalType: "uint256", name: "amount", type: "uint256" }
9896
+ ],
9897
+ name: "mint",
9898
+ outputs: [],
9899
+ stateMutability: "nonpayable",
9900
+ type: "function"
9901
+ },
9902
+ {
9903
+ inputs: [],
9904
+ name: "name",
9905
+ outputs: [{ internalType: "string", name: "", type: "string" }],
9906
+ stateMutability: "view",
9907
+ type: "function"
9908
+ },
9909
+ {
9910
+ inputs: [{ internalType: "address", name: "", type: "address" }],
9911
+ name: "nonces",
9912
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
9913
+ stateMutability: "view",
9914
+ type: "function"
9915
+ },
9916
+ {
9917
+ inputs: [
9918
+ { internalType: "address", name: "owner", type: "address" },
9919
+ { internalType: "address", name: "spender", type: "address" },
9920
+ { internalType: "uint256", name: "value", type: "uint256" },
9921
+ { internalType: "uint256", name: "deadline", type: "uint256" },
9922
+ { internalType: "uint8", name: "v", type: "uint8" },
9923
+ { internalType: "bytes32", name: "r", type: "bytes32" },
9924
+ { internalType: "bytes32", name: "s", type: "bytes32" }
9925
+ ],
9926
+ name: "permit",
9927
+ outputs: [],
9928
+ stateMutability: "nonpayable",
9929
+ type: "function"
9930
+ },
9931
+ {
9932
+ inputs: [{ internalType: "address", name: "facilitatorAddress", type: "address" }],
9933
+ name: "removeFacilitator",
9934
+ outputs: [],
9935
+ stateMutability: "nonpayable",
9936
+ type: "function"
9937
+ },
9938
+ {
9939
+ inputs: [
9940
+ { internalType: "bytes32", name: "role", type: "bytes32" },
9941
+ { internalType: "address", name: "account", type: "address" }
9942
+ ],
9943
+ name: "renounceRole",
9944
+ outputs: [],
9945
+ stateMutability: "nonpayable",
9946
+ type: "function"
9947
+ },
9948
+ {
9949
+ inputs: [
9950
+ { internalType: "bytes32", name: "role", type: "bytes32" },
9951
+ { internalType: "address", name: "account", type: "address" }
9952
+ ],
9953
+ name: "revokeRole",
9954
+ outputs: [],
9955
+ stateMutability: "nonpayable",
9956
+ type: "function"
9957
+ },
9958
+ {
9959
+ inputs: [
9960
+ { internalType: "address", name: "facilitator", type: "address" },
9961
+ { internalType: "uint128", name: "newCapacity", type: "uint128" }
9962
+ ],
9963
+ name: "setFacilitatorBucketCapacity",
9964
+ outputs: [],
9965
+ stateMutability: "nonpayable",
9966
+ type: "function"
9967
+ },
9968
+ {
9969
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
9970
+ name: "supportsInterface",
9971
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
9972
+ stateMutability: "view",
9973
+ type: "function"
9974
+ },
9975
+ {
9976
+ inputs: [],
9977
+ name: "symbol",
9978
+ outputs: [{ internalType: "string", name: "", type: "string" }],
9979
+ stateMutability: "view",
9980
+ type: "function"
9981
+ },
9982
+ {
9983
+ inputs: [],
9984
+ name: "totalSupply",
9985
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
9986
+ stateMutability: "view",
9987
+ type: "function"
9988
+ },
9989
+ {
9990
+ inputs: [
9991
+ { internalType: "address", name: "to", type: "address" },
9992
+ { internalType: "uint256", name: "amount", type: "uint256" }
9993
+ ],
9994
+ name: "transfer",
9995
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
9996
+ stateMutability: "nonpayable",
9997
+ type: "function"
9998
+ },
9999
+ {
10000
+ inputs: [
10001
+ { internalType: "address", name: "from", type: "address" },
10002
+ { internalType: "address", name: "to", type: "address" },
10003
+ { internalType: "uint256", name: "amount", type: "uint256" }
10004
+ ],
10005
+ name: "transferFrom",
10006
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
10007
+ stateMutability: "nonpayable",
10008
+ type: "function"
10009
+ }
10010
+ ];
10011
+
10012
+ // src/moneyMarket/UiPoolDataProviderService.ts
9621
10013
  var UiPoolDataProviderService = class {
9622
10014
  hubProvider;
9623
10015
  uiPoolDataProvider;
@@ -9672,29 +10064,76 @@ var UiPoolDataProviderService = class {
9672
10064
  }
9673
10065
  /**
9674
10066
  * Get the list of all reserves in the pool
9675
- * @param uiPoolDataProvider - The address of the UI Pool Data Provider
9676
- * @param poolAddressesProvider - The address of the Pool Addresses Provider
10067
+ * @param unfiltered - If true, returns all reserves in the pool (including bnUSD (debt) reserve); if false (default), filters out bnUSD.
9677
10068
  * @returns {Promise<readonly Address[]>} - Array of reserve addresses
9678
10069
  */
9679
- async getReservesList() {
9680
- return this.hubProvider.publicClient.readContract({
10070
+ async getReservesList(unfiltered = false) {
10071
+ const reservesList = await this.hubProvider.publicClient.readContract({
9681
10072
  address: this.uiPoolDataProvider,
9682
10073
  abi: uiPoolDataAbi,
9683
10074
  functionName: "getReservesList",
9684
10075
  args: [this.poolAddressesProvider]
9685
10076
  });
10077
+ if (unfiltered) {
10078
+ return reservesList;
10079
+ }
10080
+ return reservesList.filter(
10081
+ (reserve) => reserve.toLowerCase() !== getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase()
10082
+ );
10083
+ }
10084
+ /**
10085
+ * @description Get the bnUSD facilitator bucket
10086
+ * @returns {Promise<readonly [bigint, bigint]>} - The bnUSD [cap, current borrowed]
10087
+ */
10088
+ async getBnusdFacilitatorBucket() {
10089
+ return this.hubProvider.publicClient.readContract({
10090
+ address: getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD,
10091
+ abi: erc20BnusdAbi,
10092
+ functionName: "getFacilitatorBucket",
10093
+ args: [getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDAToken]
10094
+ });
9686
10095
  }
9687
10096
  /**
9688
10097
  * Get detailed data for all reserves in the pool
9689
10098
  * @returns {Promise<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo]>} - Tuple containing array of reserve data and base currency info
9690
10099
  */
9691
10100
  async getReservesData() {
9692
- return this.hubProvider.publicClient.readContract({
9693
- address: this.uiPoolDataProvider,
9694
- abi: uiPoolDataAbi,
9695
- functionName: "getReservesData",
9696
- args: [this.poolAddressesProvider]
9697
- });
10101
+ const [reserveData, bnUSDFacilitatorBucket] = await Promise.all([
10102
+ this.hubProvider.publicClient.readContract({
10103
+ address: this.uiPoolDataProvider,
10104
+ abi: uiPoolDataAbi,
10105
+ functionName: "getReservesData",
10106
+ args: [this.poolAddressesProvider]
10107
+ }),
10108
+ this.getBnusdFacilitatorBucket()
10109
+ ]);
10110
+ const [cap, currentBorrowed] = bnUSDFacilitatorBucket;
10111
+ const reserves = reserveData[0];
10112
+ const baseCurrencyInfo = reserveData[1];
10113
+ const bnUSD = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
10114
+ const bnUSDVault = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
10115
+ const bnUSDReserve = reserves.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
10116
+ const bnUSDVaultReserve = reserves.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
10117
+ if (!bnUSDReserve || !bnUSDVaultReserve) {
10118
+ return reserveData;
10119
+ }
10120
+ const mergedBNUSDReserve = {
10121
+ ...bnUSDVaultReserve,
10122
+ borrowCap: cap,
10123
+ availableLiquidity: cap - currentBorrowed,
10124
+ totalScaledVariableDebt: bnUSDReserve.totalScaledVariableDebt + bnUSDVaultReserve.totalScaledVariableDebt,
10125
+ virtualUnderlyingBalance: bnUSDReserve.virtualUnderlyingBalance + bnUSDVaultReserve.virtualUnderlyingBalance,
10126
+ accruedToTreasury: bnUSDReserve.accruedToTreasury + bnUSDVaultReserve.accruedToTreasury
10127
+ };
10128
+ return [
10129
+ [
10130
+ mergedBNUSDReserve,
10131
+ ...reserves.filter(
10132
+ (r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
10133
+ )
10134
+ ],
10135
+ baseCurrencyInfo
10136
+ ];
9698
10137
  }
9699
10138
  /**
9700
10139
  * Get user-specific reserve data
@@ -9704,12 +10143,35 @@ var UiPoolDataProviderService = class {
9704
10143
  * @returns {Promise<readonly [readonly UserReserveData[], number]>} - Tuple containing array of user reserve data and eMode category ID
9705
10144
  */
9706
10145
  async getUserReservesData(userAddress) {
9707
- return this.hubProvider.publicClient.readContract({
10146
+ const userReserves = await this.hubProvider.publicClient.readContract({
9708
10147
  address: this.uiPoolDataProvider,
9709
10148
  abi: uiPoolDataAbi,
9710
10149
  functionName: "getUserReservesData",
9711
10150
  args: [this.poolAddressesProvider, userAddress]
9712
10151
  });
10152
+ const userReservesData = userReserves[0];
10153
+ const eModeCategoryId = userReserves[1];
10154
+ const bnUSD = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
10155
+ const bnUSDVault = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
10156
+ const bnUSDReserve = userReservesData.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
10157
+ const bnUSDVaultReserve = userReservesData.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
10158
+ if (!bnUSDReserve || !bnUSDVaultReserve) {
10159
+ return userReserves;
10160
+ }
10161
+ const mergedBNUSDReserve = {
10162
+ ...bnUSDVaultReserve,
10163
+ scaledATokenBalance: bnUSDReserve.scaledATokenBalance + bnUSDVaultReserve.scaledATokenBalance,
10164
+ scaledVariableDebt: bnUSDReserve.scaledVariableDebt + bnUSDVaultReserve.scaledVariableDebt
10165
+ };
10166
+ return [
10167
+ [
10168
+ mergedBNUSDReserve,
10169
+ ...userReservesData.filter(
10170
+ (r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
10171
+ )
10172
+ ],
10173
+ eModeCategoryId
10174
+ ];
9713
10175
  }
9714
10176
  /**
9715
10177
  * Get the reserves data humanized
@@ -9837,6 +10299,9 @@ var MoneyMarketDataService = class {
9837
10299
  this.uiPoolDataProviderService = new UiPoolDataProviderService(hubProvider);
9838
10300
  this.lendingPoolService = new LendingPoolService(hubProvider);
9839
10301
  }
10302
+ async getATokenData(aToken) {
10303
+ return Erc20Service.getErc20Token(aToken, this.hubProvider.publicClient);
10304
+ }
9840
10305
  /**
9841
10306
  * LendingPool
9842
10307
  */
@@ -9861,10 +10326,11 @@ var MoneyMarketDataService = class {
9861
10326
  */
9862
10327
  /**
9863
10328
  * Get the reserves list
10329
+ * @param unfiltered - If true, return the list of all reserves in the pool (including bnUSD (debt) reserve)
9864
10330
  * @returns {Promise<readonly Address[]>} - List of reserve asset addresses
9865
10331
  */
9866
- async getReservesList() {
9867
- return this.uiPoolDataProviderService.getReservesList();
10332
+ async getReservesList(unfiltered = false) {
10333
+ return this.uiPoolDataProviderService.getReservesList(unfiltered);
9868
10334
  }
9869
10335
  /**
9870
10336
  * Get the reserves data
@@ -10633,7 +11099,7 @@ var SwapService = class {
10633
11099
  * "token_dst_blockchain_id":"0xa4b1.arbitrum",
10634
11100
  * "amount":1000000000000000n,
10635
11101
  * "quote_type": "exact_input"
10636
- * } satisfies SolverIntentQuoteRequest
11102
+ * } satisfies SolverIntentQuoteRequest & OptionalFee
10637
11103
  *
10638
11104
  * const response = await swapService.getQuote(payload);
10639
11105
  *
@@ -10647,7 +11113,7 @@ var SwapService = class {
10647
11113
  async getQuote(payload) {
10648
11114
  payload = {
10649
11115
  ...payload,
10650
- amount: adjustAmountByFee(payload.amount, this.config.partnerFee, payload.quote_type)
11116
+ amount: adjustAmountByFee(payload.amount, payload.fee ?? this.config.partnerFee, payload.quote_type)
10651
11117
  };
10652
11118
  return SolverApiService.getQuote(payload, this.config, this.configService);
10653
11119
  }
@@ -14068,26 +14534,30 @@ var SolanaSpokeService = class _SolanaSpokeService {
14068
14534
  }
14069
14535
  return spokeProvider.walletProvider.sendTransaction(serializedTransaction);
14070
14536
  }
14071
- static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs = 6e4) {
14072
- const connection = new Connection(spokeProvider.chainConfig.rpcUrl, commitment);
14073
- const deadline = Date.now() + timeoutMs;
14074
- while (Date.now() < deadline) {
14075
- try {
14076
- const tx = await connection.getTransaction(signature, { commitment, maxSupportedTransactionVersion: 0 });
14077
- if (tx) {
14078
- if (tx.meta?.err) {
14079
- return { ok: false, error: new Error(JSON.stringify(tx.meta.err)) };
14537
+ static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs = 12e4) {
14538
+ try {
14539
+ const connection = new Connection(spokeProvider.chainConfig.rpcUrl, commitment);
14540
+ const deadline = Date.now() + timeoutMs;
14541
+ while (Date.now() < deadline) {
14542
+ try {
14543
+ const tx = await connection.getTransaction(signature, { commitment, maxSupportedTransactionVersion: 0 });
14544
+ if (tx) {
14545
+ if (tx.meta?.err) {
14546
+ return { ok: false, error: new Error(JSON.stringify(tx.meta.err)) };
14547
+ }
14548
+ return { ok: true, value: true };
14080
14549
  }
14081
- return { ok: true, value: true };
14550
+ } catch {
14082
14551
  }
14083
- } catch {
14552
+ await new Promise((r) => setTimeout(r, 750));
14084
14553
  }
14085
- await new Promise((r) => setTimeout(r, 750));
14554
+ return {
14555
+ ok: false,
14556
+ error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
14557
+ };
14558
+ } catch (error) {
14559
+ return { ok: false, error: new Error(`Failed to get transaction confirmation: ${JSON.stringify(error)}`) };
14086
14560
  }
14087
- return {
14088
- ok: false,
14089
- error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
14090
- };
14091
14561
  }
14092
14562
  };
14093
14563
  function isEvmHubChainConfig(value) {
@@ -14604,7 +15074,16 @@ var SpokeService = class _SpokeService {
14604
15074
  */
14605
15075
  static async verifyTxHash(txHash, spokeProvider) {
14606
15076
  if (isSolanaSpokeProvider(spokeProvider)) {
14607
- return SolanaSpokeService.waitForConfirmation(spokeProvider, txHash);
15077
+ const result = await SolanaSpokeService.waitForConfirmation(spokeProvider, txHash);
15078
+ if (!result.ok) {
15079
+ console.warn(`Solana verifyTxHash failed: ${result.error}`);
15080
+ console.warn("Returning true to assume transaction exists on chain in future ");
15081
+ return {
15082
+ ok: true,
15083
+ value: true
15084
+ };
15085
+ }
15086
+ return result;
14608
15087
  }
14609
15088
  if (isStellarSpokeProvider(spokeProvider)) {
14610
15089
  return StellarSpokeService.waitForTransaction(spokeProvider, txHash);