@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/README.md +37 -366
- package/dist/index.cjs +516 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.mjs +518 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6820,8 +6820,6 @@ function getEvmViemChain(id) {
|
|
|
6820
6820
|
return chains.bsc;
|
|
6821
6821
|
case types.POLYGON_MAINNET_CHAIN_ID:
|
|
6822
6822
|
return chains.polygon;
|
|
6823
|
-
case types.NIBIRU_MAINNET_CHAIN_ID:
|
|
6824
|
-
return chains.nibiru;
|
|
6825
6823
|
case types.HYPEREVM_MAINNET_CHAIN_ID:
|
|
6826
6824
|
return hyper;
|
|
6827
6825
|
case types.LIGHTLINK_MAINNET_CHAIN_ID:
|
|
@@ -6897,9 +6895,16 @@ var ConfigService = class {
|
|
|
6897
6895
|
}
|
|
6898
6896
|
async initialize() {
|
|
6899
6897
|
try {
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6898
|
+
const response = await this.backendApiService.getAllConfig();
|
|
6899
|
+
if (!response.version || response.version < types.CONFIG_VERSION) {
|
|
6900
|
+
console.warn(
|
|
6901
|
+
`Dynamic config version is less than the current version, resorting to the default one. Current version: ${types.CONFIG_VERSION}, response version: ${response.version}`
|
|
6902
|
+
);
|
|
6903
|
+
} else {
|
|
6904
|
+
this.sodaxConfig = response;
|
|
6905
|
+
this.loadSodaxConfigDataStructures(this.sodaxConfig);
|
|
6906
|
+
this.initialized = true;
|
|
6907
|
+
}
|
|
6903
6908
|
return {
|
|
6904
6909
|
ok: true,
|
|
6905
6910
|
value: void 0
|
|
@@ -7999,6 +8004,29 @@ var EvmVaultTokenService = class {
|
|
|
7999
8004
|
var Erc20Service = class {
|
|
8000
8005
|
constructor() {
|
|
8001
8006
|
}
|
|
8007
|
+
static async getErc20Token(token, publicClient) {
|
|
8008
|
+
const [name, symbol, decimals] = await publicClient.multicall({
|
|
8009
|
+
contracts: [
|
|
8010
|
+
{
|
|
8011
|
+
address: token,
|
|
8012
|
+
abi: viem.erc20Abi,
|
|
8013
|
+
functionName: "name"
|
|
8014
|
+
},
|
|
8015
|
+
{
|
|
8016
|
+
address: token,
|
|
8017
|
+
abi: viem.erc20Abi,
|
|
8018
|
+
functionName: "symbol"
|
|
8019
|
+
},
|
|
8020
|
+
{
|
|
8021
|
+
address: token,
|
|
8022
|
+
abi: viem.erc20Abi,
|
|
8023
|
+
functionName: "decimals"
|
|
8024
|
+
}
|
|
8025
|
+
],
|
|
8026
|
+
allowFailure: false
|
|
8027
|
+
});
|
|
8028
|
+
return { name, symbol, decimals, address: token };
|
|
8029
|
+
}
|
|
8002
8030
|
/**
|
|
8003
8031
|
* Check if spender has enough ERC20 allowance for given amount
|
|
8004
8032
|
* @param token - ERC20 token address
|
|
@@ -9646,6 +9674,370 @@ function formatUserSummaryAndIncentives({
|
|
|
9646
9674
|
calculatedUserIncentives
|
|
9647
9675
|
};
|
|
9648
9676
|
}
|
|
9677
|
+
|
|
9678
|
+
// src/shared/abis/erc20-bnusd.abi.ts
|
|
9679
|
+
var erc20BnusdAbi = [
|
|
9680
|
+
{
|
|
9681
|
+
inputs: [{ internalType: "address", name: "admin", type: "address" }],
|
|
9682
|
+
stateMutability: "nonpayable",
|
|
9683
|
+
type: "constructor"
|
|
9684
|
+
},
|
|
9685
|
+
{
|
|
9686
|
+
anonymous: false,
|
|
9687
|
+
inputs: [
|
|
9688
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
9689
|
+
{ indexed: true, internalType: "address", name: "spender", type: "address" },
|
|
9690
|
+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" }
|
|
9691
|
+
],
|
|
9692
|
+
name: "Approval",
|
|
9693
|
+
type: "event"
|
|
9694
|
+
},
|
|
9695
|
+
{
|
|
9696
|
+
anonymous: false,
|
|
9697
|
+
inputs: [
|
|
9698
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9699
|
+
{ indexed: true, internalType: "bytes32", name: "label", type: "bytes32" },
|
|
9700
|
+
{ indexed: false, internalType: "uint256", name: "bucketCapacity", type: "uint256" }
|
|
9701
|
+
],
|
|
9702
|
+
name: "FacilitatorAdded",
|
|
9703
|
+
type: "event"
|
|
9704
|
+
},
|
|
9705
|
+
{
|
|
9706
|
+
anonymous: false,
|
|
9707
|
+
inputs: [
|
|
9708
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9709
|
+
{ indexed: false, internalType: "uint256", name: "oldCapacity", type: "uint256" },
|
|
9710
|
+
{ indexed: false, internalType: "uint256", name: "newCapacity", type: "uint256" }
|
|
9711
|
+
],
|
|
9712
|
+
name: "FacilitatorBucketCapacityUpdated",
|
|
9713
|
+
type: "event"
|
|
9714
|
+
},
|
|
9715
|
+
{
|
|
9716
|
+
anonymous: false,
|
|
9717
|
+
inputs: [
|
|
9718
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9719
|
+
{ indexed: false, internalType: "uint256", name: "oldLevel", type: "uint256" },
|
|
9720
|
+
{ indexed: false, internalType: "uint256", name: "newLevel", type: "uint256" }
|
|
9721
|
+
],
|
|
9722
|
+
name: "FacilitatorBucketLevelUpdated",
|
|
9723
|
+
type: "event"
|
|
9724
|
+
},
|
|
9725
|
+
{
|
|
9726
|
+
anonymous: false,
|
|
9727
|
+
inputs: [{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" }],
|
|
9728
|
+
name: "FacilitatorRemoved",
|
|
9729
|
+
type: "event"
|
|
9730
|
+
},
|
|
9731
|
+
{
|
|
9732
|
+
anonymous: false,
|
|
9733
|
+
inputs: [
|
|
9734
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9735
|
+
{ indexed: true, internalType: "bytes32", name: "previousAdminRole", type: "bytes32" },
|
|
9736
|
+
{ indexed: true, internalType: "bytes32", name: "newAdminRole", type: "bytes32" }
|
|
9737
|
+
],
|
|
9738
|
+
name: "RoleAdminChanged",
|
|
9739
|
+
type: "event"
|
|
9740
|
+
},
|
|
9741
|
+
{
|
|
9742
|
+
anonymous: false,
|
|
9743
|
+
inputs: [
|
|
9744
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9745
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
9746
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
9747
|
+
],
|
|
9748
|
+
name: "RoleGranted",
|
|
9749
|
+
type: "event"
|
|
9750
|
+
},
|
|
9751
|
+
{
|
|
9752
|
+
anonymous: false,
|
|
9753
|
+
inputs: [
|
|
9754
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9755
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
9756
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
9757
|
+
],
|
|
9758
|
+
name: "RoleRevoked",
|
|
9759
|
+
type: "event"
|
|
9760
|
+
},
|
|
9761
|
+
{
|
|
9762
|
+
anonymous: false,
|
|
9763
|
+
inputs: [
|
|
9764
|
+
{ indexed: true, internalType: "address", name: "from", type: "address" },
|
|
9765
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
9766
|
+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" }
|
|
9767
|
+
],
|
|
9768
|
+
name: "Transfer",
|
|
9769
|
+
type: "event"
|
|
9770
|
+
},
|
|
9771
|
+
{
|
|
9772
|
+
inputs: [],
|
|
9773
|
+
name: "BUCKET_MANAGER_ROLE",
|
|
9774
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9775
|
+
stateMutability: "view",
|
|
9776
|
+
type: "function"
|
|
9777
|
+
},
|
|
9778
|
+
{
|
|
9779
|
+
inputs: [],
|
|
9780
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
9781
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9782
|
+
stateMutability: "view",
|
|
9783
|
+
type: "function"
|
|
9784
|
+
},
|
|
9785
|
+
{
|
|
9786
|
+
inputs: [],
|
|
9787
|
+
name: "DOMAIN_SEPARATOR",
|
|
9788
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9789
|
+
stateMutability: "view",
|
|
9790
|
+
type: "function"
|
|
9791
|
+
},
|
|
9792
|
+
{
|
|
9793
|
+
inputs: [],
|
|
9794
|
+
name: "FACILITATOR_MANAGER_ROLE",
|
|
9795
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9796
|
+
stateMutability: "view",
|
|
9797
|
+
type: "function"
|
|
9798
|
+
},
|
|
9799
|
+
{
|
|
9800
|
+
inputs: [],
|
|
9801
|
+
name: "PERMIT_TYPEHASH",
|
|
9802
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9803
|
+
stateMutability: "view",
|
|
9804
|
+
type: "function"
|
|
9805
|
+
},
|
|
9806
|
+
{
|
|
9807
|
+
inputs: [
|
|
9808
|
+
{ internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9809
|
+
{ internalType: "string", name: "facilitatorLabel", type: "string" },
|
|
9810
|
+
{ internalType: "uint128", name: "bucketCapacity", type: "uint128" }
|
|
9811
|
+
],
|
|
9812
|
+
name: "addFacilitator",
|
|
9813
|
+
outputs: [],
|
|
9814
|
+
stateMutability: "nonpayable",
|
|
9815
|
+
type: "function"
|
|
9816
|
+
},
|
|
9817
|
+
{
|
|
9818
|
+
inputs: [
|
|
9819
|
+
{ internalType: "address", name: "", type: "address" },
|
|
9820
|
+
{ internalType: "address", name: "", type: "address" }
|
|
9821
|
+
],
|
|
9822
|
+
name: "allowance",
|
|
9823
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9824
|
+
stateMutability: "view",
|
|
9825
|
+
type: "function"
|
|
9826
|
+
},
|
|
9827
|
+
{
|
|
9828
|
+
inputs: [
|
|
9829
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
9830
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9831
|
+
],
|
|
9832
|
+
name: "approve",
|
|
9833
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9834
|
+
stateMutability: "nonpayable",
|
|
9835
|
+
type: "function"
|
|
9836
|
+
},
|
|
9837
|
+
{
|
|
9838
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
9839
|
+
name: "balanceOf",
|
|
9840
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9841
|
+
stateMutability: "view",
|
|
9842
|
+
type: "function"
|
|
9843
|
+
},
|
|
9844
|
+
{
|
|
9845
|
+
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
|
|
9846
|
+
name: "burn",
|
|
9847
|
+
outputs: [],
|
|
9848
|
+
stateMutability: "nonpayable",
|
|
9849
|
+
type: "function"
|
|
9850
|
+
},
|
|
9851
|
+
{
|
|
9852
|
+
inputs: [],
|
|
9853
|
+
name: "decimals",
|
|
9854
|
+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
9855
|
+
stateMutability: "view",
|
|
9856
|
+
type: "function"
|
|
9857
|
+
},
|
|
9858
|
+
{
|
|
9859
|
+
inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
|
|
9860
|
+
name: "getFacilitator",
|
|
9861
|
+
outputs: [
|
|
9862
|
+
{
|
|
9863
|
+
components: [
|
|
9864
|
+
{ internalType: "uint128", name: "bucketCapacity", type: "uint128" },
|
|
9865
|
+
{ internalType: "uint128", name: "bucketLevel", type: "uint128" },
|
|
9866
|
+
{ internalType: "string", name: "label", type: "string" }
|
|
9867
|
+
],
|
|
9868
|
+
internalType: "struct IGhoToken.Facilitator",
|
|
9869
|
+
name: "",
|
|
9870
|
+
type: "tuple"
|
|
9871
|
+
}
|
|
9872
|
+
],
|
|
9873
|
+
stateMutability: "view",
|
|
9874
|
+
type: "function"
|
|
9875
|
+
},
|
|
9876
|
+
{
|
|
9877
|
+
inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
|
|
9878
|
+
name: "getFacilitatorBucket",
|
|
9879
|
+
outputs: [
|
|
9880
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
9881
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
9882
|
+
],
|
|
9883
|
+
stateMutability: "view",
|
|
9884
|
+
type: "function"
|
|
9885
|
+
},
|
|
9886
|
+
{
|
|
9887
|
+
inputs: [],
|
|
9888
|
+
name: "getFacilitatorsList",
|
|
9889
|
+
outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
|
|
9890
|
+
stateMutability: "view",
|
|
9891
|
+
type: "function"
|
|
9892
|
+
},
|
|
9893
|
+
{
|
|
9894
|
+
inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
|
|
9895
|
+
name: "getRoleAdmin",
|
|
9896
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9897
|
+
stateMutability: "view",
|
|
9898
|
+
type: "function"
|
|
9899
|
+
},
|
|
9900
|
+
{
|
|
9901
|
+
inputs: [
|
|
9902
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9903
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9904
|
+
],
|
|
9905
|
+
name: "grantRole",
|
|
9906
|
+
outputs: [],
|
|
9907
|
+
stateMutability: "nonpayable",
|
|
9908
|
+
type: "function"
|
|
9909
|
+
},
|
|
9910
|
+
{
|
|
9911
|
+
inputs: [
|
|
9912
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9913
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9914
|
+
],
|
|
9915
|
+
name: "hasRole",
|
|
9916
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9917
|
+
stateMutability: "view",
|
|
9918
|
+
type: "function"
|
|
9919
|
+
},
|
|
9920
|
+
{
|
|
9921
|
+
inputs: [
|
|
9922
|
+
{ internalType: "address", name: "account", type: "address" },
|
|
9923
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9924
|
+
],
|
|
9925
|
+
name: "mint",
|
|
9926
|
+
outputs: [],
|
|
9927
|
+
stateMutability: "nonpayable",
|
|
9928
|
+
type: "function"
|
|
9929
|
+
},
|
|
9930
|
+
{
|
|
9931
|
+
inputs: [],
|
|
9932
|
+
name: "name",
|
|
9933
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
9934
|
+
stateMutability: "view",
|
|
9935
|
+
type: "function"
|
|
9936
|
+
},
|
|
9937
|
+
{
|
|
9938
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
9939
|
+
name: "nonces",
|
|
9940
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9941
|
+
stateMutability: "view",
|
|
9942
|
+
type: "function"
|
|
9943
|
+
},
|
|
9944
|
+
{
|
|
9945
|
+
inputs: [
|
|
9946
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
9947
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
9948
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
9949
|
+
{ internalType: "uint256", name: "deadline", type: "uint256" },
|
|
9950
|
+
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
9951
|
+
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
9952
|
+
{ internalType: "bytes32", name: "s", type: "bytes32" }
|
|
9953
|
+
],
|
|
9954
|
+
name: "permit",
|
|
9955
|
+
outputs: [],
|
|
9956
|
+
stateMutability: "nonpayable",
|
|
9957
|
+
type: "function"
|
|
9958
|
+
},
|
|
9959
|
+
{
|
|
9960
|
+
inputs: [{ internalType: "address", name: "facilitatorAddress", type: "address" }],
|
|
9961
|
+
name: "removeFacilitator",
|
|
9962
|
+
outputs: [],
|
|
9963
|
+
stateMutability: "nonpayable",
|
|
9964
|
+
type: "function"
|
|
9965
|
+
},
|
|
9966
|
+
{
|
|
9967
|
+
inputs: [
|
|
9968
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9969
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9970
|
+
],
|
|
9971
|
+
name: "renounceRole",
|
|
9972
|
+
outputs: [],
|
|
9973
|
+
stateMutability: "nonpayable",
|
|
9974
|
+
type: "function"
|
|
9975
|
+
},
|
|
9976
|
+
{
|
|
9977
|
+
inputs: [
|
|
9978
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9979
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9980
|
+
],
|
|
9981
|
+
name: "revokeRole",
|
|
9982
|
+
outputs: [],
|
|
9983
|
+
stateMutability: "nonpayable",
|
|
9984
|
+
type: "function"
|
|
9985
|
+
},
|
|
9986
|
+
{
|
|
9987
|
+
inputs: [
|
|
9988
|
+
{ internalType: "address", name: "facilitator", type: "address" },
|
|
9989
|
+
{ internalType: "uint128", name: "newCapacity", type: "uint128" }
|
|
9990
|
+
],
|
|
9991
|
+
name: "setFacilitatorBucketCapacity",
|
|
9992
|
+
outputs: [],
|
|
9993
|
+
stateMutability: "nonpayable",
|
|
9994
|
+
type: "function"
|
|
9995
|
+
},
|
|
9996
|
+
{
|
|
9997
|
+
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
9998
|
+
name: "supportsInterface",
|
|
9999
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
10000
|
+
stateMutability: "view",
|
|
10001
|
+
type: "function"
|
|
10002
|
+
},
|
|
10003
|
+
{
|
|
10004
|
+
inputs: [],
|
|
10005
|
+
name: "symbol",
|
|
10006
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
10007
|
+
stateMutability: "view",
|
|
10008
|
+
type: "function"
|
|
10009
|
+
},
|
|
10010
|
+
{
|
|
10011
|
+
inputs: [],
|
|
10012
|
+
name: "totalSupply",
|
|
10013
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
10014
|
+
stateMutability: "view",
|
|
10015
|
+
type: "function"
|
|
10016
|
+
},
|
|
10017
|
+
{
|
|
10018
|
+
inputs: [
|
|
10019
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
10020
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
10021
|
+
],
|
|
10022
|
+
name: "transfer",
|
|
10023
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
10024
|
+
stateMutability: "nonpayable",
|
|
10025
|
+
type: "function"
|
|
10026
|
+
},
|
|
10027
|
+
{
|
|
10028
|
+
inputs: [
|
|
10029
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
10030
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
10031
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
10032
|
+
],
|
|
10033
|
+
name: "transferFrom",
|
|
10034
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
10035
|
+
stateMutability: "nonpayable",
|
|
10036
|
+
type: "function"
|
|
10037
|
+
}
|
|
10038
|
+
];
|
|
10039
|
+
|
|
10040
|
+
// src/moneyMarket/UiPoolDataProviderService.ts
|
|
9649
10041
|
var UiPoolDataProviderService = class {
|
|
9650
10042
|
hubProvider;
|
|
9651
10043
|
uiPoolDataProvider;
|
|
@@ -9700,29 +10092,76 @@ var UiPoolDataProviderService = class {
|
|
|
9700
10092
|
}
|
|
9701
10093
|
/**
|
|
9702
10094
|
* Get the list of all reserves in the pool
|
|
9703
|
-
* @param
|
|
9704
|
-
* @param poolAddressesProvider - The address of the Pool Addresses Provider
|
|
10095
|
+
* @param unfiltered - If true, returns all reserves in the pool (including bnUSD (debt) reserve); if false (default), filters out bnUSD.
|
|
9705
10096
|
* @returns {Promise<readonly Address[]>} - Array of reserve addresses
|
|
9706
10097
|
*/
|
|
9707
|
-
async getReservesList() {
|
|
9708
|
-
|
|
10098
|
+
async getReservesList(unfiltered = false) {
|
|
10099
|
+
const reservesList = await this.hubProvider.publicClient.readContract({
|
|
9709
10100
|
address: this.uiPoolDataProvider,
|
|
9710
10101
|
abi: uiPoolDataAbi,
|
|
9711
10102
|
functionName: "getReservesList",
|
|
9712
10103
|
args: [this.poolAddressesProvider]
|
|
9713
10104
|
});
|
|
10105
|
+
if (unfiltered) {
|
|
10106
|
+
return reservesList;
|
|
10107
|
+
}
|
|
10108
|
+
return reservesList.filter(
|
|
10109
|
+
(reserve) => reserve.toLowerCase() !== types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase()
|
|
10110
|
+
);
|
|
10111
|
+
}
|
|
10112
|
+
/**
|
|
10113
|
+
* @description Get the bnUSD facilitator bucket
|
|
10114
|
+
* @returns {Promise<readonly [bigint, bigint]>} - The bnUSD [cap, current borrowed]
|
|
10115
|
+
*/
|
|
10116
|
+
async getBnusdFacilitatorBucket() {
|
|
10117
|
+
return this.hubProvider.publicClient.readContract({
|
|
10118
|
+
address: types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD,
|
|
10119
|
+
abi: erc20BnusdAbi,
|
|
10120
|
+
functionName: "getFacilitatorBucket",
|
|
10121
|
+
args: [types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDAToken]
|
|
10122
|
+
});
|
|
9714
10123
|
}
|
|
9715
10124
|
/**
|
|
9716
10125
|
* Get detailed data for all reserves in the pool
|
|
9717
10126
|
* @returns {Promise<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo]>} - Tuple containing array of reserve data and base currency info
|
|
9718
10127
|
*/
|
|
9719
10128
|
async getReservesData() {
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
10129
|
+
const [reserveData, bnUSDFacilitatorBucket] = await Promise.all([
|
|
10130
|
+
this.hubProvider.publicClient.readContract({
|
|
10131
|
+
address: this.uiPoolDataProvider,
|
|
10132
|
+
abi: uiPoolDataAbi,
|
|
10133
|
+
functionName: "getReservesData",
|
|
10134
|
+
args: [this.poolAddressesProvider]
|
|
10135
|
+
}),
|
|
10136
|
+
this.getBnusdFacilitatorBucket()
|
|
10137
|
+
]);
|
|
10138
|
+
const [cap, currentBorrowed] = bnUSDFacilitatorBucket;
|
|
10139
|
+
const reserves = reserveData[0];
|
|
10140
|
+
const baseCurrencyInfo = reserveData[1];
|
|
10141
|
+
const bnUSD = types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
|
|
10142
|
+
const bnUSDVault = types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
|
|
10143
|
+
const bnUSDReserve = reserves.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
|
|
10144
|
+
const bnUSDVaultReserve = reserves.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
|
|
10145
|
+
if (!bnUSDReserve || !bnUSDVaultReserve) {
|
|
10146
|
+
return reserveData;
|
|
10147
|
+
}
|
|
10148
|
+
const mergedBNUSDReserve = {
|
|
10149
|
+
...bnUSDVaultReserve,
|
|
10150
|
+
borrowCap: cap,
|
|
10151
|
+
availableLiquidity: cap - currentBorrowed,
|
|
10152
|
+
totalScaledVariableDebt: bnUSDReserve.totalScaledVariableDebt + bnUSDVaultReserve.totalScaledVariableDebt,
|
|
10153
|
+
virtualUnderlyingBalance: bnUSDReserve.virtualUnderlyingBalance + bnUSDVaultReserve.virtualUnderlyingBalance,
|
|
10154
|
+
accruedToTreasury: bnUSDReserve.accruedToTreasury + bnUSDVaultReserve.accruedToTreasury
|
|
10155
|
+
};
|
|
10156
|
+
return [
|
|
10157
|
+
[
|
|
10158
|
+
mergedBNUSDReserve,
|
|
10159
|
+
...reserves.filter(
|
|
10160
|
+
(r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
|
|
10161
|
+
)
|
|
10162
|
+
],
|
|
10163
|
+
baseCurrencyInfo
|
|
10164
|
+
];
|
|
9726
10165
|
}
|
|
9727
10166
|
/**
|
|
9728
10167
|
* Get user-specific reserve data
|
|
@@ -9732,12 +10171,35 @@ var UiPoolDataProviderService = class {
|
|
|
9732
10171
|
* @returns {Promise<readonly [readonly UserReserveData[], number]>} - Tuple containing array of user reserve data and eMode category ID
|
|
9733
10172
|
*/
|
|
9734
10173
|
async getUserReservesData(userAddress) {
|
|
9735
|
-
|
|
10174
|
+
const userReserves = await this.hubProvider.publicClient.readContract({
|
|
9736
10175
|
address: this.uiPoolDataProvider,
|
|
9737
10176
|
abi: uiPoolDataAbi,
|
|
9738
10177
|
functionName: "getUserReservesData",
|
|
9739
10178
|
args: [this.poolAddressesProvider, userAddress]
|
|
9740
10179
|
});
|
|
10180
|
+
const userReservesData = userReserves[0];
|
|
10181
|
+
const eModeCategoryId = userReserves[1];
|
|
10182
|
+
const bnUSD = types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
|
|
10183
|
+
const bnUSDVault = types.getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
|
|
10184
|
+
const bnUSDReserve = userReservesData.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
|
|
10185
|
+
const bnUSDVaultReserve = userReservesData.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
|
|
10186
|
+
if (!bnUSDReserve || !bnUSDVaultReserve) {
|
|
10187
|
+
return userReserves;
|
|
10188
|
+
}
|
|
10189
|
+
const mergedBNUSDReserve = {
|
|
10190
|
+
...bnUSDVaultReserve,
|
|
10191
|
+
scaledATokenBalance: bnUSDReserve.scaledATokenBalance + bnUSDVaultReserve.scaledATokenBalance,
|
|
10192
|
+
scaledVariableDebt: bnUSDReserve.scaledVariableDebt + bnUSDVaultReserve.scaledVariableDebt
|
|
10193
|
+
};
|
|
10194
|
+
return [
|
|
10195
|
+
[
|
|
10196
|
+
mergedBNUSDReserve,
|
|
10197
|
+
...userReservesData.filter(
|
|
10198
|
+
(r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
|
|
10199
|
+
)
|
|
10200
|
+
],
|
|
10201
|
+
eModeCategoryId
|
|
10202
|
+
];
|
|
9741
10203
|
}
|
|
9742
10204
|
/**
|
|
9743
10205
|
* Get the reserves data humanized
|
|
@@ -9865,6 +10327,9 @@ var MoneyMarketDataService = class {
|
|
|
9865
10327
|
this.uiPoolDataProviderService = new UiPoolDataProviderService(hubProvider);
|
|
9866
10328
|
this.lendingPoolService = new LendingPoolService(hubProvider);
|
|
9867
10329
|
}
|
|
10330
|
+
async getATokenData(aToken) {
|
|
10331
|
+
return Erc20Service.getErc20Token(aToken, this.hubProvider.publicClient);
|
|
10332
|
+
}
|
|
9868
10333
|
/**
|
|
9869
10334
|
* LendingPool
|
|
9870
10335
|
*/
|
|
@@ -9889,10 +10354,11 @@ var MoneyMarketDataService = class {
|
|
|
9889
10354
|
*/
|
|
9890
10355
|
/**
|
|
9891
10356
|
* Get the reserves list
|
|
10357
|
+
* @param unfiltered - If true, return the list of all reserves in the pool (including bnUSD (debt) reserve)
|
|
9892
10358
|
* @returns {Promise<readonly Address[]>} - List of reserve asset addresses
|
|
9893
10359
|
*/
|
|
9894
|
-
async getReservesList() {
|
|
9895
|
-
return this.uiPoolDataProviderService.getReservesList();
|
|
10360
|
+
async getReservesList(unfiltered = false) {
|
|
10361
|
+
return this.uiPoolDataProviderService.getReservesList(unfiltered);
|
|
9896
10362
|
}
|
|
9897
10363
|
/**
|
|
9898
10364
|
* Get the reserves data
|
|
@@ -10661,7 +11127,7 @@ var SwapService = class {
|
|
|
10661
11127
|
* "token_dst_blockchain_id":"0xa4b1.arbitrum",
|
|
10662
11128
|
* "amount":1000000000000000n,
|
|
10663
11129
|
* "quote_type": "exact_input"
|
|
10664
|
-
* } satisfies SolverIntentQuoteRequest
|
|
11130
|
+
* } satisfies SolverIntentQuoteRequest & OptionalFee
|
|
10665
11131
|
*
|
|
10666
11132
|
* const response = await swapService.getQuote(payload);
|
|
10667
11133
|
*
|
|
@@ -10675,7 +11141,7 @@ var SwapService = class {
|
|
|
10675
11141
|
async getQuote(payload) {
|
|
10676
11142
|
payload = {
|
|
10677
11143
|
...payload,
|
|
10678
|
-
amount: adjustAmountByFee(payload.amount, this.config.partnerFee, payload.quote_type)
|
|
11144
|
+
amount: adjustAmountByFee(payload.amount, payload.fee ?? this.config.partnerFee, payload.quote_type)
|
|
10679
11145
|
};
|
|
10680
11146
|
return SolverApiService.getQuote(payload, this.config, this.configService);
|
|
10681
11147
|
}
|
|
@@ -14096,26 +14562,30 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
14096
14562
|
}
|
|
14097
14563
|
return spokeProvider.walletProvider.sendTransaction(serializedTransaction);
|
|
14098
14564
|
}
|
|
14099
|
-
static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs =
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
if (tx
|
|
14107
|
-
|
|
14565
|
+
static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs = 12e4) {
|
|
14566
|
+
try {
|
|
14567
|
+
const connection = new web3_js.Connection(spokeProvider.chainConfig.rpcUrl, commitment);
|
|
14568
|
+
const deadline = Date.now() + timeoutMs;
|
|
14569
|
+
while (Date.now() < deadline) {
|
|
14570
|
+
try {
|
|
14571
|
+
const tx = await connection.getTransaction(signature, { commitment, maxSupportedTransactionVersion: 0 });
|
|
14572
|
+
if (tx) {
|
|
14573
|
+
if (tx.meta?.err) {
|
|
14574
|
+
return { ok: false, error: new Error(JSON.stringify(tx.meta.err)) };
|
|
14575
|
+
}
|
|
14576
|
+
return { ok: true, value: true };
|
|
14108
14577
|
}
|
|
14109
|
-
|
|
14578
|
+
} catch {
|
|
14110
14579
|
}
|
|
14111
|
-
|
|
14580
|
+
await new Promise((r) => setTimeout(r, 750));
|
|
14112
14581
|
}
|
|
14113
|
-
|
|
14582
|
+
return {
|
|
14583
|
+
ok: false,
|
|
14584
|
+
error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
|
|
14585
|
+
};
|
|
14586
|
+
} catch (error) {
|
|
14587
|
+
return { ok: false, error: new Error(`Failed to get transaction confirmation: ${JSON.stringify(error)}`) };
|
|
14114
14588
|
}
|
|
14115
|
-
return {
|
|
14116
|
-
ok: false,
|
|
14117
|
-
error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
|
|
14118
|
-
};
|
|
14119
14589
|
}
|
|
14120
14590
|
};
|
|
14121
14591
|
function isEvmHubChainConfig(value) {
|
|
@@ -14632,7 +15102,16 @@ var SpokeService = class _SpokeService {
|
|
|
14632
15102
|
*/
|
|
14633
15103
|
static async verifyTxHash(txHash, spokeProvider) {
|
|
14634
15104
|
if (isSolanaSpokeProvider(spokeProvider)) {
|
|
14635
|
-
|
|
15105
|
+
const result = await SolanaSpokeService.waitForConfirmation(spokeProvider, txHash);
|
|
15106
|
+
if (!result.ok) {
|
|
15107
|
+
console.warn(`Solana verifyTxHash failed: ${result.error}`);
|
|
15108
|
+
console.warn("Returning true to assume transaction exists on chain in future ");
|
|
15109
|
+
return {
|
|
15110
|
+
ok: true,
|
|
15111
|
+
value: true
|
|
15112
|
+
};
|
|
15113
|
+
}
|
|
15114
|
+
return result;
|
|
14636
15115
|
}
|
|
14637
15116
|
if (isStellarSpokeProvider(spokeProvider)) {
|
|
14638
15117
|
return StellarSpokeService.waitForTransaction(spokeProvider, txHash);
|