-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
621 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { initializedConstantProductPool } from "./initializedConstantProductPool"; | ||
export { uninitializedConstantProductPool } from "./uninitializedConstantProductPool"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { initializedConstantProductPool } from "./initializedConstantProductPool"; | ||
export { uninitializedConstantProductPool } from "./uninitializedConstantProductPool"; | ||
export { initializedStablePool, uninitializedStablePool } from "./stable-pool"; | ||
export * from "./constant-product"; | ||
export * from "./stable-pool"; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { initializedStablePool } from "./initializedStablePool"; | ||
export { uninitializedStablePool } from "./uninitializedStablePool"; | ||
export { vanillaInitializedStablePool } from "./vanillaInitializedStablePool"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ethers, deployments } from "hardhat"; | ||
import { BentoBoxV1, StablePoolFactory, StablePool__factory, ERC20Mock__factory, MasterDeployer } from "../../../types"; | ||
|
||
export const vanillaInitializedStablePool = deployments.createFixture( | ||
async ( | ||
{ | ||
deployments, | ||
ethers: { | ||
getNamedSigners, | ||
constants: { MaxUint256 }, | ||
}, | ||
}, | ||
options | ||
) => { | ||
await deployments.fixture(["StablePoolFactory"], { keepExistingDeployments: true }); // ensure you start from a fresh deployments | ||
const { deployer } = await getNamedSigners(); | ||
|
||
const ERC20 = await ethers.getContractFactory<ERC20Mock__factory>("ERC20Mock"); | ||
|
||
const token0 = await ERC20.deploy("Token 0", "TOKEN0", ethers.constants.MaxUint256); | ||
await token0.deployed(); | ||
|
||
const token1 = await ERC20.deploy("Token 1", "TOKEN1", ethers.constants.MaxUint256); | ||
await token1.deployed(); | ||
|
||
const masterDeployer = await ethers.getContract<MasterDeployer>("MasterDeployer"); | ||
|
||
const stablePoolFactory = await ethers.getContract<StablePoolFactory>("StablePoolFactory"); | ||
|
||
const deployData = ethers.utils.defaultAbiCoder.encode( | ||
["address", "address", "uint256"], | ||
[token0.address, token1.address, 0] | ||
); | ||
|
||
const contractReceipt = await masterDeployer | ||
.deployPool(stablePoolFactory.address, deployData) | ||
.then((tx) => tx.wait()); | ||
|
||
const bento = await ethers.getContract<BentoBoxV1>("BentoBoxV1"); | ||
|
||
await bento.whitelistMasterContract("0x0000000000000000000000000000000000000001", true); | ||
|
||
await token0.approve(bento.address, MaxUint256).then((tx) => tx.wait()); | ||
|
||
await token1.approve(bento.address, MaxUint256).then((tx) => tx.wait()); | ||
|
||
await bento | ||
.setMasterContractApproval( | ||
deployer.address, | ||
"0x0000000000000000000000000000000000000001", | ||
true, | ||
"0", | ||
"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"0x0000000000000000000000000000000000000000000000000000000000000000" | ||
) | ||
.then((tx) => tx.wait()); | ||
|
||
await bento | ||
.deposit(token0.address, deployer.address, deployer.address, "1000000000000000000", 0) | ||
.then((tx) => tx.wait()); | ||
|
||
await bento | ||
.deposit(token1.address, deployer.address, deployer.address, "1000000000000000000", 0) | ||
.then((tx) => tx.wait()); | ||
|
||
await bento | ||
.transfer(token0.address, deployer.address, contractReceipt.events?.[0].args?.pool, "1000000000000000000") | ||
.then((tx) => tx.wait()); | ||
|
||
await bento | ||
.transfer(token1.address, deployer.address, contractReceipt.events?.[0].args?.pool, "1000000000000000000") | ||
.then((tx) => tx.wait()); | ||
|
||
const Pool = await ethers.getContractFactory<StablePool__factory>("StablePool"); | ||
|
||
const pool = Pool.attach(contractReceipt.events?.[0].args?.pool); | ||
|
||
await pool.mint(ethers.utils.defaultAbiCoder.encode(["address"], [deployer.address])).then((tx) => tx.wait()); | ||
|
||
return pool; | ||
}, | ||
"vanillaInitializedStablePool" | ||
); |
Oops, something went wrong.