MCPcopy Create free account
hub / github.com/SmarDex-Dev/smart-contracts / deployTokens

Function deployTokens

script/generateSwapGasCost.ts:132–185  ·  view source on GitHub ↗
(router: SmardexRouter, hre: HardhatRuntimeEnvironment)

Source from the content-addressed store, hash-verified

130}
131
132async function deployTokens(router: SmardexRouter, hre: HardhatRuntimeEnvironment) {
133 const { ethers } = hre;
134 const { MaxUint256 } = ethers.constants;
135 const { parseEther } = ethers.utils;
136 const signers = await ethers.getSigners();
137 const tokenFactory = await hre.ethers.getContractFactory("ERC20Test");
138 const tokens = await Promise.all(
139 [...Array(MAX_HOPS + 1).keys()].map(() => {
140 return tokenFactory.deploy(MaxUint256);
141 }),
142 );
143 await Promise.all(tokens.map(token => token.deployed()));
144 await Promise.all(tokens.map(token => token.approve(router.address, MaxUint256)));
145 await Promise.all(
146 tokens.map(token =>
147 router.addLiquidityETH(
148 {
149 token: token.address,
150 amountTokenDesired: parseEther("100000"),
151 amountTokenMin: 0,
152 amountETHMin: 0,
153 fictiveReserveETH: 0,
154 fictiveReserveTokenMin: 0,
155 fictiveReserveTokenMax: 0,
156 },
157 signers[0].address,
158 MaxUint256,
159 {
160 value: parseEther("100000"),
161 },
162 ),
163 ),
164 );
165 await Promise.all(
166 Array.from(slidingWindow(tokens, 2)).map(([tokenA, tokenB]) => {
167 return router.addLiquidity(
168 {
169 tokenA: tokenA.address,
170 tokenB: tokenB.address,
171 amountADesired: parseEther("100000"),
172 amountBDesired: parseEther("100000"),
173 amountAMin: 0,
174 amountBMin: 0,
175 fictiveReserveB: 0,
176 fictiveReserveAMin: 0,
177 fictiveReserveAMax: 0,
178 },
179 signers[0].address,
180 MaxUint256,
181 );
182 }),
183 );
184 return tokens;
185}
186
187async function getDeployedAddress(network: string, contractName: string): Promise<string> {
188 try {

Callers 1

generateSwapGasCostFunction · 0.85

Calls 1

slidingWindowFunction · 0.85

Tested by

no test coverage detected