@swapkit/toolboxes 4.0.0-beta.50 → 4.0.0-beta.52
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/src/cosmos/index.cjs +2 -2
- package/dist/src/cosmos/index.cjs.map +10 -6
- package/dist/src/cosmos/index.js +2 -2
- package/dist/src/cosmos/index.js.map +10 -6
- package/dist/src/evm/index.cjs +2 -2
- package/dist/src/evm/index.cjs.map +10 -8
- package/dist/src/evm/index.js +2 -2
- package/dist/src/evm/index.js.map +10 -8
- package/dist/src/index.cjs +4 -2
- package/dist/src/index.cjs.map +54 -4
- package/dist/src/index.js +4 -2
- package/dist/src/index.js.map +54 -4
- package/dist/src/near/index.cjs +2 -2
- package/dist/src/near/index.cjs.map +7 -5
- package/dist/src/near/index.js +2 -2
- package/dist/src/near/index.js.map +7 -5
- package/dist/src/radix/index.cjs +2 -2
- package/dist/src/radix/index.cjs.map +2 -2
- package/dist/src/radix/index.js +2 -2
- package/dist/src/radix/index.js.map +2 -2
- package/dist/src/ripple/index.cjs +2 -2
- package/dist/src/ripple/index.cjs.map +2 -2
- package/dist/src/ripple/index.js +2 -2
- package/dist/src/ripple/index.js.map +2 -2
- package/dist/src/solana/index.cjs +2 -2
- package/dist/src/solana/index.cjs.map +5 -4
- package/dist/src/solana/index.js +2 -2
- package/dist/src/solana/index.js.map +5 -4
- package/dist/src/substrate/index.cjs +2 -2
- package/dist/src/substrate/index.cjs.map +6 -5
- package/dist/src/substrate/index.js +2 -2
- package/dist/src/substrate/index.js.map +6 -5
- package/dist/src/tron/index.cjs +2 -2
- package/dist/src/tron/index.cjs.map +6 -5
- package/dist/src/tron/index.js +2 -2
- package/dist/src/tron/index.js.map +6 -5
- package/dist/src/utxo/index.cjs +4 -4
- package/dist/src/utxo/index.cjs.map +10 -7
- package/dist/src/utxo/index.js +4 -4
- package/dist/src/utxo/index.js.map +10 -7
- package/{src/cosmos/index.ts → dist/types/cosmos/index.d.ts} +1 -0
- package/dist/types/cosmos/index.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +5 -0
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -0
- package/{src/cosmos/thorchainUtils/index.ts → dist/types/cosmos/thorchainUtils/index.d.ts} +1 -0
- package/dist/types/cosmos/thorchainUtils/index.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +208 -0
- package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/registry.d.ts +4 -0
- package/dist/types/cosmos/thorchainUtils/registry.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts +2 -0
- package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts +66 -0
- package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/index.d.ts +2 -0
- package/dist/types/cosmos/thorchainUtils/types/index.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/cosmos.d.ts +93 -0
- package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/index.d.ts +14 -0
- package/dist/types/cosmos/toolbox/index.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/thorchain.d.ts +158 -0
- package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -0
- package/{src/cosmos/types.ts → dist/types/cosmos/types.d.ts} +24 -29
- package/dist/types/cosmos/types.d.ts.map +1 -0
- package/dist/types/cosmos/util.d.ts +68 -0
- package/dist/types/cosmos/util.d.ts.map +1 -0
- package/dist/types/evm/api.d.ts +8 -0
- package/dist/types/evm/api.d.ts.map +1 -0
- package/dist/types/evm/contracts/eth/multicall.d.ts +36 -0
- package/dist/types/evm/contracts/eth/multicall.d.ts.map +1 -0
- package/dist/types/evm/contracts/op/gasOracle.d.ts +40 -0
- package/dist/types/evm/contracts/op/gasOracle.d.ts.map +1 -0
- package/dist/types/evm/helpers.d.ts +20 -0
- package/dist/types/evm/helpers.d.ts.map +1 -0
- package/{src/evm/index.ts → dist/types/evm/index.d.ts} +1 -0
- package/dist/types/evm/index.d.ts.map +1 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +82 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -0
- package/dist/types/evm/toolbox/evm.d.ts +367 -0
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -0
- package/dist/types/evm/toolbox/index.d.ts +89 -0
- package/dist/types/evm/toolbox/index.d.ts.map +1 -0
- package/dist/types/evm/toolbox/op.d.ts +62 -0
- package/dist/types/evm/toolbox/op.d.ts.map +1 -0
- package/dist/types/evm/types.d.ts +98 -0
- package/dist/types/evm/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/near/helpers/core.d.ts +15 -0
- package/dist/types/near/helpers/core.d.ts.map +1 -0
- package/dist/types/near/helpers/gasEstimation.d.ts +41 -0
- package/dist/types/near/helpers/gasEstimation.d.ts.map +1 -0
- package/dist/types/near/helpers/nep141.d.ts +72 -0
- package/dist/types/near/helpers/nep141.d.ts.map +1 -0
- package/dist/types/near/index.d.ts +10 -0
- package/dist/types/near/index.d.ts.map +1 -0
- package/dist/types/near/toolbox.d.ts +4 -0
- package/dist/types/near/toolbox.d.ts.map +1 -0
- package/dist/types/near/types/contract.d.ts +38 -0
- package/dist/types/near/types/contract.d.ts.map +1 -0
- package/dist/types/near/types/nep141.d.ts +56 -0
- package/dist/types/near/types/nep141.d.ts.map +1 -0
- package/dist/types/near/types/toolbox.d.ts +57 -0
- package/dist/types/near/types/toolbox.d.ts.map +1 -0
- package/dist/types/near/types.d.ts +44 -0
- package/dist/types/near/types.d.ts.map +1 -0
- package/dist/types/radix/index.d.ts +14 -0
- package/dist/types/radix/index.d.ts.map +1 -0
- package/dist/types/ripple/index.d.ts +43 -0
- package/dist/types/ripple/index.d.ts.map +1 -0
- package/dist/types/solana/index.d.ts +37 -0
- package/dist/types/solana/index.d.ts.map +1 -0
- package/dist/types/solana/toolbox.d.ts +41 -0
- package/dist/types/solana/toolbox.d.ts.map +1 -0
- package/dist/types/substrate/balance.d.ts +17 -0
- package/dist/types/substrate/balance.d.ts.map +1 -0
- package/{src/substrate/index.ts → dist/types/substrate/index.d.ts} +1 -0
- package/dist/types/substrate/index.d.ts.map +1 -0
- package/dist/types/substrate/substrate.d.ts +148 -0
- package/dist/types/substrate/substrate.d.ts.map +1 -0
- package/dist/types/substrate/types.d.ts +100 -0
- package/dist/types/substrate/types.d.ts.map +1 -0
- package/dist/types/tron/helpers/trc20.abi.d.ts +156 -0
- package/dist/types/tron/helpers/trc20.abi.d.ts.map +1 -0
- package/dist/types/tron/helpers/trongrid.d.ts +8 -0
- package/dist/types/tron/helpers/trongrid.d.ts.map +1 -0
- package/dist/types/tron/index.d.ts +6 -0
- package/dist/types/tron/index.d.ts.map +1 -0
- package/dist/types/tron/toolbox.d.ts +26 -0
- package/dist/types/tron/toolbox.d.ts.map +1 -0
- package/dist/types/tron/types.d.ts +101 -0
- package/dist/types/tron/types.d.ts.map +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utxo/helpers/api.d.ts +133 -0
- package/dist/types/utxo/helpers/api.d.ts.map +1 -0
- package/dist/types/utxo/helpers/bchaddrjs.d.ts +10 -0
- package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -0
- package/dist/types/utxo/helpers/coinselect.d.ts +16 -0
- package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -0
- package/{src/utxo/helpers/index.ts → dist/types/utxo/helpers/index.d.ts} +1 -0
- package/dist/types/utxo/helpers/index.d.ts.map +1 -0
- package/dist/types/utxo/helpers/txSize.d.ts +21 -0
- package/dist/types/utxo/helpers/txSize.d.ts.map +1 -0
- package/{src/utxo/index.ts → dist/types/utxo/index.d.ts} +1 -0
- package/dist/types/utxo/index.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts +104 -0
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/index.d.ts +50 -0
- package/dist/types/utxo/toolbox/index.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/utxo.d.ts +102 -0
- package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/zcash.d.ts +83 -0
- package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -0
- package/dist/types/utxo/types.d.ts +46 -0
- package/dist/types/utxo/types.d.ts.map +1 -0
- package/package.json +15 -18
- package/dist/chunk-0h4xdrwz.js +0 -5
- package/dist/chunk-0h4xdrwz.js.map +0 -10
- package/dist/chunk-4yap1fvd.js +0 -4
- package/dist/chunk-4yap1fvd.js.map +0 -10
- package/dist/chunk-9bqegm61.js +0 -4
- package/dist/chunk-9bqegm61.js.map +0 -10
- package/dist/chunk-fazw0jvt.js +0 -4
- package/dist/chunk-fazw0jvt.js.map +0 -9
- package/dist/chunk-fjfxga2v.js +0 -4
- package/dist/chunk-fjfxga2v.js.map +0 -10
- package/dist/chunk-s47y8512.js +0 -5
- package/dist/chunk-s47y8512.js.map +0 -9
- package/dist/chunk-vtd17cje.js +0 -4
- package/dist/chunk-vtd17cje.js.map +0 -10
- package/dist/chunk-zcdeg6h9.js +0 -5
- package/dist/chunk-zcdeg6h9.js.map +0 -10
- package/src/cosmos/thorchainUtils/addressFormat.ts +0 -26
- package/src/cosmos/thorchainUtils/messages.ts +0 -262
- package/src/cosmos/thorchainUtils/registry.ts +0 -44
- package/src/cosmos/thorchainUtils/types/MsgCompiled.ts +0 -2800
- package/src/cosmos/thorchainUtils/types/client-types.ts +0 -73
- package/src/cosmos/thorchainUtils/types/index.ts +0 -1
- package/src/cosmos/toolbox/cosmos.ts +0 -375
- package/src/cosmos/toolbox/index.ts +0 -33
- package/src/cosmos/toolbox/thorchain.ts +0 -313
- package/src/cosmos/util.ts +0 -266
- package/src/evm/__tests__/address-validation.test.ts +0 -86
- package/src/evm/__tests__/ethereum.test.ts +0 -141
- package/src/evm/api.ts +0 -21
- package/src/evm/contracts/eth/multicall.ts +0 -165
- package/src/evm/contracts/op/gasOracle.ts +0 -151
- package/src/evm/helpers.ts +0 -194
- package/src/evm/toolbox/baseEVMToolbox.ts +0 -762
- package/src/evm/toolbox/evm.ts +0 -66
- package/src/evm/toolbox/index.ts +0 -52
- package/src/evm/toolbox/op.ts +0 -131
- package/src/evm/types.ts +0 -146
- package/src/index.ts +0 -263
- package/src/near/__tests__/core.test.ts +0 -80
- package/src/near/helpers/contractFactory.ts +0 -22
- package/src/near/helpers/core.ts +0 -91
- package/src/near/helpers/gasEstimation.ts +0 -110
- package/src/near/helpers/index.ts +0 -5
- package/src/near/helpers/nep141.ts +0 -110
- package/src/near/index.ts +0 -24
- package/src/near/toolbox.ts +0 -509
- package/src/near/types/contract.ts +0 -48
- package/src/near/types/nep141.ts +0 -66
- package/src/near/types.ts +0 -57
- package/src/radix/index.ts +0 -156
- package/src/ripple/index.ts +0 -192
- package/src/solana/index.ts +0 -55
- package/src/solana/toolbox.ts +0 -433
- package/src/substrate/balance.ts +0 -92
- package/src/substrate/substrate.ts +0 -320
- package/src/substrate/types.ts +0 -120
- package/src/tron/__tests__/toolbox.test.ts +0 -147
- package/src/tron/helpers/trc20.abi.ts +0 -107
- package/src/tron/helpers/trongrid.ts +0 -54
- package/src/tron/index.ts +0 -17
- package/src/tron/toolbox.ts +0 -650
- package/src/tron/types.ts +0 -120
- package/src/utils.ts +0 -27
- package/src/utxo/__tests__/zcash-integration.test.ts +0 -114
- package/src/utxo/helpers/api.ts +0 -560
- package/src/utxo/helpers/bchaddrjs.ts +0 -183
- package/src/utxo/helpers/coinselect.ts +0 -98
- package/src/utxo/helpers/txSize.ts +0 -104
- package/src/utxo/toolbox/bitcoinCash.ts +0 -320
- package/src/utxo/toolbox/index.ts +0 -90
- package/src/utxo/toolbox/utxo.ts +0 -525
- package/src/utxo/toolbox/zcash.ts +0 -208
- package/src/utxo/types.ts +0 -57
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import type ethers from "@nomicfoundation/hardhat-ethers";
|
|
3
|
-
import helpers from "@nomicfoundation/hardhat-network-helpers";
|
|
4
|
-
import { AssetValue, Chain, SKConfig } from "@swapkit/helpers";
|
|
5
|
-
import { erc20ABI } from "@swapkit/helpers/contracts";
|
|
6
|
-
import type { JsonRpcProvider } from "ethers";
|
|
7
|
-
import hre from "hardhat";
|
|
8
|
-
import { getProvider } from "../helpers";
|
|
9
|
-
import { getEvmToolbox } from "../toolbox";
|
|
10
|
-
|
|
11
|
-
const testAddress = "0x6d6e022eE439C8aB8B7a7dBb0576f8090319CDc6";
|
|
12
|
-
const emptyRecipient = "0xE29E61479420Dd1029A9946710Ac31A0d140e77F";
|
|
13
|
-
const USDCAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
14
|
-
// Get latest block to use as base for reset fork after test
|
|
15
|
-
const block = await hre.ethers.provider.getBlock("latest");
|
|
16
|
-
|
|
17
|
-
beforeAll(() => {
|
|
18
|
-
hre.run("node");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const context: {
|
|
22
|
-
ethers: typeof ethers;
|
|
23
|
-
provider: JsonRpcProvider;
|
|
24
|
-
toolbox: Awaited<ReturnType<typeof getEvmToolbox>>;
|
|
25
|
-
} = {} as any;
|
|
26
|
-
|
|
27
|
-
beforeEach(async () => {
|
|
28
|
-
context.ethers = hre.artifacts;
|
|
29
|
-
const provider = await getProvider(Chain.Ethereum, "http://127.0.0.1:8545/");
|
|
30
|
-
const signer = await hre.ethers.getImpersonatedSigner(testAddress);
|
|
31
|
-
|
|
32
|
-
SKConfig.set({
|
|
33
|
-
apiKeys: {
|
|
34
|
-
swapKit: process.env.TEST_API_KEY || Bun.env.TEST_API_KEY,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
context.provider = provider;
|
|
38
|
-
context.toolbox = await getEvmToolbox(Chain.Ethereum, { provider, signer: signer as any });
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterEach(async () => {
|
|
42
|
-
await helpers.reset(hre.config.networks.hardhat.forking?.url, block?.number);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("Ethereum toolkit", () => {
|
|
46
|
-
// biome-ignore lint/suspicious/noSkippedTests: env not setup correctly
|
|
47
|
-
test.skip("Get Balances", async () => {
|
|
48
|
-
const balances = await context.toolbox.getBalance(testAddress);
|
|
49
|
-
expect(balances.find((balance) => balance.symbol === "ETH")?.getBaseValue("string")).toBe(
|
|
50
|
-
"20526000000000000",
|
|
51
|
-
);
|
|
52
|
-
expect(
|
|
53
|
-
balances
|
|
54
|
-
.find(
|
|
55
|
-
(balance) =>
|
|
56
|
-
balance.symbol.toLowerCase() ===
|
|
57
|
-
"USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".toLowerCase(),
|
|
58
|
-
)
|
|
59
|
-
?.getBaseValue("string"),
|
|
60
|
-
).toBe("6656178");
|
|
61
|
-
}, 10000);
|
|
62
|
-
|
|
63
|
-
test("Send ETH", async () => {
|
|
64
|
-
expect((await context.provider.getBalance(emptyRecipient)).toString()).toBe("0");
|
|
65
|
-
await context.toolbox.transfer({
|
|
66
|
-
recipient: emptyRecipient,
|
|
67
|
-
assetValue: await AssetValue.from({ chain: Chain.Ethereum, value: "0.010526" }),
|
|
68
|
-
sender: testAddress,
|
|
69
|
-
});
|
|
70
|
-
expect((await context.provider.getBalance(emptyRecipient)).toString()).toBe(
|
|
71
|
-
"10526000000000000",
|
|
72
|
-
);
|
|
73
|
-
}, 10000);
|
|
74
|
-
|
|
75
|
-
test("Send Token", async () => {
|
|
76
|
-
const USDC = await context.toolbox.createContract(USDCAddress, erc20ABI);
|
|
77
|
-
const balance = await USDC.balanceOf?.(emptyRecipient);
|
|
78
|
-
expect(balance.toString()).toBe("0");
|
|
79
|
-
|
|
80
|
-
await AssetValue.loadStaticAssets(["thorchain"]);
|
|
81
|
-
|
|
82
|
-
const assetValue = AssetValue.from({
|
|
83
|
-
asset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
84
|
-
value: "1",
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
await context.toolbox.transfer({
|
|
88
|
-
recipient: emptyRecipient,
|
|
89
|
-
assetValue,
|
|
90
|
-
sender: testAddress,
|
|
91
|
-
});
|
|
92
|
-
// biome-ignore lint/correctness/noUnsafeOptionalChaining: <explanation>
|
|
93
|
-
expect((await USDC.balanceOf?.(emptyRecipient)).toString()).toBe("1000000");
|
|
94
|
-
}, 10000);
|
|
95
|
-
|
|
96
|
-
test("Approve Token and validate approved amount", async () => {
|
|
97
|
-
expect(
|
|
98
|
-
await context.toolbox.isApproved({
|
|
99
|
-
assetAddress: USDCAddress,
|
|
100
|
-
spenderAddress: emptyRecipient,
|
|
101
|
-
from: testAddress,
|
|
102
|
-
amount: "1000000",
|
|
103
|
-
}),
|
|
104
|
-
).toBe(false);
|
|
105
|
-
|
|
106
|
-
await context.toolbox.approve({
|
|
107
|
-
assetAddress: USDCAddress,
|
|
108
|
-
spenderAddress: emptyRecipient,
|
|
109
|
-
amount: "1000000",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(
|
|
113
|
-
await context.toolbox.isApproved({
|
|
114
|
-
assetAddress: USDCAddress,
|
|
115
|
-
spenderAddress: emptyRecipient,
|
|
116
|
-
from: testAddress,
|
|
117
|
-
amount: "1000000",
|
|
118
|
-
}),
|
|
119
|
-
).toBe(true);
|
|
120
|
-
}, 10000);
|
|
121
|
-
|
|
122
|
-
test("Create contract tx object and sendTransaction", async () => {
|
|
123
|
-
const USDC = context.toolbox.createContract(USDCAddress, erc20ABI);
|
|
124
|
-
const balance = await USDC.balanceOf?.(emptyRecipient);
|
|
125
|
-
expect(balance.toString()).toBe("0");
|
|
126
|
-
|
|
127
|
-
const txObject = await context.toolbox.createContractTxObject({
|
|
128
|
-
contractAddress: USDCAddress,
|
|
129
|
-
abi: erc20ABI,
|
|
130
|
-
funcName: "transfer",
|
|
131
|
-
funcParams: [emptyRecipient, BigInt("2222222")],
|
|
132
|
-
txOverrides: {
|
|
133
|
-
from: testAddress,
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
await context.toolbox.sendTransaction(txObject);
|
|
138
|
-
// biome-ignore lint/correctness/noUnsafeOptionalChaining: <explanation>
|
|
139
|
-
expect((await USDC?.balanceOf?.(emptyRecipient)).toString()).toBe("2222222");
|
|
140
|
-
}, 10000);
|
|
141
|
-
});
|
package/src/evm/api.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type EVMChain, SKConfig, warnOnce } from "@swapkit/helpers";
|
|
2
|
-
import { getBalance } from "../utils";
|
|
3
|
-
|
|
4
|
-
export function getEvmApi(chain: EVMChain) {
|
|
5
|
-
const customEvmApi = SKConfig.get("apis")[chain];
|
|
6
|
-
|
|
7
|
-
if (customEvmApi) {
|
|
8
|
-
warnOnce(true, "Using custom EVM API. Be sure to implement all methods to avoid issues.");
|
|
9
|
-
return customEvmApi as ReturnType<typeof evmApi>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return evmApi(chain);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function createCustomEvmApi(methods: ReturnType<typeof getEvmApi>) {
|
|
16
|
-
return methods;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function evmApi(chain: EVMChain) {
|
|
20
|
-
return { getBalance: getBalance(chain) };
|
|
21
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
export const multicallAbi = [
|
|
2
|
-
{
|
|
3
|
-
inputs: [
|
|
4
|
-
{
|
|
5
|
-
components: [
|
|
6
|
-
{ internalType: "address", name: "target", type: "address" },
|
|
7
|
-
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
8
|
-
],
|
|
9
|
-
internalType: "struct Multicall2.Call[]",
|
|
10
|
-
name: "calls",
|
|
11
|
-
type: "tuple[]",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
name: "aggregate",
|
|
15
|
-
outputs: [
|
|
16
|
-
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
17
|
-
{ internalType: "bytes[]", name: "returnData", type: "bytes[]" },
|
|
18
|
-
],
|
|
19
|
-
stateMutability: "nonpayable",
|
|
20
|
-
type: "function",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
inputs: [
|
|
24
|
-
{
|
|
25
|
-
components: [
|
|
26
|
-
{ internalType: "address", name: "target", type: "address" },
|
|
27
|
-
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
28
|
-
],
|
|
29
|
-
internalType: "struct Multicall2.Call[]",
|
|
30
|
-
name: "calls",
|
|
31
|
-
type: "tuple[]",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
name: "blockAndAggregate",
|
|
35
|
-
outputs: [
|
|
36
|
-
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
37
|
-
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
38
|
-
{
|
|
39
|
-
components: [
|
|
40
|
-
{ internalType: "bool", name: "success", type: "bool" },
|
|
41
|
-
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
42
|
-
],
|
|
43
|
-
internalType: "struct Multicall2.Result[]",
|
|
44
|
-
name: "returnData",
|
|
45
|
-
type: "tuple[]",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
stateMutability: "nonpayable",
|
|
49
|
-
type: "function",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
inputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }],
|
|
53
|
-
name: "getBlockHash",
|
|
54
|
-
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
55
|
-
stateMutability: "view",
|
|
56
|
-
type: "function",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
inputs: [],
|
|
60
|
-
name: "getBlockNumber",
|
|
61
|
-
outputs: [{ internalType: "uint256", name: "blockNumber", type: "uint256" }],
|
|
62
|
-
stateMutability: "view",
|
|
63
|
-
type: "function",
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
inputs: [],
|
|
67
|
-
name: "getCurrentBlockCoinbase",
|
|
68
|
-
outputs: [{ internalType: "address", name: "coinbase", type: "address" }],
|
|
69
|
-
stateMutability: "view",
|
|
70
|
-
type: "function",
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
inputs: [],
|
|
74
|
-
name: "getCurrentBlockDifficulty",
|
|
75
|
-
outputs: [{ internalType: "uint256", name: "difficulty", type: "uint256" }],
|
|
76
|
-
stateMutability: "view",
|
|
77
|
-
type: "function",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
inputs: [],
|
|
81
|
-
name: "getCurrentBlockGasLimit",
|
|
82
|
-
outputs: [{ internalType: "uint256", name: "gaslimit", type: "uint256" }],
|
|
83
|
-
stateMutability: "view",
|
|
84
|
-
type: "function",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
inputs: [],
|
|
88
|
-
name: "getCurrentBlockTimestamp",
|
|
89
|
-
outputs: [{ internalType: "uint256", name: "timestamp", type: "uint256" }],
|
|
90
|
-
stateMutability: "view",
|
|
91
|
-
type: "function",
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
inputs: [{ internalType: "address", name: "addr", type: "address" }],
|
|
95
|
-
name: "getEthBalance",
|
|
96
|
-
outputs: [{ internalType: "uint256", name: "balance", type: "uint256" }],
|
|
97
|
-
stateMutability: "view",
|
|
98
|
-
type: "function",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
inputs: [],
|
|
102
|
-
name: "getLastBlockHash",
|
|
103
|
-
outputs: [{ internalType: "bytes32", name: "blockHash", type: "bytes32" }],
|
|
104
|
-
stateMutability: "view",
|
|
105
|
-
type: "function",
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
inputs: [
|
|
109
|
-
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
110
|
-
{
|
|
111
|
-
components: [
|
|
112
|
-
{ internalType: "address", name: "target", type: "address" },
|
|
113
|
-
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
114
|
-
],
|
|
115
|
-
internalType: "struct Multicall2.Call[]",
|
|
116
|
-
name: "calls",
|
|
117
|
-
type: "tuple[]",
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
name: "tryAggregate",
|
|
121
|
-
outputs: [
|
|
122
|
-
{
|
|
123
|
-
components: [
|
|
124
|
-
{ internalType: "bool", name: "success", type: "bool" },
|
|
125
|
-
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
126
|
-
],
|
|
127
|
-
internalType: "struct Multicall2.Result[]",
|
|
128
|
-
name: "returnData",
|
|
129
|
-
type: "tuple[]",
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
stateMutability: "nonpayable",
|
|
133
|
-
type: "function",
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
inputs: [
|
|
137
|
-
{ internalType: "bool", name: "requireSuccess", type: "bool" },
|
|
138
|
-
{
|
|
139
|
-
components: [
|
|
140
|
-
{ internalType: "address", name: "target", type: "address" },
|
|
141
|
-
{ internalType: "bytes", name: "callData", type: "bytes" },
|
|
142
|
-
],
|
|
143
|
-
internalType: "struct Multicall2.Call[]",
|
|
144
|
-
name: "calls",
|
|
145
|
-
type: "tuple[]",
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
name: "tryBlockAndAggregate",
|
|
149
|
-
outputs: [
|
|
150
|
-
{ internalType: "uint256", name: "blockNumber", type: "uint256" },
|
|
151
|
-
{ internalType: "bytes32", name: "blockHash", type: "bytes32" },
|
|
152
|
-
{
|
|
153
|
-
components: [
|
|
154
|
-
{ internalType: "bool", name: "success", type: "bool" },
|
|
155
|
-
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
156
|
-
],
|
|
157
|
-
internalType: "struct Multicall2.Result[]",
|
|
158
|
-
name: "returnData",
|
|
159
|
-
type: "tuple[]",
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
stateMutability: "nonpayable",
|
|
163
|
-
type: "function",
|
|
164
|
-
},
|
|
165
|
-
];
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
export const gasOracleAbi = [
|
|
2
|
-
{
|
|
3
|
-
inputs: [{ internalType: "address", name: "_owner", type: "address" }],
|
|
4
|
-
stateMutability: "nonpayable",
|
|
5
|
-
type: "constructor",
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
anonymous: false,
|
|
9
|
-
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
10
|
-
name: "DecimalsUpdated",
|
|
11
|
-
type: "event",
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
anonymous: false,
|
|
15
|
-
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
16
|
-
name: "GasPriceUpdated",
|
|
17
|
-
type: "event",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
anonymous: false,
|
|
21
|
-
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
22
|
-
name: "L1BaseFeeUpdated",
|
|
23
|
-
type: "event",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
anonymous: false,
|
|
27
|
-
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
28
|
-
name: "OverheadUpdated",
|
|
29
|
-
type: "event",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
anonymous: false,
|
|
33
|
-
inputs: [
|
|
34
|
-
{ indexed: true, internalType: "address", name: "previousOwner", type: "address" },
|
|
35
|
-
{ indexed: true, internalType: "address", name: "newOwner", type: "address" },
|
|
36
|
-
],
|
|
37
|
-
name: "OwnershipTransferred",
|
|
38
|
-
type: "event",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
anonymous: false,
|
|
42
|
-
inputs: [{ indexed: false, internalType: "uint256", name: "", type: "uint256" }],
|
|
43
|
-
name: "ScalarUpdated",
|
|
44
|
-
type: "event",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
inputs: [],
|
|
48
|
-
name: "decimals",
|
|
49
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
50
|
-
stateMutability: "view",
|
|
51
|
-
type: "function",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
inputs: [],
|
|
55
|
-
name: "gasPrice",
|
|
56
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
57
|
-
stateMutability: "view",
|
|
58
|
-
type: "function",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
|
|
62
|
-
name: "getL1Fee",
|
|
63
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
64
|
-
stateMutability: "view",
|
|
65
|
-
type: "function",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
inputs: [{ internalType: "bytes", name: "_data", type: "bytes" }],
|
|
69
|
-
name: "getL1GasUsed",
|
|
70
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
71
|
-
stateMutability: "view",
|
|
72
|
-
type: "function",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
inputs: [],
|
|
76
|
-
name: "l1BaseFee",
|
|
77
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
78
|
-
stateMutability: "view",
|
|
79
|
-
type: "function",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
inputs: [],
|
|
83
|
-
name: "overhead",
|
|
84
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
85
|
-
stateMutability: "view",
|
|
86
|
-
type: "function",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
inputs: [],
|
|
90
|
-
name: "owner",
|
|
91
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
92
|
-
stateMutability: "view",
|
|
93
|
-
type: "function",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
inputs: [],
|
|
97
|
-
name: "renounceOwnership",
|
|
98
|
-
outputs: [],
|
|
99
|
-
stateMutability: "nonpayable",
|
|
100
|
-
type: "function",
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
inputs: [],
|
|
104
|
-
name: "scalar",
|
|
105
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
106
|
-
stateMutability: "view",
|
|
107
|
-
type: "function",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
inputs: [{ internalType: "uint256", name: "_decimals", type: "uint256" }],
|
|
111
|
-
name: "setDecimals",
|
|
112
|
-
outputs: [],
|
|
113
|
-
stateMutability: "nonpayable",
|
|
114
|
-
type: "function",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
inputs: [{ internalType: "uint256", name: "_gasPrice", type: "uint256" }],
|
|
118
|
-
name: "setGasPrice",
|
|
119
|
-
outputs: [],
|
|
120
|
-
stateMutability: "nonpayable",
|
|
121
|
-
type: "function",
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
inputs: [{ internalType: "uint256", name: "_baseFee", type: "uint256" }],
|
|
125
|
-
name: "setL1BaseFee",
|
|
126
|
-
outputs: [],
|
|
127
|
-
stateMutability: "nonpayable",
|
|
128
|
-
type: "function",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
inputs: [{ internalType: "uint256", name: "_overhead", type: "uint256" }],
|
|
132
|
-
name: "setOverhead",
|
|
133
|
-
outputs: [],
|
|
134
|
-
stateMutability: "nonpayable",
|
|
135
|
-
type: "function",
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
inputs: [{ internalType: "uint256", name: "_scalar", type: "uint256" }],
|
|
139
|
-
name: "setScalar",
|
|
140
|
-
outputs: [],
|
|
141
|
-
stateMutability: "nonpayable",
|
|
142
|
-
type: "function",
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
|
146
|
-
name: "transferOwnership",
|
|
147
|
-
outputs: [],
|
|
148
|
-
stateMutability: "nonpayable",
|
|
149
|
-
type: "function",
|
|
150
|
-
},
|
|
151
|
-
];
|
package/src/evm/helpers.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AssetValue,
|
|
3
|
-
BaseDecimal,
|
|
4
|
-
Chain,
|
|
5
|
-
ChainToExplorerUrl,
|
|
6
|
-
ChainToHexChainId,
|
|
7
|
-
type EVMChain,
|
|
8
|
-
FeeOption,
|
|
9
|
-
type NetworkParams,
|
|
10
|
-
SKConfig,
|
|
11
|
-
SwapKitError,
|
|
12
|
-
SwapKitNumber,
|
|
13
|
-
} from "@swapkit/helpers";
|
|
14
|
-
import type { BrowserProvider, Provider } from "ethers";
|
|
15
|
-
|
|
16
|
-
import { getEstimateGasPrices } from "./toolbox/baseEVMToolbox";
|
|
17
|
-
import type { EIP1559TxParams, EVMMaxSendableAmountsParams } from "./types";
|
|
18
|
-
|
|
19
|
-
export async function getProvider(chain: EVMChain, customUrl?: string) {
|
|
20
|
-
const { JsonRpcProvider } = await import("ethers");
|
|
21
|
-
|
|
22
|
-
return new JsonRpcProvider(customUrl || SKConfig.get("rpcUrls")[chain]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated
|
|
27
|
-
*/
|
|
28
|
-
export const estimateMaxSendableAmount = async ({
|
|
29
|
-
from,
|
|
30
|
-
memo = "",
|
|
31
|
-
feeOptionKey = FeeOption.Fastest,
|
|
32
|
-
assetValue,
|
|
33
|
-
abi,
|
|
34
|
-
funcName,
|
|
35
|
-
funcParams,
|
|
36
|
-
contractAddress,
|
|
37
|
-
txOverrides,
|
|
38
|
-
}: EVMMaxSendableAmountsParams): Promise<AssetValue> => {
|
|
39
|
-
const { getEvmToolbox } = await import("@swapkit/toolboxes/evm");
|
|
40
|
-
const toolbox = await getEvmToolbox(assetValue.chain as EVMChain);
|
|
41
|
-
|
|
42
|
-
const balances = await toolbox.getBalance(from);
|
|
43
|
-
const balance = balances.find(({ symbol, chain }) =>
|
|
44
|
-
assetValue ? symbol === assetValue.symbol : symbol === AssetValue.from({ chain })?.symbol,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const gasRate = (await toolbox.estimateGasPrices())[feeOptionKey];
|
|
48
|
-
|
|
49
|
-
if (!balance) return AssetValue.from({ chain: assetValue.chain });
|
|
50
|
-
|
|
51
|
-
if (assetValue && (balance.chain !== assetValue.chain || balance.symbol !== assetValue?.symbol)) {
|
|
52
|
-
return balance;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const gasLimit =
|
|
56
|
-
abi && funcName && funcParams && contractAddress
|
|
57
|
-
? await toolbox.estimateCall({
|
|
58
|
-
contractAddress,
|
|
59
|
-
abi,
|
|
60
|
-
funcName,
|
|
61
|
-
funcParams,
|
|
62
|
-
txOverrides,
|
|
63
|
-
})
|
|
64
|
-
: await toolbox.estimateGasLimit({
|
|
65
|
-
sender: from,
|
|
66
|
-
recipient: from,
|
|
67
|
-
memo,
|
|
68
|
-
assetValue,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const isFeeEIP1559Compatible = "maxFeePerGas" in gasRate;
|
|
72
|
-
const isFeeEVMLegacyCompatible = "gasPrice" in gasRate && gasRate.gasPrice !== undefined;
|
|
73
|
-
|
|
74
|
-
if (!(gasRate && (isFeeEVMLegacyCompatible || isFeeEIP1559Compatible))) {
|
|
75
|
-
throw new SwapKitError("toolbox_evm_no_fee_data");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const gasPrice = isFeeEIP1559Compatible
|
|
79
|
-
? (gasRate.maxFeePerGas || 1n) + (gasRate.maxPriorityFeePerGas || 1n)
|
|
80
|
-
: gasRate.gasPrice || 1n;
|
|
81
|
-
|
|
82
|
-
const fee = gasLimit * gasPrice;
|
|
83
|
-
const maxSendableAmount = SwapKitNumber.fromBigInt(balance.getBaseValue("bigint")).sub(
|
|
84
|
-
fee.toString(),
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return AssetValue.from({ chain: balance.chain, value: maxSendableAmount.getValue("string") });
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export function toHexString(value: bigint) {
|
|
91
|
-
return value > 0n ? `0x${value.toString(16)}` : "0x0";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function getEstimateTransactionFee({
|
|
95
|
-
provider,
|
|
96
|
-
isEIP1559Compatible = true,
|
|
97
|
-
}: { provider: Provider | BrowserProvider; isEIP1559Compatible?: boolean; chain: EVMChain }) {
|
|
98
|
-
return async function estimateTransactionFee({
|
|
99
|
-
feeOption = FeeOption.Fast,
|
|
100
|
-
chain,
|
|
101
|
-
...txObject
|
|
102
|
-
}: EIP1559TxParams & { feeOption: FeeOption; chain: EVMChain }) {
|
|
103
|
-
const estimateGasPrices = getEstimateGasPrices({ provider, isEIP1559Compatible, chain });
|
|
104
|
-
const gasPrices = await estimateGasPrices();
|
|
105
|
-
const gasLimit = await provider.estimateGas(txObject);
|
|
106
|
-
|
|
107
|
-
const assetValue = AssetValue.from({ chain });
|
|
108
|
-
const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = gasPrices[feeOption];
|
|
109
|
-
|
|
110
|
-
if (!isEIP1559Compatible && gasPrice) {
|
|
111
|
-
return assetValue.set(SwapKitNumber.fromBigInt(gasPrice * gasLimit, assetValue.decimal));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (maxFeePerGas && maxPriorityFeePerGas) {
|
|
115
|
-
const fee = (maxFeePerGas + maxPriorityFeePerGas) * gasLimit;
|
|
116
|
-
|
|
117
|
-
return assetValue.set(SwapKitNumber.fromBigInt(fee, assetValue.decimal));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
throw new SwapKitError("toolbox_evm_no_gas_price");
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function getNetworkParams<C extends EVMChain>(chain: C) {
|
|
125
|
-
return () =>
|
|
126
|
-
(Chain.Ethereum === chain
|
|
127
|
-
? undefined
|
|
128
|
-
: {
|
|
129
|
-
...getNetworkInfo({ chain }),
|
|
130
|
-
chainId: ChainToHexChainId[chain],
|
|
131
|
-
rpcUrls: [SKConfig.get("rpcUrls")[chain]],
|
|
132
|
-
blockExplorerUrls: [ChainToExplorerUrl[chain]],
|
|
133
|
-
}) as C extends Chain.Ethereum ? undefined : NetworkParams;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function getIsEIP1559Compatible<C extends EVMChain>(chain: C) {
|
|
137
|
-
const notCompatible = [Chain.Arbitrum, Chain.BinanceSmartChain];
|
|
138
|
-
|
|
139
|
-
return !notCompatible.includes(chain);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getNetworkInfo<C extends EVMChain>({ chain }: { chain: C }) {
|
|
143
|
-
const decimals = BaseDecimal[chain];
|
|
144
|
-
|
|
145
|
-
switch (chain) {
|
|
146
|
-
case Chain.Arbitrum:
|
|
147
|
-
return {
|
|
148
|
-
chainName: "Arbitrum One",
|
|
149
|
-
nativeCurrency: { name: "Ethereum", symbol: Chain.Ethereum, decimals },
|
|
150
|
-
};
|
|
151
|
-
case Chain.Aurora:
|
|
152
|
-
return {
|
|
153
|
-
chainName: "Aurora Mainnet",
|
|
154
|
-
nativeCurrency: { name: "Ethereum", symbol: Chain.Ethereum, decimals },
|
|
155
|
-
};
|
|
156
|
-
case Chain.Avalanche:
|
|
157
|
-
return {
|
|
158
|
-
chainName: "Avalanche Network",
|
|
159
|
-
nativeCurrency: { name: "Avalanche", symbol: chain, decimals },
|
|
160
|
-
};
|
|
161
|
-
case Chain.Base:
|
|
162
|
-
return {
|
|
163
|
-
chainName: "Base Mainnet",
|
|
164
|
-
nativeCurrency: { name: "Ethereum", symbol: Chain.Ethereum, decimals },
|
|
165
|
-
};
|
|
166
|
-
case Chain.Berachain:
|
|
167
|
-
return {
|
|
168
|
-
chainName: "Berachain",
|
|
169
|
-
nativeCurrency: { name: "Berachain", symbol: "BERA", decimals },
|
|
170
|
-
};
|
|
171
|
-
case Chain.BinanceSmartChain:
|
|
172
|
-
return {
|
|
173
|
-
chainName: "BNB Smart Chain Mainnet",
|
|
174
|
-
nativeCurrency: { name: "Binance Coin", symbol: "BNB", decimals },
|
|
175
|
-
};
|
|
176
|
-
case Chain.Gnosis:
|
|
177
|
-
return {
|
|
178
|
-
chainName: "Gnosis",
|
|
179
|
-
nativeCurrency: { name: "xDAI", symbol: "XDAI", decimals },
|
|
180
|
-
};
|
|
181
|
-
case Chain.Optimism:
|
|
182
|
-
return {
|
|
183
|
-
chainName: "OP Mainnet",
|
|
184
|
-
nativeCurrency: { name: "Ethereum", symbol: Chain.Ethereum, decimals },
|
|
185
|
-
};
|
|
186
|
-
case Chain.Polygon:
|
|
187
|
-
return {
|
|
188
|
-
chainName: "Polygon Mainnet",
|
|
189
|
-
nativeCurrency: { name: "Polygon", symbol: Chain.Polygon, decimals },
|
|
190
|
-
};
|
|
191
|
-
default:
|
|
192
|
-
throw new SwapKitError("toolbox_evm_not_supported", { chain });
|
|
193
|
-
}
|
|
194
|
-
}
|