@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.
Files changed (172) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/paraswap-dex-lib.iml +9 -0
  7. package/.idea/prettier.xml +7 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/build/abi/integral/factory.json +333 -0
  10. package/build/abi/integral/oracle.json +501 -0
  11. package/build/abi/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
  12. package/build/abi/{wombat/pool.json → integral/relayer.json} +720 -473
  13. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  14. package/build/dex/aave-v1/aave-v1.js +0 -23
  15. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  16. package/build/dex/balancer-v2/config.js +1 -1
  17. package/build/dex/balancer-v2/config.js.map +1 -1
  18. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
  19. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
  20. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
  21. package/build/dex/generic-rfq/e2e-test-config.js +3 -3
  22. package/build/dex/generic-rfq/e2e-test-config.js.map +1 -1
  23. package/build/dex/integral/config.d.ts +4 -0
  24. package/build/dex/integral/config.js +20 -0
  25. package/build/dex/integral/config.js.map +1 -0
  26. package/build/dex/integral/context.d.ts +40 -0
  27. package/build/dex/integral/context.js +158 -0
  28. package/build/dex/integral/context.js.map +1 -0
  29. package/build/dex/integral/integral-factory.d.ts +24 -0
  30. package/build/dex/integral/integral-factory.js +95 -0
  31. package/build/dex/integral/integral-factory.js.map +1 -0
  32. package/build/dex/integral/integral-pool.d.ts +50 -0
  33. package/build/dex/integral/integral-pool.js +149 -0
  34. package/build/dex/integral/integral-pool.js.map +1 -0
  35. package/build/dex/integral/integral-pricing.d.ts +18 -0
  36. package/build/dex/integral/integral-pricing.js +114 -0
  37. package/build/dex/integral/integral-pricing.js.map +1 -0
  38. package/build/dex/integral/integral-relayer.d.ts +42 -0
  39. package/build/dex/integral/integral-relayer.js +192 -0
  40. package/build/dex/integral/integral-relayer.js.map +1 -0
  41. package/build/dex/integral/integral-token.d.ts +27 -0
  42. package/build/dex/integral/integral-token.js +59 -0
  43. package/build/dex/integral/integral-token.js.map +1 -0
  44. package/build/dex/integral/integral.d.ts +41 -0
  45. package/build/dex/integral/integral.js +376 -0
  46. package/build/dex/integral/integral.js.map +1 -0
  47. package/build/dex/integral/types.d.ts +85 -0
  48. package/build/dex/integral/types.js +9 -0
  49. package/build/dex/integral/types.js.map +1 -0
  50. package/build/dex/integral/utils-e2e.d.ts +9 -0
  51. package/build/dex/integral/utils-e2e.js +131 -0
  52. package/build/dex/integral/utils-e2e.js.map +1 -0
  53. package/build/dex/integral/utils.d.ts +17 -0
  54. package/build/dex/integral/utils.js +94 -0
  55. package/build/dex/integral/utils.js.map +1 -0
  56. package/build/dex/jarvis.d.ts +1 -2
  57. package/build/dex/jarvis.js +0 -58
  58. package/build/dex/jarvis.js.map +1 -1
  59. package/build/dex/maverick-v1/config.js +1 -1
  60. package/build/dex/maverick-v1/config.js.map +1 -1
  61. package/build/dex/platypus/platypus.d.ts +1 -2
  62. package/build/dex/platypus/platypus.js +0 -45
  63. package/build/dex/platypus/platypus.js.map +1 -1
  64. package/build/dex/stable-pool.js +8 -1
  65. package/build/dex/stable-pool.js.map +1 -1
  66. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  67. package/build/dex/swaap-v1/swaap-v1.js +0 -14
  68. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  69. package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
  70. package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
  71. package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
  72. package/build/dex/uniswap-v3/config.js +1 -1
  73. package/build/dex/uniswap-v3/config.js.map +1 -1
  74. package/build/dex/zerox/index.d.ts +26 -4
  75. package/build/dex/zerox/index.js +42 -50
  76. package/build/dex/zerox/index.js.map +1 -1
  77. package/build/dex/zerox/types.d.ts +0 -29
  78. package/build/dex/zerox/types.js +1 -8
  79. package/build/dex/zerox/types.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +165 -102
  82. package/src/dex/balancer-v2/balancer-v2-integration.test.ts +238 -80
  83. package/src/dex/balancer-v2/config.ts +1 -2
  84. package/src/dex/generic-rfq/e2e-test-config.ts +3 -3
  85. package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +2 -2
  86. package/src/dex/maverick-v1/config.ts +1 -2
  87. package/src/dex/uniswap-v3/config.ts +1 -2
  88. package/tests/constants-e2e.ts +1 -1
  89. package/tests/smart-tokens.ts +1 -3
  90. package/tests/tenderly-simulation.ts +149 -84
  91. package/tests/utils-e2e.ts +5 -2
  92. package/.vscode/launch.json +0 -53
  93. package/.vscode/settings.json +0 -2
  94. package/.vscode/tasks.json +0 -15
  95. package/build/abi/inception/inception-ratio-feed.json +0 -329
  96. package/build/abi/inception/inception-vault.json +0 -991
  97. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  98. package/build/abi/usual-m-smart-m/usualM.abi.json +0 -483
  99. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  100. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  101. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  102. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
  103. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
  104. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
  105. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
  106. package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
  107. package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
  108. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
  109. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
  110. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
  111. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +0 -34
  112. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +0 -406
  113. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +0 -1
  114. package/build/dex/inception/config.d.ts +0 -4
  115. package/build/dex/inception/config.js +0 -109
  116. package/build/dex/inception/config.js.map +0 -1
  117. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  118. package/build/dex/inception/inception-event-pool.js +0 -49
  119. package/build/dex/inception/inception-event-pool.js.map +0 -1
  120. package/build/dex/inception/inception.d.ts +0 -43
  121. package/build/dex/inception/inception.js +0 -180
  122. package/build/dex/inception/inception.js.map +0 -1
  123. package/build/dex/inception/tokens.d.ts +0 -9
  124. package/build/dex/inception/tokens.js +0 -28
  125. package/build/dex/inception/tokens.js.map +0 -1
  126. package/build/dex/inception/types.d.ts +0 -22
  127. package/build/dex/inception/types.js +0 -3
  128. package/build/dex/inception/types.js.map +0 -1
  129. package/build/dex/inception/utils.d.ts +0 -7
  130. package/build/dex/inception/utils.js +0 -58
  131. package/build/dex/inception/utils.js.map +0 -1
  132. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  133. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  134. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  135. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  136. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  137. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
  138. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  139. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  140. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  141. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  142. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  143. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  144. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  145. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  146. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
  147. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
  148. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
  149. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
  150. package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
  151. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
  152. package/build/dex/usual/usual-m-smart-m.d.ts +0 -17
  153. package/build/dex/usual/usual-m-smart-m.js +0 -50
  154. package/build/dex/usual/usual-m-smart-m.js.map +0 -1
  155. package/build/dex/usual-m-smart-m/config.d.ts +0 -3
  156. package/build/dex/usual-m-smart-m/config.js +0 -13
  157. package/build/dex/usual-m-smart-m/config.js.map +0 -1
  158. package/build/dex/usual-m-smart-m/types.d.ts +0 -7
  159. package/build/dex/usual-m-smart-m/types.js +0 -3
  160. package/build/dex/usual-m-smart-m/types.js.map +0 -1
  161. package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +0 -35
  162. package/build/dex/usual-m-smart-m/usual-m-smart-m.js +0 -161
  163. package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +0 -1
  164. package/build/dex/usual-m-usd0/config.d.ts +0 -3
  165. package/build/dex/usual-m-usd0/config.js +0 -14
  166. package/build/dex/usual-m-usd0/config.js.map +0 -1
  167. package/build/dex/usual-m-usd0/types.d.ts +0 -8
  168. package/build/dex/usual-m-usd0/types.js +0 -3
  169. package/build/dex/usual-m-usd0/types.js.map +0 -1
  170. package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +0 -35
  171. package/build/dex/usual-m-usd0/usual-m-usd0.js +0 -159
  172. 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 { StaticJsonRpcProvider, Provider } from '@ethersproject/providers';
7
- import Web3 from 'web3';
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 TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID;
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
- forkId: string;
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
- forkId: string = '0';
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
- testNetRPC: StaticJsonRpcProvider | null = null;
61
- lastTx: string = '';
62
- forkId: string = '';
65
+ vnetId: string = '';
66
+ rpcURL: string = '';
63
67
  maxGasLimit = 80000000;
64
68
 
65
- constructor(
66
- private network: Number = 1,
67
- forkId?: string,
68
- lastTransactionId?: string,
69
- ) {
70
- if (forkId && lastTransactionId) {
71
- this.forkId = forkId;
72
- this.lastTx = lastTransactionId;
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
- if (this.forkId && this.lastTx) return;
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 (TENDERLY_FORK_ID) {
86
- if (!TENDERLY_FORK_LAST_TX_ID) throw new Error('Always set last tx id');
87
- this.forkId = TENDERLY_FORK_ID;
88
- this.lastTx = TENDERLY_FORK_LAST_TX_ID;
89
- return;
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}/fork`,
131
+ `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT}/vnets`,
101
132
  {
102
- network_id: this.network.toString(),
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: 20000,
151
+ timeout: 200000,
106
152
  headers: {
107
153
  'x-access-key': TENDERLY_TOKEN,
108
154
  },
109
155
  },
110
156
  );
111
- this.forkId = res.data.simulation_fork.id;
112
- this.lastTx = res.data.root_transaction.id;
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
- if (this.testNetRPC) return this.executeTransactionOnTestnet(params);
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
- _params.state_objects = Object.keys(result.data.stateOverrides).reduce(
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}/fork/${this.forkId}/simulate`,
162
- _params,
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
- const lastTx = data.simulation.id;
172
- if (data.transaction.status) {
173
- this.lastTx = lastTx;
230
+ if (data.status === 'success') {
174
231
  return {
175
232
  success: true,
176
- gasUsed: data.transaction.gas_used,
177
- url: `https://dashboard.tenderly.co/${TENDERLY_ACCOUNT_ID}/${TENDERLY_PROJECT}/fork/${this.forkId}/simulation/${lastTx}`,
178
- transaction: data.transaction,
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}/fork/${this.forkId}/simulation/${lastTx}`,
184
- error: `Simulation failed: ${data.transaction.error_info.error_message} at ${data.transaction.error_info.address}`,
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 executeTransactionOnTestnet(params: TxObject) {
195
- const txParams = {
196
- from: params.from,
197
- to: params.to,
198
- value: Web3.utils.toHex(params.value || '0'),
199
- data: params.data,
200
- gas: '0x4c4b40', // 5,000,000
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
  }
@@ -446,7 +446,7 @@ export async function testE2E(
446
446
  formatDeployMessage(
447
447
  'adapter',
448
448
  contractAddress,
449
- ts.forkId,
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/fork/${ts.forkId}`,
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';
@@ -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
- }
@@ -1,2 +0,0 @@
1
- {
2
- }
@@ -1,15 +0,0 @@
1
- {
2
- "version": "2.0.0",
3
- "tasks": [
4
- {
5
- "label": "tsc: build - tsconfig.json",
6
- "type": "typescript",
7
- "tsconfig": "tsconfig.json",
8
- "problemMatcher": ["$tsc"],
9
- "group": {
10
- "kind": "build",
11
- "isDefault": true
12
- }
13
- }
14
- ]
15
- }