@sodax/sdk 1.0.0-rc.2 → 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 +508 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -13
- package/dist/index.d.ts +21 -13
- package/dist/index.mjs +510 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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, LIGHTLINK_MAINNET_CHAIN_ID, HYPEREVM_MAINNET_CHAIN_ID,
|
|
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, 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 {
|
|
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,12 +6792,12 @@ 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:
|
|
6800
6798
|
return lightlinkPhoenix;
|
|
6799
|
+
case ETHEREUM_MAINNET_CHAIN_ID:
|
|
6800
|
+
return mainnet;
|
|
6801
6801
|
default:
|
|
6802
6802
|
throw new Error(`Unsupported EVM chain ID: ${id}`);
|
|
6803
6803
|
}
|
|
@@ -7969,6 +7969,29 @@ var EvmVaultTokenService = class {
|
|
|
7969
7969
|
var Erc20Service = class {
|
|
7970
7970
|
constructor() {
|
|
7971
7971
|
}
|
|
7972
|
+
static async getErc20Token(token, publicClient) {
|
|
7973
|
+
const [name, symbol, decimals] = await publicClient.multicall({
|
|
7974
|
+
contracts: [
|
|
7975
|
+
{
|
|
7976
|
+
address: token,
|
|
7977
|
+
abi: erc20Abi$1,
|
|
7978
|
+
functionName: "name"
|
|
7979
|
+
},
|
|
7980
|
+
{
|
|
7981
|
+
address: token,
|
|
7982
|
+
abi: erc20Abi$1,
|
|
7983
|
+
functionName: "symbol"
|
|
7984
|
+
},
|
|
7985
|
+
{
|
|
7986
|
+
address: token,
|
|
7987
|
+
abi: erc20Abi$1,
|
|
7988
|
+
functionName: "decimals"
|
|
7989
|
+
}
|
|
7990
|
+
],
|
|
7991
|
+
allowFailure: false
|
|
7992
|
+
});
|
|
7993
|
+
return { name, symbol, decimals, address: token };
|
|
7994
|
+
}
|
|
7972
7995
|
/**
|
|
7973
7996
|
* Check if spender has enough ERC20 allowance for given amount
|
|
7974
7997
|
* @param token - ERC20 token address
|
|
@@ -9616,6 +9639,370 @@ function formatUserSummaryAndIncentives({
|
|
|
9616
9639
|
calculatedUserIncentives
|
|
9617
9640
|
};
|
|
9618
9641
|
}
|
|
9642
|
+
|
|
9643
|
+
// src/shared/abis/erc20-bnusd.abi.ts
|
|
9644
|
+
var erc20BnusdAbi = [
|
|
9645
|
+
{
|
|
9646
|
+
inputs: [{ internalType: "address", name: "admin", type: "address" }],
|
|
9647
|
+
stateMutability: "nonpayable",
|
|
9648
|
+
type: "constructor"
|
|
9649
|
+
},
|
|
9650
|
+
{
|
|
9651
|
+
anonymous: false,
|
|
9652
|
+
inputs: [
|
|
9653
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
9654
|
+
{ indexed: true, internalType: "address", name: "spender", type: "address" },
|
|
9655
|
+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" }
|
|
9656
|
+
],
|
|
9657
|
+
name: "Approval",
|
|
9658
|
+
type: "event"
|
|
9659
|
+
},
|
|
9660
|
+
{
|
|
9661
|
+
anonymous: false,
|
|
9662
|
+
inputs: [
|
|
9663
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9664
|
+
{ indexed: true, internalType: "bytes32", name: "label", type: "bytes32" },
|
|
9665
|
+
{ indexed: false, internalType: "uint256", name: "bucketCapacity", type: "uint256" }
|
|
9666
|
+
],
|
|
9667
|
+
name: "FacilitatorAdded",
|
|
9668
|
+
type: "event"
|
|
9669
|
+
},
|
|
9670
|
+
{
|
|
9671
|
+
anonymous: false,
|
|
9672
|
+
inputs: [
|
|
9673
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9674
|
+
{ indexed: false, internalType: "uint256", name: "oldCapacity", type: "uint256" },
|
|
9675
|
+
{ indexed: false, internalType: "uint256", name: "newCapacity", type: "uint256" }
|
|
9676
|
+
],
|
|
9677
|
+
name: "FacilitatorBucketCapacityUpdated",
|
|
9678
|
+
type: "event"
|
|
9679
|
+
},
|
|
9680
|
+
{
|
|
9681
|
+
anonymous: false,
|
|
9682
|
+
inputs: [
|
|
9683
|
+
{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9684
|
+
{ indexed: false, internalType: "uint256", name: "oldLevel", type: "uint256" },
|
|
9685
|
+
{ indexed: false, internalType: "uint256", name: "newLevel", type: "uint256" }
|
|
9686
|
+
],
|
|
9687
|
+
name: "FacilitatorBucketLevelUpdated",
|
|
9688
|
+
type: "event"
|
|
9689
|
+
},
|
|
9690
|
+
{
|
|
9691
|
+
anonymous: false,
|
|
9692
|
+
inputs: [{ indexed: true, internalType: "address", name: "facilitatorAddress", type: "address" }],
|
|
9693
|
+
name: "FacilitatorRemoved",
|
|
9694
|
+
type: "event"
|
|
9695
|
+
},
|
|
9696
|
+
{
|
|
9697
|
+
anonymous: false,
|
|
9698
|
+
inputs: [
|
|
9699
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9700
|
+
{ indexed: true, internalType: "bytes32", name: "previousAdminRole", type: "bytes32" },
|
|
9701
|
+
{ indexed: true, internalType: "bytes32", name: "newAdminRole", type: "bytes32" }
|
|
9702
|
+
],
|
|
9703
|
+
name: "RoleAdminChanged",
|
|
9704
|
+
type: "event"
|
|
9705
|
+
},
|
|
9706
|
+
{
|
|
9707
|
+
anonymous: false,
|
|
9708
|
+
inputs: [
|
|
9709
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9710
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
9711
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
9712
|
+
],
|
|
9713
|
+
name: "RoleGranted",
|
|
9714
|
+
type: "event"
|
|
9715
|
+
},
|
|
9716
|
+
{
|
|
9717
|
+
anonymous: false,
|
|
9718
|
+
inputs: [
|
|
9719
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9720
|
+
{ indexed: true, internalType: "address", name: "account", type: "address" },
|
|
9721
|
+
{ indexed: true, internalType: "address", name: "sender", type: "address" }
|
|
9722
|
+
],
|
|
9723
|
+
name: "RoleRevoked",
|
|
9724
|
+
type: "event"
|
|
9725
|
+
},
|
|
9726
|
+
{
|
|
9727
|
+
anonymous: false,
|
|
9728
|
+
inputs: [
|
|
9729
|
+
{ indexed: true, internalType: "address", name: "from", type: "address" },
|
|
9730
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
9731
|
+
{ indexed: false, internalType: "uint256", name: "value", type: "uint256" }
|
|
9732
|
+
],
|
|
9733
|
+
name: "Transfer",
|
|
9734
|
+
type: "event"
|
|
9735
|
+
},
|
|
9736
|
+
{
|
|
9737
|
+
inputs: [],
|
|
9738
|
+
name: "BUCKET_MANAGER_ROLE",
|
|
9739
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9740
|
+
stateMutability: "view",
|
|
9741
|
+
type: "function"
|
|
9742
|
+
},
|
|
9743
|
+
{
|
|
9744
|
+
inputs: [],
|
|
9745
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
9746
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9747
|
+
stateMutability: "view",
|
|
9748
|
+
type: "function"
|
|
9749
|
+
},
|
|
9750
|
+
{
|
|
9751
|
+
inputs: [],
|
|
9752
|
+
name: "DOMAIN_SEPARATOR",
|
|
9753
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9754
|
+
stateMutability: "view",
|
|
9755
|
+
type: "function"
|
|
9756
|
+
},
|
|
9757
|
+
{
|
|
9758
|
+
inputs: [],
|
|
9759
|
+
name: "FACILITATOR_MANAGER_ROLE",
|
|
9760
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9761
|
+
stateMutability: "view",
|
|
9762
|
+
type: "function"
|
|
9763
|
+
},
|
|
9764
|
+
{
|
|
9765
|
+
inputs: [],
|
|
9766
|
+
name: "PERMIT_TYPEHASH",
|
|
9767
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9768
|
+
stateMutability: "view",
|
|
9769
|
+
type: "function"
|
|
9770
|
+
},
|
|
9771
|
+
{
|
|
9772
|
+
inputs: [
|
|
9773
|
+
{ internalType: "address", name: "facilitatorAddress", type: "address" },
|
|
9774
|
+
{ internalType: "string", name: "facilitatorLabel", type: "string" },
|
|
9775
|
+
{ internalType: "uint128", name: "bucketCapacity", type: "uint128" }
|
|
9776
|
+
],
|
|
9777
|
+
name: "addFacilitator",
|
|
9778
|
+
outputs: [],
|
|
9779
|
+
stateMutability: "nonpayable",
|
|
9780
|
+
type: "function"
|
|
9781
|
+
},
|
|
9782
|
+
{
|
|
9783
|
+
inputs: [
|
|
9784
|
+
{ internalType: "address", name: "", type: "address" },
|
|
9785
|
+
{ internalType: "address", name: "", type: "address" }
|
|
9786
|
+
],
|
|
9787
|
+
name: "allowance",
|
|
9788
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9789
|
+
stateMutability: "view",
|
|
9790
|
+
type: "function"
|
|
9791
|
+
},
|
|
9792
|
+
{
|
|
9793
|
+
inputs: [
|
|
9794
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
9795
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9796
|
+
],
|
|
9797
|
+
name: "approve",
|
|
9798
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9799
|
+
stateMutability: "nonpayable",
|
|
9800
|
+
type: "function"
|
|
9801
|
+
},
|
|
9802
|
+
{
|
|
9803
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
9804
|
+
name: "balanceOf",
|
|
9805
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9806
|
+
stateMutability: "view",
|
|
9807
|
+
type: "function"
|
|
9808
|
+
},
|
|
9809
|
+
{
|
|
9810
|
+
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
|
|
9811
|
+
name: "burn",
|
|
9812
|
+
outputs: [],
|
|
9813
|
+
stateMutability: "nonpayable",
|
|
9814
|
+
type: "function"
|
|
9815
|
+
},
|
|
9816
|
+
{
|
|
9817
|
+
inputs: [],
|
|
9818
|
+
name: "decimals",
|
|
9819
|
+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
9820
|
+
stateMutability: "view",
|
|
9821
|
+
type: "function"
|
|
9822
|
+
},
|
|
9823
|
+
{
|
|
9824
|
+
inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
|
|
9825
|
+
name: "getFacilitator",
|
|
9826
|
+
outputs: [
|
|
9827
|
+
{
|
|
9828
|
+
components: [
|
|
9829
|
+
{ internalType: "uint128", name: "bucketCapacity", type: "uint128" },
|
|
9830
|
+
{ internalType: "uint128", name: "bucketLevel", type: "uint128" },
|
|
9831
|
+
{ internalType: "string", name: "label", type: "string" }
|
|
9832
|
+
],
|
|
9833
|
+
internalType: "struct IGhoToken.Facilitator",
|
|
9834
|
+
name: "",
|
|
9835
|
+
type: "tuple"
|
|
9836
|
+
}
|
|
9837
|
+
],
|
|
9838
|
+
stateMutability: "view",
|
|
9839
|
+
type: "function"
|
|
9840
|
+
},
|
|
9841
|
+
{
|
|
9842
|
+
inputs: [{ internalType: "address", name: "facilitator", type: "address" }],
|
|
9843
|
+
name: "getFacilitatorBucket",
|
|
9844
|
+
outputs: [
|
|
9845
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
9846
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
9847
|
+
],
|
|
9848
|
+
stateMutability: "view",
|
|
9849
|
+
type: "function"
|
|
9850
|
+
},
|
|
9851
|
+
{
|
|
9852
|
+
inputs: [],
|
|
9853
|
+
name: "getFacilitatorsList",
|
|
9854
|
+
outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
|
|
9855
|
+
stateMutability: "view",
|
|
9856
|
+
type: "function"
|
|
9857
|
+
},
|
|
9858
|
+
{
|
|
9859
|
+
inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
|
|
9860
|
+
name: "getRoleAdmin",
|
|
9861
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
9862
|
+
stateMutability: "view",
|
|
9863
|
+
type: "function"
|
|
9864
|
+
},
|
|
9865
|
+
{
|
|
9866
|
+
inputs: [
|
|
9867
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9868
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9869
|
+
],
|
|
9870
|
+
name: "grantRole",
|
|
9871
|
+
outputs: [],
|
|
9872
|
+
stateMutability: "nonpayable",
|
|
9873
|
+
type: "function"
|
|
9874
|
+
},
|
|
9875
|
+
{
|
|
9876
|
+
inputs: [
|
|
9877
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9878
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9879
|
+
],
|
|
9880
|
+
name: "hasRole",
|
|
9881
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9882
|
+
stateMutability: "view",
|
|
9883
|
+
type: "function"
|
|
9884
|
+
},
|
|
9885
|
+
{
|
|
9886
|
+
inputs: [
|
|
9887
|
+
{ internalType: "address", name: "account", type: "address" },
|
|
9888
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9889
|
+
],
|
|
9890
|
+
name: "mint",
|
|
9891
|
+
outputs: [],
|
|
9892
|
+
stateMutability: "nonpayable",
|
|
9893
|
+
type: "function"
|
|
9894
|
+
},
|
|
9895
|
+
{
|
|
9896
|
+
inputs: [],
|
|
9897
|
+
name: "name",
|
|
9898
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
9899
|
+
stateMutability: "view",
|
|
9900
|
+
type: "function"
|
|
9901
|
+
},
|
|
9902
|
+
{
|
|
9903
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
9904
|
+
name: "nonces",
|
|
9905
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9906
|
+
stateMutability: "view",
|
|
9907
|
+
type: "function"
|
|
9908
|
+
},
|
|
9909
|
+
{
|
|
9910
|
+
inputs: [
|
|
9911
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
9912
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
9913
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
9914
|
+
{ internalType: "uint256", name: "deadline", type: "uint256" },
|
|
9915
|
+
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
9916
|
+
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
9917
|
+
{ internalType: "bytes32", name: "s", type: "bytes32" }
|
|
9918
|
+
],
|
|
9919
|
+
name: "permit",
|
|
9920
|
+
outputs: [],
|
|
9921
|
+
stateMutability: "nonpayable",
|
|
9922
|
+
type: "function"
|
|
9923
|
+
},
|
|
9924
|
+
{
|
|
9925
|
+
inputs: [{ internalType: "address", name: "facilitatorAddress", type: "address" }],
|
|
9926
|
+
name: "removeFacilitator",
|
|
9927
|
+
outputs: [],
|
|
9928
|
+
stateMutability: "nonpayable",
|
|
9929
|
+
type: "function"
|
|
9930
|
+
},
|
|
9931
|
+
{
|
|
9932
|
+
inputs: [
|
|
9933
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9934
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9935
|
+
],
|
|
9936
|
+
name: "renounceRole",
|
|
9937
|
+
outputs: [],
|
|
9938
|
+
stateMutability: "nonpayable",
|
|
9939
|
+
type: "function"
|
|
9940
|
+
},
|
|
9941
|
+
{
|
|
9942
|
+
inputs: [
|
|
9943
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
9944
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
9945
|
+
],
|
|
9946
|
+
name: "revokeRole",
|
|
9947
|
+
outputs: [],
|
|
9948
|
+
stateMutability: "nonpayable",
|
|
9949
|
+
type: "function"
|
|
9950
|
+
},
|
|
9951
|
+
{
|
|
9952
|
+
inputs: [
|
|
9953
|
+
{ internalType: "address", name: "facilitator", type: "address" },
|
|
9954
|
+
{ internalType: "uint128", name: "newCapacity", type: "uint128" }
|
|
9955
|
+
],
|
|
9956
|
+
name: "setFacilitatorBucketCapacity",
|
|
9957
|
+
outputs: [],
|
|
9958
|
+
stateMutability: "nonpayable",
|
|
9959
|
+
type: "function"
|
|
9960
|
+
},
|
|
9961
|
+
{
|
|
9962
|
+
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
9963
|
+
name: "supportsInterface",
|
|
9964
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9965
|
+
stateMutability: "view",
|
|
9966
|
+
type: "function"
|
|
9967
|
+
},
|
|
9968
|
+
{
|
|
9969
|
+
inputs: [],
|
|
9970
|
+
name: "symbol",
|
|
9971
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
9972
|
+
stateMutability: "view",
|
|
9973
|
+
type: "function"
|
|
9974
|
+
},
|
|
9975
|
+
{
|
|
9976
|
+
inputs: [],
|
|
9977
|
+
name: "totalSupply",
|
|
9978
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
9979
|
+
stateMutability: "view",
|
|
9980
|
+
type: "function"
|
|
9981
|
+
},
|
|
9982
|
+
{
|
|
9983
|
+
inputs: [
|
|
9984
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
9985
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9986
|
+
],
|
|
9987
|
+
name: "transfer",
|
|
9988
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
9989
|
+
stateMutability: "nonpayable",
|
|
9990
|
+
type: "function"
|
|
9991
|
+
},
|
|
9992
|
+
{
|
|
9993
|
+
inputs: [
|
|
9994
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
9995
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
9996
|
+
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
9997
|
+
],
|
|
9998
|
+
name: "transferFrom",
|
|
9999
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
10000
|
+
stateMutability: "nonpayable",
|
|
10001
|
+
type: "function"
|
|
10002
|
+
}
|
|
10003
|
+
];
|
|
10004
|
+
|
|
10005
|
+
// src/moneyMarket/UiPoolDataProviderService.ts
|
|
9619
10006
|
var UiPoolDataProviderService = class {
|
|
9620
10007
|
hubProvider;
|
|
9621
10008
|
uiPoolDataProvider;
|
|
@@ -9670,29 +10057,76 @@ var UiPoolDataProviderService = class {
|
|
|
9670
10057
|
}
|
|
9671
10058
|
/**
|
|
9672
10059
|
* Get the list of all reserves in the pool
|
|
9673
|
-
* @param
|
|
9674
|
-
* @param poolAddressesProvider - The address of the Pool Addresses Provider
|
|
10060
|
+
* @param unfiltered - If true, returns all reserves in the pool (including bnUSD (debt) reserve); if false (default), filters out bnUSD.
|
|
9675
10061
|
* @returns {Promise<readonly Address[]>} - Array of reserve addresses
|
|
9676
10062
|
*/
|
|
9677
|
-
async getReservesList() {
|
|
9678
|
-
|
|
10063
|
+
async getReservesList(unfiltered = false) {
|
|
10064
|
+
const reservesList = await this.hubProvider.publicClient.readContract({
|
|
9679
10065
|
address: this.uiPoolDataProvider,
|
|
9680
10066
|
abi: uiPoolDataAbi,
|
|
9681
10067
|
functionName: "getReservesList",
|
|
9682
10068
|
args: [this.poolAddressesProvider]
|
|
9683
10069
|
});
|
|
10070
|
+
if (unfiltered) {
|
|
10071
|
+
return reservesList;
|
|
10072
|
+
}
|
|
10073
|
+
return reservesList.filter(
|
|
10074
|
+
(reserve) => reserve.toLowerCase() !== getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase()
|
|
10075
|
+
);
|
|
10076
|
+
}
|
|
10077
|
+
/**
|
|
10078
|
+
* @description Get the bnUSD facilitator bucket
|
|
10079
|
+
* @returns {Promise<readonly [bigint, bigint]>} - The bnUSD [cap, current borrowed]
|
|
10080
|
+
*/
|
|
10081
|
+
async getBnusdFacilitatorBucket() {
|
|
10082
|
+
return this.hubProvider.publicClient.readContract({
|
|
10083
|
+
address: getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD,
|
|
10084
|
+
abi: erc20BnusdAbi,
|
|
10085
|
+
functionName: "getFacilitatorBucket",
|
|
10086
|
+
args: [getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDAToken]
|
|
10087
|
+
});
|
|
9684
10088
|
}
|
|
9685
10089
|
/**
|
|
9686
10090
|
* Get detailed data for all reserves in the pool
|
|
9687
10091
|
* @returns {Promise<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo]>} - Tuple containing array of reserve data and base currency info
|
|
9688
10092
|
*/
|
|
9689
10093
|
async getReservesData() {
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
10094
|
+
const [reserveData, bnUSDFacilitatorBucket] = await Promise.all([
|
|
10095
|
+
this.hubProvider.publicClient.readContract({
|
|
10096
|
+
address: this.uiPoolDataProvider,
|
|
10097
|
+
abi: uiPoolDataAbi,
|
|
10098
|
+
functionName: "getReservesData",
|
|
10099
|
+
args: [this.poolAddressesProvider]
|
|
10100
|
+
}),
|
|
10101
|
+
this.getBnusdFacilitatorBucket()
|
|
10102
|
+
]);
|
|
10103
|
+
const [cap, currentBorrowed] = bnUSDFacilitatorBucket;
|
|
10104
|
+
const reserves = reserveData[0];
|
|
10105
|
+
const baseCurrencyInfo = reserveData[1];
|
|
10106
|
+
const bnUSD = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
|
|
10107
|
+
const bnUSDVault = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
|
|
10108
|
+
const bnUSDReserve = reserves.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
|
|
10109
|
+
const bnUSDVaultReserve = reserves.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
|
|
10110
|
+
if (!bnUSDReserve || !bnUSDVaultReserve) {
|
|
10111
|
+
return reserveData;
|
|
10112
|
+
}
|
|
10113
|
+
const mergedBNUSDReserve = {
|
|
10114
|
+
...bnUSDVaultReserve,
|
|
10115
|
+
borrowCap: cap,
|
|
10116
|
+
availableLiquidity: cap - currentBorrowed,
|
|
10117
|
+
totalScaledVariableDebt: bnUSDReserve.totalScaledVariableDebt + bnUSDVaultReserve.totalScaledVariableDebt,
|
|
10118
|
+
virtualUnderlyingBalance: bnUSDReserve.virtualUnderlyingBalance + bnUSDVaultReserve.virtualUnderlyingBalance,
|
|
10119
|
+
accruedToTreasury: bnUSDReserve.accruedToTreasury + bnUSDVaultReserve.accruedToTreasury
|
|
10120
|
+
};
|
|
10121
|
+
return [
|
|
10122
|
+
[
|
|
10123
|
+
mergedBNUSDReserve,
|
|
10124
|
+
...reserves.filter(
|
|
10125
|
+
(r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
|
|
10126
|
+
)
|
|
10127
|
+
],
|
|
10128
|
+
baseCurrencyInfo
|
|
10129
|
+
];
|
|
9696
10130
|
}
|
|
9697
10131
|
/**
|
|
9698
10132
|
* Get user-specific reserve data
|
|
@@ -9702,12 +10136,35 @@ var UiPoolDataProviderService = class {
|
|
|
9702
10136
|
* @returns {Promise<readonly [readonly UserReserveData[], number]>} - Tuple containing array of user reserve data and eMode category ID
|
|
9703
10137
|
*/
|
|
9704
10138
|
async getUserReservesData(userAddress) {
|
|
9705
|
-
|
|
10139
|
+
const userReserves = await this.hubProvider.publicClient.readContract({
|
|
9706
10140
|
address: this.uiPoolDataProvider,
|
|
9707
10141
|
abi: uiPoolDataAbi,
|
|
9708
10142
|
functionName: "getUserReservesData",
|
|
9709
10143
|
args: [this.poolAddressesProvider, userAddress]
|
|
9710
10144
|
});
|
|
10145
|
+
const userReservesData = userReserves[0];
|
|
10146
|
+
const eModeCategoryId = userReserves[1];
|
|
10147
|
+
const bnUSD = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSD.toLowerCase();
|
|
10148
|
+
const bnUSDVault = getMoneyMarketConfig(this.hubProvider.chainConfig.chain.id).bnUSDVault.toLowerCase();
|
|
10149
|
+
const bnUSDReserve = userReservesData.find((r) => bnUSD === r.underlyingAsset.toLowerCase());
|
|
10150
|
+
const bnUSDVaultReserve = userReservesData.find((r) => bnUSDVault === r.underlyingAsset.toLowerCase());
|
|
10151
|
+
if (!bnUSDReserve || !bnUSDVaultReserve) {
|
|
10152
|
+
return userReserves;
|
|
10153
|
+
}
|
|
10154
|
+
const mergedBNUSDReserve = {
|
|
10155
|
+
...bnUSDVaultReserve,
|
|
10156
|
+
scaledATokenBalance: bnUSDReserve.scaledATokenBalance + bnUSDVaultReserve.scaledATokenBalance,
|
|
10157
|
+
scaledVariableDebt: bnUSDReserve.scaledVariableDebt + bnUSDVaultReserve.scaledVariableDebt
|
|
10158
|
+
};
|
|
10159
|
+
return [
|
|
10160
|
+
[
|
|
10161
|
+
mergedBNUSDReserve,
|
|
10162
|
+
...userReservesData.filter(
|
|
10163
|
+
(r) => r.underlyingAsset.toLowerCase() !== bnUSD && r.underlyingAsset.toLowerCase() !== bnUSDVault
|
|
10164
|
+
)
|
|
10165
|
+
],
|
|
10166
|
+
eModeCategoryId
|
|
10167
|
+
];
|
|
9711
10168
|
}
|
|
9712
10169
|
/**
|
|
9713
10170
|
* Get the reserves data humanized
|
|
@@ -9835,6 +10292,9 @@ var MoneyMarketDataService = class {
|
|
|
9835
10292
|
this.uiPoolDataProviderService = new UiPoolDataProviderService(hubProvider);
|
|
9836
10293
|
this.lendingPoolService = new LendingPoolService(hubProvider);
|
|
9837
10294
|
}
|
|
10295
|
+
async getATokenData(aToken) {
|
|
10296
|
+
return Erc20Service.getErc20Token(aToken, this.hubProvider.publicClient);
|
|
10297
|
+
}
|
|
9838
10298
|
/**
|
|
9839
10299
|
* LendingPool
|
|
9840
10300
|
*/
|
|
@@ -9859,10 +10319,11 @@ var MoneyMarketDataService = class {
|
|
|
9859
10319
|
*/
|
|
9860
10320
|
/**
|
|
9861
10321
|
* Get the reserves list
|
|
10322
|
+
* @param unfiltered - If true, return the list of all reserves in the pool (including bnUSD (debt) reserve)
|
|
9862
10323
|
* @returns {Promise<readonly Address[]>} - List of reserve asset addresses
|
|
9863
10324
|
*/
|
|
9864
|
-
async getReservesList() {
|
|
9865
|
-
return this.uiPoolDataProviderService.getReservesList();
|
|
10325
|
+
async getReservesList(unfiltered = false) {
|
|
10326
|
+
return this.uiPoolDataProviderService.getReservesList(unfiltered);
|
|
9866
10327
|
}
|
|
9867
10328
|
/**
|
|
9868
10329
|
* Get the reserves data
|
|
@@ -10631,7 +11092,7 @@ var SwapService = class {
|
|
|
10631
11092
|
* "token_dst_blockchain_id":"0xa4b1.arbitrum",
|
|
10632
11093
|
* "amount":1000000000000000n,
|
|
10633
11094
|
* "quote_type": "exact_input"
|
|
10634
|
-
* } satisfies SolverIntentQuoteRequest
|
|
11095
|
+
* } satisfies SolverIntentQuoteRequest & OptionalFee
|
|
10635
11096
|
*
|
|
10636
11097
|
* const response = await swapService.getQuote(payload);
|
|
10637
11098
|
*
|
|
@@ -10645,7 +11106,7 @@ var SwapService = class {
|
|
|
10645
11106
|
async getQuote(payload) {
|
|
10646
11107
|
payload = {
|
|
10647
11108
|
...payload,
|
|
10648
|
-
amount: adjustAmountByFee(payload.amount, this.config.partnerFee, payload.quote_type)
|
|
11109
|
+
amount: adjustAmountByFee(payload.amount, payload.fee ?? this.config.partnerFee, payload.quote_type)
|
|
10649
11110
|
};
|
|
10650
11111
|
return SolverApiService.getQuote(payload, this.config, this.configService);
|
|
10651
11112
|
}
|
|
@@ -14066,26 +14527,30 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
14066
14527
|
}
|
|
14067
14528
|
return spokeProvider.walletProvider.sendTransaction(serializedTransaction);
|
|
14068
14529
|
}
|
|
14069
|
-
static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs =
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
if (tx
|
|
14077
|
-
|
|
14530
|
+
static async waitForConfirmation(spokeProvider, signature, commitment = "finalized", timeoutMs = 12e4) {
|
|
14531
|
+
try {
|
|
14532
|
+
const connection = new Connection(spokeProvider.chainConfig.rpcUrl, commitment);
|
|
14533
|
+
const deadline = Date.now() + timeoutMs;
|
|
14534
|
+
while (Date.now() < deadline) {
|
|
14535
|
+
try {
|
|
14536
|
+
const tx = await connection.getTransaction(signature, { commitment, maxSupportedTransactionVersion: 0 });
|
|
14537
|
+
if (tx) {
|
|
14538
|
+
if (tx.meta?.err) {
|
|
14539
|
+
return { ok: false, error: new Error(JSON.stringify(tx.meta.err)) };
|
|
14540
|
+
}
|
|
14541
|
+
return { ok: true, value: true };
|
|
14078
14542
|
}
|
|
14079
|
-
|
|
14543
|
+
} catch {
|
|
14080
14544
|
}
|
|
14081
|
-
|
|
14545
|
+
await new Promise((r) => setTimeout(r, 750));
|
|
14082
14546
|
}
|
|
14083
|
-
|
|
14547
|
+
return {
|
|
14548
|
+
ok: false,
|
|
14549
|
+
error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
|
|
14550
|
+
};
|
|
14551
|
+
} catch (error) {
|
|
14552
|
+
return { ok: false, error: new Error(`Failed to get transaction confirmation: ${JSON.stringify(error)}`) };
|
|
14084
14553
|
}
|
|
14085
|
-
return {
|
|
14086
|
-
ok: false,
|
|
14087
|
-
error: new Error(`Timed out after ${timeoutMs}ms waiting for ${commitment} confirmation for ${signature}`)
|
|
14088
|
-
};
|
|
14089
14554
|
}
|
|
14090
14555
|
};
|
|
14091
14556
|
function isEvmHubChainConfig(value) {
|
|
@@ -14602,7 +15067,16 @@ var SpokeService = class _SpokeService {
|
|
|
14602
15067
|
*/
|
|
14603
15068
|
static async verifyTxHash(txHash, spokeProvider) {
|
|
14604
15069
|
if (isSolanaSpokeProvider(spokeProvider)) {
|
|
14605
|
-
|
|
15070
|
+
const result = await SolanaSpokeService.waitForConfirmation(spokeProvider, txHash);
|
|
15071
|
+
if (!result.ok) {
|
|
15072
|
+
console.warn(`Solana verifyTxHash failed: ${result.error}`);
|
|
15073
|
+
console.warn("Returning true to assume transaction exists on chain in future ");
|
|
15074
|
+
return {
|
|
15075
|
+
ok: true,
|
|
15076
|
+
value: true
|
|
15077
|
+
};
|
|
15078
|
+
}
|
|
15079
|
+
return result;
|
|
14606
15080
|
}
|
|
14607
15081
|
if (isStellarSpokeProvider(spokeProvider)) {
|
|
14608
15082
|
return StellarSpokeService.waitForTransaction(spokeProvider, txHash);
|