@paraswap/dex-lib 4.0.22 → 4.0.23
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
- package/build/abi/{wombat/pool.json → integral/relayer.json} +720 -473
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -23
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/balancer-v2/config.js +1 -1
- package/build/dex/balancer-v2/config.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
- package/build/dex/generic-rfq/e2e-test-config.js +3 -3
- package/build/dex/generic-rfq/e2e-test-config.js.map +1 -1
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +1 -2
- package/build/dex/jarvis.js +0 -58
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/maverick-v1/config.js +1 -1
- package/build/dex/maverick-v1/config.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -45
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/stable-pool.js +8 -1
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -14
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
- package/build/dex/uniswap-v3/config.js +1 -1
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/zerox/index.d.ts +26 -4
- package/build/dex/zerox/index.js +42 -50
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +0 -29
- package/build/dex/zerox/types.js +1 -8
- package/build/dex/zerox/types.js.map +1 -1
- package/package.json +1 -1
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +165 -102
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +238 -80
- package/src/dex/balancer-v2/config.ts +1 -2
- package/src/dex/generic-rfq/e2e-test-config.ts +3 -3
- package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +2 -2
- package/src/dex/maverick-v1/config.ts +1 -2
- package/src/dex/uniswap-v3/config.ts +1 -2
- package/tests/constants-e2e.ts +1 -1
- package/tests/smart-tokens.ts +1 -3
- package/tests/tenderly-simulation.ts +149 -84
- package/tests/utils-e2e.ts +5 -2
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/build/abi/inception/inception-ratio-feed.json +0 -329
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/abi/usual-m-smart-m/usualM.abi.json +0 -483
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
- package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +0 -34
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +0 -406
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -4
- package/build/dex/inception/config.js +0 -109
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -16
- package/build/dex/inception/inception-event-pool.js +0 -49
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -43
- package/build/dex/inception/inception.js +0 -180
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -7
- package/build/dex/inception/utils.js +0 -58
- package/build/dex/inception/utils.js.map +0 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
- package/build/dex/usual/usual-m-smart-m.d.ts +0 -17
- package/build/dex/usual/usual-m-smart-m.js +0 -50
- package/build/dex/usual/usual-m-smart-m.js.map +0 -1
- package/build/dex/usual-m-smart-m/config.d.ts +0 -3
- package/build/dex/usual-m-smart-m/config.js +0 -13
- package/build/dex/usual-m-smart-m/config.js.map +0 -1
- package/build/dex/usual-m-smart-m/types.d.ts +0 -7
- package/build/dex/usual-m-smart-m/types.js +0 -3
- package/build/dex/usual-m-smart-m/types.js.map +0 -1
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +0 -35
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +0 -161
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +0 -1
- package/build/dex/usual-m-usd0/config.d.ts +0 -3
- package/build/dex/usual-m-usd0/config.js +0 -14
- package/build/dex/usual-m-usd0/config.js.map +0 -1
- package/build/dex/usual-m-usd0/types.d.ts +0 -8
- package/build/dex/usual-m-usd0/types.js +0 -3
- package/build/dex/usual-m-usd0/types.js.map +0 -1
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +0 -35
- package/build/dex/usual-m-usd0/usual-m-usd0.js +0 -159
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { Address } from '@paraswap/core';
|
|
4
3
|
import { TxObject } from '../src/types';
|
|
5
4
|
import { StateOverrides, StateSimulateApiOverride } from './smart-tokens';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
6
|
+
import { ethers } from 'ethers';
|
|
7
|
+
import { Network } from '../build/constants';
|
|
8
|
+
import { Address } from '@paraswap/core';
|
|
8
9
|
|
|
9
10
|
const TENDERLY_TOKEN = process.env.TENDERLY_TOKEN;
|
|
10
11
|
const TENDERLY_ACCOUNT_ID = process.env.TENDERLY_ACCOUNT_ID;
|
|
11
12
|
const TENDERLY_PROJECT = process.env.TENDERLY_PROJECT;
|
|
12
|
-
const
|
|
13
|
-
const TENDERLY_TEST_NET_RPC = process.env.TENDERLY_TEST_NET_RPC;
|
|
14
|
-
const TENDERLY_FORK_LAST_TX_ID = process.env.TENDERLY_FORK_LAST_TX_ID;
|
|
13
|
+
const TENDERLY_VNET_ID = process.env.TENDERLY_VNET_ID;
|
|
15
14
|
|
|
16
15
|
export type SimulationResult = {
|
|
17
16
|
success: boolean;
|
|
@@ -21,9 +20,11 @@ export type SimulationResult = {
|
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
export interface TransactionSimulator {
|
|
24
|
-
|
|
23
|
+
vnetId: string;
|
|
25
24
|
setup(): Promise<void>;
|
|
26
25
|
|
|
26
|
+
getChainNameByChainId(network: number): string;
|
|
27
|
+
|
|
27
28
|
simulate(
|
|
28
29
|
params: TxObject,
|
|
29
30
|
stateOverrides?: StateOverrides,
|
|
@@ -31,12 +32,16 @@ export interface TransactionSimulator {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export class EstimateGasSimulation implements TransactionSimulator {
|
|
34
|
-
|
|
35
|
+
vnetId: string = '0';
|
|
35
36
|
|
|
36
37
|
constructor(private provider: Provider) {}
|
|
37
38
|
|
|
38
39
|
async setup() {}
|
|
39
40
|
|
|
41
|
+
getChainNameByChainId(network: number) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
async simulate(
|
|
41
46
|
params: TxObject,
|
|
42
47
|
_: StateOverrides,
|
|
@@ -57,59 +62,106 @@ export class EstimateGasSimulation implements TransactionSimulator {
|
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
export class TenderlySimulation implements TransactionSimulator {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
forkId: string = '';
|
|
65
|
+
vnetId: string = '';
|
|
66
|
+
rpcURL: string = '';
|
|
63
67
|
maxGasLimit = 80000000;
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
private readonly chainIdToChainNameMap: { [key: number]: string } = {
|
|
70
|
+
[Network.MAINNET]: 'mainnet',
|
|
71
|
+
[Network.BSC]: 'bnb',
|
|
72
|
+
[Network.POLYGON]: 'polygon',
|
|
73
|
+
[Network.AVALANCHE]: 'avalanche-mainnet',
|
|
74
|
+
[Network.FANTOM]: 'fantom',
|
|
75
|
+
[Network.ARBITRUM]: 'arbitrum',
|
|
76
|
+
[Network.OPTIMISM]: 'optimistic',
|
|
77
|
+
[Network.GNOSIS]: 'gnosis-chain',
|
|
78
|
+
[Network.BASE]: 'base',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
constructor(private network: number = 1) {}
|
|
82
|
+
|
|
83
|
+
getChainNameByChainId(network: number): string {
|
|
84
|
+
return this.chainIdToChainNameMap[network];
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
async setup() {
|
|
77
|
-
// Fork the mainnet
|
|
78
88
|
if (!TENDERLY_TOKEN)
|
|
79
89
|
throw new Error(
|
|
80
90
|
`TenderlySimulation_setup: TENDERLY_TOKEN not found in the env`,
|
|
81
91
|
);
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
const findAdminRPC = (rpcs: { name: string; url: string }[]) => {
|
|
94
|
+
return rpcs.find(
|
|
95
|
+
rpc => rpc.name.toLowerCase() === 'Admin RPC'.toLowerCase(),
|
|
96
|
+
);
|
|
97
|
+
};
|
|
84
98
|
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
if (TENDERLY_VNET_ID) {
|
|
100
|
+
this.vnetId = TENDERLY_VNET_ID;
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
let res = await axios.get(
|
|
104
|
+
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/vnets/${this.vnetId}`,
|
|
105
|
+
{
|
|
106
|
+
timeout: 200000,
|
|
107
|
+
headers: {
|
|
108
|
+
'x-access-key': TENDERLY_TOKEN,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const rpc = findAdminRPC(res.data.rpcs);
|
|
114
|
+
|
|
115
|
+
if (!rpc) {
|
|
116
|
+
throw new Error(`RPC url was not found for testnet: ${this.vnetId}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.rpcURL = rpc.url;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error(`TenderlySimulation_setup:`, e);
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
91
124
|
|
|
92
|
-
if (TENDERLY_TEST_NET_RPC) {
|
|
93
|
-
this.testNetRPC = new StaticJsonRpcProvider(TENDERLY_TEST_NET_RPC);
|
|
94
125
|
return;
|
|
95
126
|
}
|
|
96
127
|
|
|
97
128
|
try {
|
|
98
129
|
await process.nextTick(() => {}); // https://stackoverflow.com/questions/69169492/async-external-function-leaves-open-handles-jest-supertest-express
|
|
99
130
|
let res = await axios.post(
|
|
100
|
-
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/
|
|
131
|
+
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/vnets`,
|
|
101
132
|
{
|
|
102
|
-
|
|
133
|
+
slug: `e2e-tests-testnetwork-${this.network.toString()}-${Date.now()}`,
|
|
134
|
+
fork_config: {
|
|
135
|
+
network_id: this.network,
|
|
136
|
+
},
|
|
137
|
+
virtual_network_config: {
|
|
138
|
+
chain_config: {
|
|
139
|
+
chain_id: this.network,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
sync_state_config: {
|
|
143
|
+
enabled: false,
|
|
144
|
+
},
|
|
145
|
+
explorer_page_config: {
|
|
146
|
+
enabled: true,
|
|
147
|
+
verification_visibility: 'bytecode',
|
|
148
|
+
},
|
|
103
149
|
},
|
|
104
150
|
{
|
|
105
|
-
timeout:
|
|
151
|
+
timeout: 200000,
|
|
106
152
|
headers: {
|
|
107
153
|
'x-access-key': TENDERLY_TOKEN,
|
|
108
154
|
},
|
|
109
155
|
},
|
|
110
156
|
);
|
|
111
|
-
|
|
112
|
-
this.
|
|
157
|
+
|
|
158
|
+
this.vnetId = res.data.id;
|
|
159
|
+
const rpc = findAdminRPC(res.data.rpcs);
|
|
160
|
+
if (!rpc) {
|
|
161
|
+
throw new Error(`RPC url was not found for testnet: ${this.vnetId}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.rpcURL = rpc.url;
|
|
113
165
|
} catch (e) {
|
|
114
166
|
console.error(`TenderlySimulation_setup:`, e);
|
|
115
167
|
throw e;
|
|
@@ -117,24 +169,13 @@ export class TenderlySimulation implements TransactionSimulator {
|
|
|
117
169
|
}
|
|
118
170
|
|
|
119
171
|
async simulate(params: TxObject, stateOverrides?: StateOverrides) {
|
|
120
|
-
let _params = {
|
|
121
|
-
from: params.from,
|
|
122
|
-
to: params.to,
|
|
123
|
-
save: true,
|
|
124
|
-
root: this.lastTx,
|
|
125
|
-
value: params.value || '0',
|
|
126
|
-
gas: this.maxGasLimit,
|
|
127
|
-
input: params.data,
|
|
128
|
-
state_objects: {},
|
|
129
|
-
};
|
|
130
172
|
try {
|
|
131
|
-
|
|
173
|
+
let stateOverridesParams = {};
|
|
132
174
|
|
|
133
175
|
if (stateOverrides) {
|
|
134
176
|
await process.nextTick(() => {}); // https://stackoverflow.com/questions/69169492/async-external-function-leaves-open-handles-jest-supertest-express
|
|
135
177
|
const result = await axios.post(
|
|
136
|
-
`
|
|
137
|
-
https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/contracts/encode-states`,
|
|
178
|
+
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/contracts/encode-states`,
|
|
138
179
|
stateOverrides,
|
|
139
180
|
{
|
|
140
181
|
headers: {
|
|
@@ -143,7 +184,7 @@ export class TenderlySimulation implements TransactionSimulator {
|
|
|
143
184
|
},
|
|
144
185
|
);
|
|
145
186
|
|
|
146
|
-
|
|
187
|
+
stateOverridesParams = Object.keys(result.data.stateOverrides).reduce(
|
|
147
188
|
(acc, contract) => {
|
|
148
189
|
const _storage = result.data.stateOverrides[contract].value;
|
|
149
190
|
|
|
@@ -154,12 +195,30 @@ export class TenderlySimulation implements TransactionSimulator {
|
|
|
154
195
|
},
|
|
155
196
|
{} as Record<Address, StateSimulateApiOverride>,
|
|
156
197
|
);
|
|
198
|
+
|
|
199
|
+
await this.executeStateOverrides(stateOverridesParams);
|
|
157
200
|
}
|
|
158
201
|
|
|
159
202
|
await process.nextTick(() => {}); // https://stackoverflow.com/questions/69169492/async-external-function-leaves-open-handles-jest-supertest-express
|
|
160
203
|
const { data } = await axios.post(
|
|
161
|
-
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/
|
|
162
|
-
|
|
204
|
+
`https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/vnets/${this.vnetId}/transactions`,
|
|
205
|
+
{
|
|
206
|
+
callArgs: {
|
|
207
|
+
from: params.from,
|
|
208
|
+
to: params.to,
|
|
209
|
+
value:
|
|
210
|
+
params.value === '0'
|
|
211
|
+
? '0x0'
|
|
212
|
+
: ethers.utils.hexStripZeros(
|
|
213
|
+
ethers.utils.hexlify(BigInt(params.value)),
|
|
214
|
+
),
|
|
215
|
+
gas: ethers.utils.hexStripZeros(
|
|
216
|
+
ethers.utils.hexlify(BigInt(this.maxGasLimit)),
|
|
217
|
+
),
|
|
218
|
+
data: params.data,
|
|
219
|
+
},
|
|
220
|
+
blockNumber: 'pending',
|
|
221
|
+
},
|
|
163
222
|
{
|
|
164
223
|
timeout: 30 * 1000,
|
|
165
224
|
headers: {
|
|
@@ -168,20 +227,22 @@ export class TenderlySimulation implements TransactionSimulator {
|
|
|
168
227
|
},
|
|
169
228
|
);
|
|
170
229
|
|
|
171
|
-
|
|
172
|
-
if (data.transaction.status) {
|
|
173
|
-
this.lastTx = lastTx;
|
|
230
|
+
if (data.status === 'success') {
|
|
174
231
|
return {
|
|
175
232
|
success: true,
|
|
176
|
-
gasUsed: data.
|
|
177
|
-
url: `https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/
|
|
178
|
-
|
|
233
|
+
gasUsed: data.gasUsed,
|
|
234
|
+
url: `https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/testnet/${
|
|
235
|
+
this.vnetId
|
|
236
|
+
}/tx/${this.chainIdToChainNameMap[this.network]}/${data.id}`,
|
|
237
|
+
transaction: data.input,
|
|
179
238
|
};
|
|
180
239
|
} else {
|
|
181
240
|
return {
|
|
182
241
|
success: false,
|
|
183
|
-
url: `https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/
|
|
184
|
-
|
|
242
|
+
url: `https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/testnet/${
|
|
243
|
+
this.vnetId
|
|
244
|
+
}/tx/${this.chainIdToChainNameMap[this.network]}/${data.id}`,
|
|
245
|
+
error: `Simulation failed ${data.error_reason}`,
|
|
185
246
|
};
|
|
186
247
|
}
|
|
187
248
|
} catch (e) {
|
|
@@ -191,31 +252,35 @@ export class TenderlySimulation implements TransactionSimulator {
|
|
|
191
252
|
}
|
|
192
253
|
}
|
|
193
254
|
|
|
194
|
-
async
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
gasPrice: '0x0', // 0
|
|
202
|
-
};
|
|
203
|
-
const txHash = await this.testNetRPC!.send('eth_sendTransaction', [
|
|
204
|
-
txParams,
|
|
205
|
-
]);
|
|
206
|
-
const transaction = await this.testNetRPC!.waitForTransaction(txHash);
|
|
207
|
-
if (transaction.status) {
|
|
208
|
-
return {
|
|
209
|
-
success: true,
|
|
210
|
-
url: txHash,
|
|
211
|
-
gasUsed: transaction.gasUsed.toString(),
|
|
212
|
-
transaction,
|
|
213
|
-
};
|
|
214
|
-
} else {
|
|
215
|
-
return {
|
|
216
|
-
success: false,
|
|
217
|
-
error: `Transaction on testnet failed, hash: ${txHash}`,
|
|
218
|
-
};
|
|
255
|
+
async executeStateOverrides(
|
|
256
|
+
stateOverridesParams: Record<string, StateSimulateApiOverride>,
|
|
257
|
+
) {
|
|
258
|
+
if (!this.rpcURL) {
|
|
259
|
+
throw new Error(
|
|
260
|
+
`rpcURL is not defined for testnet: ${this.vnetId} (https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/testnet/${this.vnetId}`,
|
|
261
|
+
);
|
|
219
262
|
}
|
|
263
|
+
|
|
264
|
+
const testNetRPC = new StaticJsonRpcProvider(this.rpcURL);
|
|
265
|
+
await Promise.all(
|
|
266
|
+
Object.keys(stateOverridesParams).map(async addr => {
|
|
267
|
+
const storage = stateOverridesParams[addr].storage;
|
|
268
|
+
|
|
269
|
+
await Promise.all(
|
|
270
|
+
Object.keys(storage).map(async slot => {
|
|
271
|
+
const txHash = await testNetRPC!.send('tenderly_setStorageAt', [
|
|
272
|
+
addr,
|
|
273
|
+
slot,
|
|
274
|
+
storage[slot],
|
|
275
|
+
]);
|
|
276
|
+
|
|
277
|
+
const transaction = await testNetRPC!.waitForTransaction(txHash);
|
|
278
|
+
if (!transaction.status) {
|
|
279
|
+
console.log(`Transaction failed: ${txHash}`);
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
282
|
+
);
|
|
283
|
+
}),
|
|
284
|
+
);
|
|
220
285
|
}
|
|
221
286
|
}
|
package/tests/utils-e2e.ts
CHANGED
|
@@ -446,7 +446,7 @@ export async function testE2E(
|
|
|
446
446
|
formatDeployMessage(
|
|
447
447
|
'adapter',
|
|
448
448
|
contractAddress,
|
|
449
|
-
ts.
|
|
449
|
+
ts.vnetId,
|
|
450
450
|
testContractName || '',
|
|
451
451
|
testContractRelativePath || '',
|
|
452
452
|
),
|
|
@@ -486,7 +486,9 @@ export async function testE2E(
|
|
|
486
486
|
|
|
487
487
|
if (paraswap.dexHelper?.replaceProviderWithRPC) {
|
|
488
488
|
paraswap.dexHelper?.replaceProviderWithRPC(
|
|
489
|
-
`https://rpc.tenderly.co
|
|
489
|
+
`https://virtual.${ts.getChainNameByChainId(network)}.rpc.tenderly.co/${
|
|
490
|
+
ts.vnetId
|
|
491
|
+
}`,
|
|
490
492
|
);
|
|
491
493
|
}
|
|
492
494
|
|
|
@@ -572,6 +574,7 @@ export async function testE2E(
|
|
|
572
574
|
);
|
|
573
575
|
|
|
574
576
|
const swapTx = await ts.simulate(swapParams);
|
|
577
|
+
|
|
575
578
|
// Only log gas estimate if testing against API
|
|
576
579
|
if (useAPI) {
|
|
577
580
|
const gasUsed = swapTx.gasUsed || '0';
|
package/.vscode/launch.json
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"type": "node",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"name": "Current",
|
|
8
|
-
"program": "${file}",
|
|
9
|
-
"preLaunchTask": "npm: build",
|
|
10
|
-
"sourceMaps": true,
|
|
11
|
-
"smartStep": true,
|
|
12
|
-
"internalConsoleOptions": "openOnSessionStart",
|
|
13
|
-
"outFiles": ["${workspaceFolder}/build/**/*.js"]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"type": "node",
|
|
17
|
-
"request": "launch",
|
|
18
|
-
"name": "Debug dex integration",
|
|
19
|
-
"program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js",
|
|
20
|
-
"args": [
|
|
21
|
-
"--project",
|
|
22
|
-
"tsconfig.json",
|
|
23
|
-
// "${workspaceFolder}/src/dex/algebra/scripts/validate-state.ts",
|
|
24
|
-
"${workspaceFolder}/src/dex/camelot/camelot-pool-discovery.test.ts",
|
|
25
|
-
// "${workspaceFolder}/src/dex/solidly-v3/scripts/check-event-pool-event.ts",
|
|
26
|
-
// "${workspaceFolder}/scripts/dex-integration.ts",
|
|
27
|
-
"test",
|
|
28
|
-
"wombat"
|
|
29
|
-
],
|
|
30
|
-
"console": "integratedTerminal",
|
|
31
|
-
"internalConsoleOptions": "neverOpen",
|
|
32
|
-
"runtimeArgs": ["--nolazy"],
|
|
33
|
-
"sourceMaps": true,
|
|
34
|
-
"smartStep": true,
|
|
35
|
-
"skipFiles": ["<node_internals>/**"],
|
|
36
|
-
"cwd": "${workspaceFolder}"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"type": "node",
|
|
40
|
-
"name": "Jest file",
|
|
41
|
-
"request": "launch",
|
|
42
|
-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
|
43
|
-
// "program": "${workspaceFolder}/src/dex/camelot/scripts/validate-state.ts",
|
|
44
|
-
// "args": ["src/dex/balancer-v1/balancer-v1-e2e.test.ts"],
|
|
45
|
-
// "args": ["${relativeFile}"],
|
|
46
|
-
"args": ["${file}"],
|
|
47
|
-
"cwd": "${workspaceRoot}",
|
|
48
|
-
"console": "integratedTerminal",
|
|
49
|
-
"internalConsoleOptions": "neverOpen",
|
|
50
|
-
"sourceMaps": true
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
package/.vscode/settings.json
DELETED
package/.vscode/tasks.json
DELETED