@berachain/berajs 0.2.8-beta.9 → 0.2.9
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/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
- package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
- package/dist/{RequestError-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
- package/dist/abi/exports.mjs +4452 -2
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +104 -189
- package/dist/actions/exports.mjs +853 -2
- package/dist/actions/governance/exports.d.ts +140 -0
- package/dist/actions/governance/exports.mjs +226 -0
- package/dist/actions/server/exports.d.ts +13 -0
- package/dist/actions/server/exports.mjs +27 -0
- package/dist/chunk-3EARVV7K.mjs +414 -0
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/chunk-BGMRHTBQ.mjs +23 -0
- package/dist/chunk-CDFWPU2R.mjs +473 -0
- package/dist/chunk-CDK4YV3D.mjs +571 -0
- package/dist/chunk-DKMAIU74.mjs +62 -0
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/chunk-FFB5LFDW.mjs +35 -0
- package/dist/chunk-HQCOU6GY.mjs +243 -0
- package/dist/chunk-HSSJKHZ4.mjs +135 -0
- package/dist/chunk-J5I45WGQ.mjs +1769 -0
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/chunk-NBYLMO2L.mjs +14 -0
- package/dist/chunk-NPBQLVL3.mjs +80 -0
- package/dist/chunk-O2NQFKJK.mjs +170 -0
- package/dist/chunk-QJIXTYTZ.mjs +4054 -0
- package/dist/chunk-SGIJVHZO.mjs +12 -0
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/chunk-WXXOISTU.mjs +96 -0
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +85 -2
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +46 -2
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +4 -3
- package/dist/errors/exports.mjs +48 -2
- package/dist/exports-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
- package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
- package/dist/hooks/exports.d.ts +69 -211
- package/dist/hooks/exports.mjs +7434 -4
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-CqPA9K6m.d.ts +142 -0
- package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
- package/dist/types/exports.d.ts +9 -9
- package/dist/types/exports.mjs +0 -1
- package/dist/types/governance/exports.d.ts +109 -0
- package/dist/types/governance/exports.mjs +0 -0
- package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
- package/dist/utils/exports.d.ts +15 -6
- package/dist/utils/exports.mjs +825 -2
- package/package.json +49 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +58 -23
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/enso/enso.ts +27 -17
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
- package/src/actions/dex/aggregators/kyberswap.ts +18 -23
- package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
- package/src/actions/exports.ts +4 -9
- package/src/actions/governance/exports.ts +9 -0
- package/src/actions/governance/getAllProposals.ts +10 -65
- package/src/actions/governance/getProposalDetails.ts +6 -33
- package/src/actions/governance/getProposalVotes.ts +8 -15
- package/src/actions/honey/getChartData.ts +27 -21
- package/src/actions/honey/getHoney24hVolume.ts +19 -22
- package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +7 -11
- package/src/actions/pol/getGlobalData.ts +1 -0
- package/src/actions/pol/getHeroEarnVaults.ts +62 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
- package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +7 -10
- package/src/actions/server/exports.ts +1 -0
- package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
- package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
- package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
- package/src/actions/validators/getValidatorAnalytics.ts +20 -21
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
- package/src/enum/contracts.ts +1 -0
- package/src/enum/exports.ts +0 -1
- package/src/enum/governance/exports.ts +1 -0
- package/src/errors/BeraError.ts +47 -7
- package/src/errors/BeraTracing.unit.test.ts +65 -0
- package/src/errors/RequestError.ts +13 -1
- package/src/errors/exports.ts +5 -0
- package/src/errors/getRevertReason.integration.test.ts +3 -3
- package/src/errors/spanStatus.ts +78 -0
- package/src/errors/spanStatus.unit.test.ts +62 -0
- package/src/hooks/dex/useCreatePool.ts +1 -88
- package/src/hooks/dex/useOnChainPoolData.ts +27 -2
- package/src/hooks/dex/usePriceImpact.ts +12 -5
- package/src/hooks/enso/useBendDemultiply.ts +9 -1
- package/src/hooks/enso/useBendMultiply.ts +9 -1
- package/src/hooks/enso/useBendZapSupply.ts +26 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
- package/src/hooks/exports.ts +2 -15
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +2 -0
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +8 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +9 -3
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- package/src/utils/sanitizeRpcUrl.ts +22 -0
- package/src/utils/tracedTransport.ts +35 -0
- package/dist/BeraError-_mQdkanr.d.ts +0 -94
- package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
- package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
- package/dist/RequestError-DSUzJ1Iy.d.cts +0 -144
- package/dist/abi/exports.cjs +0 -2
- package/dist/abi/exports.cjs.map +0 -1
- package/dist/abi/exports.d.cts +0 -6574
- package/dist/abi/exports.mjs.map +0 -1
- package/dist/actions/exports.cjs +0 -2
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1650
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-45HIEVNI.cjs +0 -4
- package/dist/chunk-45HIEVNI.cjs.map +0 -1
- package/dist/chunk-47ILYVHC.mjs +0 -2
- package/dist/chunk-47ILYVHC.mjs.map +0 -1
- package/dist/chunk-575OK77P.mjs +0 -2
- package/dist/chunk-575OK77P.mjs.map +0 -1
- package/dist/chunk-5NVZG5N6.mjs +0 -2
- package/dist/chunk-5NVZG5N6.mjs.map +0 -1
- package/dist/chunk-6DIA6PXV.cjs +0 -2
- package/dist/chunk-6DIA6PXV.cjs.map +0 -1
- package/dist/chunk-6JJIZCVY.cjs +0 -2
- package/dist/chunk-6JJIZCVY.cjs.map +0 -1
- package/dist/chunk-7F72ZH4Q.mjs +0 -2
- package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
- package/dist/chunk-AUA42YIG.mjs +0 -4
- package/dist/chunk-AUA42YIG.mjs.map +0 -1
- package/dist/chunk-BC2WX6O6.cjs +0 -2
- package/dist/chunk-BC2WX6O6.cjs.map +0 -1
- package/dist/chunk-CJOZC5Z2.cjs +0 -2
- package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
- package/dist/chunk-D6L7LTA2.cjs +0 -2
- package/dist/chunk-D6L7LTA2.cjs.map +0 -1
- package/dist/chunk-DDEQFR3M.cjs +0 -2
- package/dist/chunk-DDEQFR3M.cjs.map +0 -1
- package/dist/chunk-GXV2JA36.mjs +0 -2
- package/dist/chunk-GXV2JA36.mjs.map +0 -1
- package/dist/chunk-ISYNEDET.mjs +0 -2
- package/dist/chunk-ISYNEDET.mjs.map +0 -1
- package/dist/chunk-JDDRTHFG.mjs +0 -2
- package/dist/chunk-JDDRTHFG.mjs.map +0 -1
- package/dist/chunk-JDZGYU5T.mjs +0 -2
- package/dist/chunk-JDZGYU5T.mjs.map +0 -1
- package/dist/chunk-LVOXBZMA.cjs +0 -2
- package/dist/chunk-LVOXBZMA.cjs.map +0 -1
- package/dist/chunk-MK5NS5B5.mjs +0 -2
- package/dist/chunk-MK5NS5B5.mjs.map +0 -1
- package/dist/chunk-NAXAZJJY.mjs +0 -2
- package/dist/chunk-NAXAZJJY.mjs.map +0 -1
- package/dist/chunk-NLVWRMGD.mjs +0 -2
- package/dist/chunk-NLVWRMGD.mjs.map +0 -1
- package/dist/chunk-OGBD5YOG.mjs +0 -2
- package/dist/chunk-OGBD5YOG.mjs.map +0 -1
- package/dist/chunk-OGJMSGB2.mjs +0 -2
- package/dist/chunk-OGJMSGB2.mjs.map +0 -1
- package/dist/chunk-OIYXOKTT.cjs +0 -2
- package/dist/chunk-OIYXOKTT.cjs.map +0 -1
- package/dist/chunk-OUD27MU7.cjs +0 -2
- package/dist/chunk-OUD27MU7.cjs.map +0 -1
- package/dist/chunk-PRLVZIKD.mjs +0 -2
- package/dist/chunk-PRLVZIKD.mjs.map +0 -1
- package/dist/chunk-Q2SNRLW3.cjs +0 -2
- package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
- package/dist/chunk-REWME3FY.cjs +0 -2
- package/dist/chunk-REWME3FY.cjs.map +0 -1
- package/dist/chunk-RJN36GBU.mjs +0 -2
- package/dist/chunk-RJN36GBU.mjs.map +0 -1
- package/dist/chunk-RWOICHRW.cjs +0 -2
- package/dist/chunk-RWOICHRW.cjs.map +0 -1
- package/dist/chunk-S4CDSVLK.cjs +0 -2
- package/dist/chunk-S4CDSVLK.cjs.map +0 -1
- package/dist/chunk-SFEULGSX.cjs +0 -2
- package/dist/chunk-SFEULGSX.cjs.map +0 -1
- package/dist/chunk-WBTS6KFG.mjs +0 -2
- package/dist/chunk-WBTS6KFG.mjs.map +0 -1
- package/dist/chunk-WRFDB3QJ.cjs +0 -2
- package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
- package/dist/chunk-XNJLSA6P.cjs +0 -2
- package/dist/chunk-XNJLSA6P.cjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -2
- package/dist/contexts/exports.cjs.map +0 -1
- package/dist/contexts/exports.d.cts +0 -66
- package/dist/contexts/exports.mjs.map +0 -1
- package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
- package/dist/dex-C_BB0b0O.d.cts +0 -37
- package/dist/enum/exports.cjs +0 -2
- package/dist/enum/exports.cjs.map +0 -1
- package/dist/enum/exports.d.cts +0 -23
- package/dist/enum/exports.mjs.map +0 -1
- package/dist/errors/exports.cjs +0 -2
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -327
- package/dist/errors/exports.mjs.map +0 -1
- package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
- package/dist/global.d-B7IeayVX.d.cts +0 -474
- package/dist/honey-CYm0RWf4.d.cts +0 -14
- package/dist/hooks/exports.cjs +0 -4
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1734
- package/dist/hooks/exports.mjs.map +0 -1
- package/dist/polling-BKnyavLI.d.cts +0 -8
- package/dist/txnEnum-7_o92X3N.d.ts +0 -164
- package/dist/types/exports.cjs +0 -1
- package/dist/types/exports.cjs.map +0 -1
- package/dist/types/exports.d.cts +0 -90
- package/dist/types/exports.mjs.map +0 -1
- package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
- package/dist/utils/exports.cjs +0 -2
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -420
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bignumber_js_default
|
|
3
|
+
} from "./chunk-CDFWPU2R.mjs";
|
|
4
|
+
import {
|
|
5
|
+
isToken,
|
|
6
|
+
wBeraToken
|
|
7
|
+
} from "./chunk-NPBQLVL3.mjs";
|
|
8
|
+
|
|
9
|
+
// src/utils/tokenWrapping.ts
|
|
10
|
+
function wrapNativeToken(token) {
|
|
11
|
+
return {
|
|
12
|
+
...token,
|
|
13
|
+
...isToken(token, "BERA") && wBeraToken
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function wrapNativeTokens(tokens) {
|
|
17
|
+
return tokens.map((token) => wrapNativeToken(token));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/utils/math.ts
|
|
21
|
+
var computePriceImpact = (tokenInPrice, tokenOutPrice, inAmount, outAmount) => {
|
|
22
|
+
if (!tokenInPrice || !tokenOutPrice || !inAmount || !outAmount) return 0;
|
|
23
|
+
const usdIn = new bignumber_js_default(tokenInPrice).times(inAmount);
|
|
24
|
+
const usdOut = new bignumber_js_default(tokenOutPrice).times(outAmount);
|
|
25
|
+
if (usdIn.lt(0.01) || usdOut.lt(0.01)) return 0;
|
|
26
|
+
if (usdIn.isZero() || usdOut.isZero()) return 0;
|
|
27
|
+
const ratio = usdOut.div(usdIn);
|
|
28
|
+
return Number(new bignumber_js_default(1).minus(ratio).toFixed());
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
wrapNativeToken,
|
|
33
|
+
wrapNativeTokens,
|
|
34
|
+
computePriceImpact
|
|
35
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// src/abi/utils/multicall3.ts
|
|
2
|
+
var multicall3Abi = [
|
|
3
|
+
{
|
|
4
|
+
inputs: [
|
|
5
|
+
{
|
|
6
|
+
components: [
|
|
7
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
8
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
9
|
+
],
|
|
10
|
+
internalType: "struct Multicall3.Call[]",
|
|
11
|
+
name: "calls",
|
|
12
|
+
type: "tuple[]"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
name: "aggregate",
|
|
16
|
+
outputs: [
|
|
17
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
18
|
+
{ internalType: "bytes[]", name: "returnData", type: "bytes[]" }
|
|
19
|
+
],
|
|
20
|
+
stateMutability: "payable",
|
|
21
|
+
type: "function"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
inputs: [
|
|
25
|
+
{
|
|
26
|
+
components: [
|
|
27
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
28
|
+
{ internalType: "bool", name: "allowFailure", type: "bool" },
|
|
29
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
30
|
+
],
|
|
31
|
+
internalType: "struct Multicall3.Call3[]",
|
|
32
|
+
name: "calls",
|
|
33
|
+
type: "tuple[]"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
name: "aggregate3",
|
|
37
|
+
outputs: [
|
|
38
|
+
{
|
|
39
|
+
components: [
|
|
40
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
41
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" }
|
|
42
|
+
],
|
|
43
|
+
internalType: "struct Multicall3.Result[]",
|
|
44
|
+
name: "returnData",
|
|
45
|
+
type: "tuple[]"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
stateMutability: "payable",
|
|
49
|
+
type: "function"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
inputs: [
|
|
53
|
+
{
|
|
54
|
+
components: [
|
|
55
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
56
|
+
{ internalType: "bool", name: "allowFailure", type: "bool" },
|
|
57
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
58
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
59
|
+
],
|
|
60
|
+
internalType: "struct Multicall3.Call3Value[]",
|
|
61
|
+
name: "calls",
|
|
62
|
+
type: "tuple[]"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
name: "aggregate3Value",
|
|
66
|
+
outputs: [
|
|
67
|
+
{
|
|
68
|
+
components: [
|
|
69
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
70
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" }
|
|
71
|
+
],
|
|
72
|
+
internalType: "struct Multicall3.Result[]",
|
|
73
|
+
name: "returnData",
|
|
74
|
+
type: "tuple[]"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
stateMutability: "payable",
|
|
78
|
+
type: "function"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
inputs: [
|
|
82
|
+
{
|
|
83
|
+
components: [
|
|
84
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
85
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
86
|
+
],
|
|
87
|
+
internalType: "struct Multicall3.Call[]",
|
|
88
|
+
name: "calls",
|
|
89
|
+
type: "tuple[]"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
name: "blockAndAggregate",
|
|
93
|
+
outputs: [
|
|
94
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
95
|
+
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
96
|
+
{
|
|
97
|
+
components: [
|
|
98
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
99
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" }
|
|
100
|
+
],
|
|
101
|
+
internalType: "struct Multicall3.Result[]",
|
|
102
|
+
name: "returnData",
|
|
103
|
+
type: "tuple[]"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
stateMutability: "payable",
|
|
107
|
+
type: "function"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
inputs: [],
|
|
111
|
+
name: "getBasefee",
|
|
112
|
+
outputs: [{ internalType: "uint256", name: "basefee", type: "uint256" }],
|
|
113
|
+
stateMutability: "view",
|
|
114
|
+
type: "function"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
inputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }],
|
|
118
|
+
name: "getBlockHash",
|
|
119
|
+
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
120
|
+
stateMutability: "view",
|
|
121
|
+
type: "function"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
inputs: [],
|
|
125
|
+
name: "getBlockNumber",
|
|
126
|
+
outputs: [
|
|
127
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" }
|
|
128
|
+
],
|
|
129
|
+
stateMutability: "view",
|
|
130
|
+
type: "function"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
inputs: [],
|
|
134
|
+
name: "getChainId",
|
|
135
|
+
outputs: [{ internalType: "uint256", name: "chainid", type: "uint256" }],
|
|
136
|
+
stateMutability: "view",
|
|
137
|
+
type: "function"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
inputs: [],
|
|
141
|
+
name: "getCurrentBlockCoinbase",
|
|
142
|
+
outputs: [{ internalType: "address", name: "coinbase", type: "address" }],
|
|
143
|
+
stateMutability: "view",
|
|
144
|
+
type: "function"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
inputs: [],
|
|
148
|
+
name: "getCurrentBlockDifficulty",
|
|
149
|
+
outputs: [{ internalType: "uint256", name: "difficulty", type: "uint256" }],
|
|
150
|
+
stateMutability: "view",
|
|
151
|
+
type: "function"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
inputs: [],
|
|
155
|
+
name: "getCurrentBlockGasLimit",
|
|
156
|
+
outputs: [{ internalType: "uint256", name: "gaslimit", type: "uint256" }],
|
|
157
|
+
stateMutability: "view",
|
|
158
|
+
type: "function"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
inputs: [],
|
|
162
|
+
name: "getCurrentBlockTimestamp",
|
|
163
|
+
outputs: [{ internalType: "uint256", name: "timestamp", type: "uint256" }],
|
|
164
|
+
stateMutability: "view",
|
|
165
|
+
type: "function"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
inputs: [{ internalType: "address", name: "addr", type: "address" }],
|
|
169
|
+
name: "getEthBalance",
|
|
170
|
+
outputs: [{ internalType: "uint256", name: "balance", type: "uint256" }],
|
|
171
|
+
stateMutability: "view",
|
|
172
|
+
type: "function"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
inputs: [],
|
|
176
|
+
name: "getLastBlockHash",
|
|
177
|
+
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
178
|
+
stateMutability: "view",
|
|
179
|
+
type: "function"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
inputs: [
|
|
183
|
+
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
184
|
+
{
|
|
185
|
+
components: [
|
|
186
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
187
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
188
|
+
],
|
|
189
|
+
internalType: "struct Multicall3.Call[]",
|
|
190
|
+
name: "calls",
|
|
191
|
+
type: "tuple[]"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
name: "tryAggregate",
|
|
195
|
+
outputs: [
|
|
196
|
+
{
|
|
197
|
+
components: [
|
|
198
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
199
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" }
|
|
200
|
+
],
|
|
201
|
+
internalType: "struct Multicall3.Result[]",
|
|
202
|
+
name: "returnData",
|
|
203
|
+
type: "tuple[]"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
stateMutability: "payable",
|
|
207
|
+
type: "function"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
inputs: [
|
|
211
|
+
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
212
|
+
{
|
|
213
|
+
components: [
|
|
214
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
215
|
+
{ internalType: "bytes", name: "callData", type: "bytes" }
|
|
216
|
+
],
|
|
217
|
+
internalType: "struct Multicall3.Call[]",
|
|
218
|
+
name: "calls",
|
|
219
|
+
type: "tuple[]"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
name: "tryBlockAndAggregate",
|
|
223
|
+
outputs: [
|
|
224
|
+
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
225
|
+
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
226
|
+
{
|
|
227
|
+
components: [
|
|
228
|
+
{ internalType: "bool", name: "success", type: "bool" },
|
|
229
|
+
{ internalType: "bytes", name: "returnData", type: "bytes" }
|
|
230
|
+
],
|
|
231
|
+
internalType: "struct Multicall3.Result[]",
|
|
232
|
+
name: "returnData",
|
|
233
|
+
type: "tuple[]"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
stateMutability: "payable",
|
|
237
|
+
type: "function"
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
multicall3Abi
|
|
243
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
multicall3Abi
|
|
3
|
+
} from "./chunk-HQCOU6GY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
assertAddress,
|
|
6
|
+
assertDefined,
|
|
7
|
+
assertPublicClient
|
|
8
|
+
} from "./chunk-KQUMKB66.mjs";
|
|
9
|
+
import {
|
|
10
|
+
isToken
|
|
11
|
+
} from "./chunk-NPBQLVL3.mjs";
|
|
12
|
+
import {
|
|
13
|
+
parseBaseArgs
|
|
14
|
+
} from "./chunk-75M6TF7M.mjs";
|
|
15
|
+
|
|
16
|
+
// src/actions/clients/getEnsoClient.ts
|
|
17
|
+
import { EnsoClient } from "@ensofinance/sdk";
|
|
18
|
+
import { appConfig } from "@berachain/config/internal";
|
|
19
|
+
var isProduction = process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test";
|
|
20
|
+
function getEnsoClient({
|
|
21
|
+
baseURL,
|
|
22
|
+
...args
|
|
23
|
+
} = {}) {
|
|
24
|
+
const { config } = parseBaseArgs(args);
|
|
25
|
+
const resolvedBaseURL = baseURL !== void 0 ? baseURL : isProduction ? `${config.bex.aggregatorsProxyUrl}/enso/api/v1/` : void 0;
|
|
26
|
+
return new EnsoClient({
|
|
27
|
+
baseURL: resolvedBaseURL,
|
|
28
|
+
// no API key when routing through a proxy — the proxy handles auth
|
|
29
|
+
apiKey: resolvedBaseURL ? "" : appConfig.apiKeys.public.enso
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/actions/tokens/getWalletBalances.ts
|
|
34
|
+
import { getChainId, getPublicClient } from "@wagmi/core";
|
|
35
|
+
import {
|
|
36
|
+
erc20Abi,
|
|
37
|
+
formatUnits,
|
|
38
|
+
isAddress
|
|
39
|
+
} from "viem";
|
|
40
|
+
function getBalanceCall({
|
|
41
|
+
token,
|
|
42
|
+
account,
|
|
43
|
+
multicallAddress
|
|
44
|
+
}) {
|
|
45
|
+
if (isToken(token, "BERA") || isToken(token, "ETH")) {
|
|
46
|
+
return {
|
|
47
|
+
address: multicallAddress,
|
|
48
|
+
abi: multicall3Abi,
|
|
49
|
+
functionName: "getEthBalance",
|
|
50
|
+
args: [account]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
address: token.address,
|
|
55
|
+
abi: erc20Abi,
|
|
56
|
+
functionName: "balanceOf",
|
|
57
|
+
args: [account]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function getWalletBalances({
|
|
61
|
+
account,
|
|
62
|
+
tokenList,
|
|
63
|
+
wagmiConfig: config
|
|
64
|
+
}) {
|
|
65
|
+
assertDefined(config, "config");
|
|
66
|
+
if (!account || !tokenList)
|
|
67
|
+
throw new Error("account or tokenList is not defined");
|
|
68
|
+
assertAddress(account, "account");
|
|
69
|
+
const filteredTokenList = tokenList.filter(
|
|
70
|
+
(token) => isAddress(token.address)
|
|
71
|
+
);
|
|
72
|
+
const tokensByChainId = Object.groupBy(
|
|
73
|
+
filteredTokenList,
|
|
74
|
+
(token) => token.chainId ?? getChainId(config)
|
|
75
|
+
);
|
|
76
|
+
const res = await Promise.allSettled(
|
|
77
|
+
Object.entries(tokensByChainId).map(async ([chainId, tokens]) => {
|
|
78
|
+
assertDefined(tokens, "tokens");
|
|
79
|
+
const publicClient = getPublicClient(config, {
|
|
80
|
+
chainId: Number(chainId)
|
|
81
|
+
});
|
|
82
|
+
assertPublicClient(publicClient, `publicClient ${chainId}`);
|
|
83
|
+
assertDefined(publicClient.chain, "publicClient.chain");
|
|
84
|
+
assertDefined(
|
|
85
|
+
publicClient.chain.contracts,
|
|
86
|
+
"publicClient.chain.contracts"
|
|
87
|
+
);
|
|
88
|
+
assertDefined(
|
|
89
|
+
publicClient.chain.contracts.multicall3,
|
|
90
|
+
"publicClient.chain.contracts.multicall3"
|
|
91
|
+
);
|
|
92
|
+
const { multicall3 } = publicClient.chain.contracts;
|
|
93
|
+
const multicall3Address = typeof multicall3 === "string" ? multicall3 : multicall3.address;
|
|
94
|
+
assertAddress(multicall3Address, "multicall3Address");
|
|
95
|
+
const call = tokens.map(
|
|
96
|
+
(token) => getBalanceCall({
|
|
97
|
+
token,
|
|
98
|
+
account,
|
|
99
|
+
multicallAddress: multicall3Address
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
const result = await publicClient.multicall({
|
|
103
|
+
contracts: call
|
|
104
|
+
});
|
|
105
|
+
return result.map((item, index) => {
|
|
106
|
+
const token = tokens[index];
|
|
107
|
+
if (item.error) {
|
|
108
|
+
return { ...token, balance: { raw: "0", formatted: "0" } };
|
|
109
|
+
}
|
|
110
|
+
const formattedBalance = formatUnits(
|
|
111
|
+
item.result,
|
|
112
|
+
token?.decimals || 18
|
|
113
|
+
);
|
|
114
|
+
const resultBalanceToken = {
|
|
115
|
+
...token,
|
|
116
|
+
balance: {
|
|
117
|
+
raw: item.result.toString(),
|
|
118
|
+
// TODO: this was done 10 months ago, i'm not sure it's a good solution.
|
|
119
|
+
formatted: formattedBalance.includes("e") ? "0" : formattedBalance
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return resultBalanceToken;
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
return res.flatMap(
|
|
127
|
+
(result) => result.status === "fulfilled" ? result.value : []
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
getEnsoClient,
|
|
133
|
+
getBalanceCall,
|
|
134
|
+
getWalletBalances
|
|
135
|
+
};
|