-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move all token-seller related scripts to separate folder
- Loading branch information
Showing
10 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {parseUnits} from "ethers/lib/utils"; | ||
import { | ||
IERC20Metadata__factory, | ||
MockToken__factory, | ||
UniswapV3Callee__factory, | ||
Univ3TokenSeller__factory | ||
} from "../../typechain"; | ||
import {ethers, network} from "hardhat"; | ||
import {Misc} from "../utils/Misc"; | ||
import {RunHelper} from "../utils/RunHelper"; | ||
|
||
/** | ||
* npx hardhat run scripts/token-seller/GetStatus.ts | ||
*/ | ||
async function main() { | ||
const TOKEN_A = "0xF21ABFC5D68819EA0044fdB256d0AA854DC3034b"; | ||
const TOKEN_B = "0xF992a90B4F2D59B65548bF9766a02ee8170E7F07"; | ||
const POOL = "0x11aB7c23B6d05Aa08D69A1eD669Ad19f3eAC52d9"; | ||
const TOKEN_SELLER = "0x8E294388A3E91cdac5FEA95b5b75f509b85dC5E2"; | ||
|
||
const signer = (await ethers.getSigners())[0]; | ||
console.log("signer", signer.address); | ||
|
||
const net = await ethers.provider.getNetwork(); | ||
console.log(net, `network name="${network.name}"`); | ||
|
||
const swapTokenA = false; | ||
|
||
const tokenA = MockToken__factory.connect(TOKEN_A, signer); | ||
const tokenB = MockToken__factory.connect(TOKEN_B, signer); | ||
|
||
const decimalsA = await tokenA.decimals(); | ||
const decimalsB = await tokenB.decimals(); | ||
|
||
const tokenSeller = Univ3TokenSeller__factory.connect(TOKEN_SELLER, signer); | ||
const owner = await tokenSeller.owner(); | ||
|
||
console.log("Need to refresh", await tokenSeller.needToRefresh()); | ||
console.log("TokenSeller.state", await tokenSeller.state()); | ||
console.log("owner", owner); | ||
console.log("BalanceA", await tokenA.balanceOf(owner)); | ||
console.log("BalanceB", await tokenB.balanceOf(owner)); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {parseUnits} from "ethers/lib/utils"; | ||
import {IERC20Metadata__factory, MockToken__factory, UniswapV3Callee__factory} from "../../typechain"; | ||
import {ethers, network} from "hardhat"; | ||
import {Misc} from "../utils/Misc"; | ||
import {RunHelper} from "../utils/RunHelper"; | ||
|
||
/** | ||
* npx hardhat run scripts/token-seller/MakeTestSwap.ts | ||
*/ | ||
async function main() { | ||
const TOKEN_A = "0xF21ABFC5D68819EA0044fdB256d0AA854DC3034b"; | ||
const TOKEN_B = "0xF992a90B4F2D59B65548bF9766a02ee8170E7F07"; | ||
const POOL = "0x11aB7c23B6d05Aa08D69A1eD669Ad19f3eAC52d9"; | ||
const UNISWAP_V3_CALEE = "0x848A49De3f59C62A337463f1D856Ad30FE85675e"; | ||
|
||
const signer = (await ethers.getSigners())[0]; | ||
// const signer = await Misc.impersonate("0xF1dCce3a6c321176C62b71c091E3165CC9C3816E"); | ||
console.log("signer", signer.address); | ||
|
||
const net = await ethers.provider.getNetwork(); | ||
console.log(net, `network name="${network.name}"`); | ||
|
||
const swapTokenA = false; | ||
|
||
const tokenA = MockToken__factory.connect(TOKEN_A, signer); | ||
const tokenB = MockToken__factory.connect(TOKEN_B, signer); | ||
const uniswapV3Callee = UniswapV3Callee__factory.connect(UNISWAP_V3_CALEE, signer); | ||
|
||
const decimalsA = await tokenA.decimals(); | ||
const decimalsB = await tokenB.decimals(); | ||
|
||
const swapAmount = "1000"; | ||
const amountToSwap = parseUnits(swapAmount, swapTokenA ? decimalsA : decimalsB); | ||
|
||
if (swapTokenA) { | ||
await RunHelper.runAndWait2ExplicitSigner( | ||
signer, | ||
tokenA.connect(signer).populateTransaction.approve(uniswapV3Callee.address, amountToSwap) | ||
) | ||
} else { | ||
await RunHelper.runAndWait2ExplicitSigner( | ||
signer, | ||
tokenB.connect(signer).populateTransaction.approve(uniswapV3Callee.address, amountToSwap) | ||
); | ||
} | ||
|
||
console.log("BalanceA", await tokenA.balanceOf(signer.address)); | ||
console.log("BalanceB", await tokenB.balanceOf(signer.address)); | ||
|
||
await RunHelper.runAndWait2ExplicitSigner( | ||
signer, | ||
uniswapV3Callee.connect(signer).populateTransaction.swap( | ||
POOL, | ||
signer.address, | ||
swapTokenA ? tokenA.address : tokenB.address, | ||
amountToSwap | ||
) | ||
); | ||
|
||
console.log("BalanceA.after", await tokenA.balanceOf(signer.address)); | ||
console.log("BalanceB.after", await tokenB.balanceOf(signer.address)); | ||
|
||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {parseUnits} from "ethers/lib/utils"; | ||
import { | ||
IERC20Metadata__factory, | ||
MockToken__factory, | ||
UniswapV3Callee__factory, | ||
Univ3TokenSeller__factory, Univ3TokenSellerResolver__factory | ||
} from "../../typechain"; | ||
import {ethers, network} from "hardhat"; | ||
import {Misc} from "../utils/Misc"; | ||
import {RunHelper} from "../utils/RunHelper"; | ||
|
||
/** | ||
* npx hardhat run scripts/token-seller/SetOperator.ts | ||
*/ | ||
async function main() { | ||
const TOKEN_SELLER = "0x8E294388A3E91cdac5FEA95b5b75f509b85dC5E2"; | ||
const RESOLVER = "0xd2538f5f7c328a7027a5e0dea1938931601d1684"; | ||
const MESSAGE_SENDER = "0x0592ce0e3ffb1bc21f5f687e4b9b9da91d9124c3"; | ||
|
||
const signer = (await ethers.getSigners())[0]; | ||
console.log("signer", signer.address); | ||
|
||
const net = await ethers.provider.getNetwork(); | ||
console.log(net, `network name="${network.name}"`); | ||
|
||
const tokenSeller = Univ3TokenSeller__factory.connect(TOKEN_SELLER, signer); | ||
await RunHelper.runAndWait2ExplicitSigner( | ||
signer, | ||
tokenSeller.populateTransaction.setOperator(RESOLVER, true) | ||
); | ||
|
||
const resolver = Univ3TokenSellerResolver__factory.connect(RESOLVER, signer); | ||
await RunHelper.runAndWait2ExplicitSigner( | ||
signer, | ||
resolver.populateTransaction.changeOperatorStatus(MESSAGE_SENDER, true) | ||
); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters