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