-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mike/updated_l2_deploys_childGauge_permiss…
…ions
- Loading branch information
Showing
36 changed files
with
15,705 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import "@openzeppelin/contracts-4.7.3/token/ERC20/presets/ERC20PresetMinterPauser.sol"; | ||
|
||
contract DummyERC20 is ERC20PresetMinterPauser { | ||
constructor(string memory name, string memory symbol) | ||
ERC20PresetMinterPauser(name, symbol) | ||
{} | ||
|
||
function mint(address to, uint256 amount) public virtual override { | ||
assert(amount <= 10000000000000000000); | ||
_mint(to, amount); | ||
} | ||
} |
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,29 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy, execute, getOrNull, log } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const lpToken = await getOrNull("LPTokenV2") | ||
if (lpToken) { | ||
log(`reusing "LPTokenV2" at ${lpToken.address}`) | ||
} else { | ||
await deploy("LPTokenV2", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
}) | ||
|
||
await execute( | ||
"LPTokenV2", | ||
{ from: deployer, log: true }, | ||
"initialize", | ||
"Saddle LP Token (Target)", | ||
"saddleLPTokenTarget", | ||
) | ||
} | ||
} | ||
export default func | ||
func.tags = ["LPTokenV2"] |
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,16 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId } = hre | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
await deploy("AmplificationUtilsV2", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
}) | ||
} | ||
export default func | ||
func.tags = ["AmplificationUtilsV2"] |
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,16 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId } = hre | ||
const { deploy, get } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
await deploy("SwapUtilsV2", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
}) | ||
} | ||
export default func | ||
func.tags = ["SwapUtilsV2"] |
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,16 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy, get } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
await deploy("MetaSwapUtilsV1", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
}) | ||
} | ||
export default func | ||
func.tags = ["MetaSwapUtilsV1"] |
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,17 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId, ethers } = hre | ||
const { deploy, get, execute } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
await deploy("PoolRegistry", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: [deployer, deployer], | ||
}) | ||
} | ||
export default func | ||
func.tags = ["PoolRegistry"] |
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,51 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { MasterRegistry } from "../../build/typechain" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId, ethers } = hre | ||
const { deploy, get, getOrNull, execute, read } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const masterRegistry = await getOrNull("MasterRegistry") | ||
|
||
if (masterRegistry == null) { | ||
await deploy("MasterRegistry", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: [deployer], | ||
}) | ||
|
||
const contract = (await ethers.getContract( | ||
"MasterRegistry", | ||
)) as MasterRegistry | ||
|
||
const batchCall = [ | ||
await contract.populateTransaction.addRegistry( | ||
ethers.utils.formatBytes32String("PoolRegistry"), | ||
( | ||
await get("PoolRegistry") | ||
).address, | ||
), | ||
await contract.populateTransaction.addRegistry( | ||
ethers.utils.formatBytes32String("FeeCollector"), | ||
deployer, | ||
), | ||
] | ||
|
||
const batchCallData = batchCall | ||
.map((x) => x.data) | ||
.filter((x): x is string => !!x) | ||
|
||
await execute( | ||
"MasterRegistry", | ||
{ from: deployer, log: true }, | ||
"batch", | ||
batchCallData, | ||
true, | ||
) | ||
} | ||
} | ||
export default func | ||
func.tags = ["MasterRegistry"] |
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,20 @@ | ||
import dotenv from "dotenv" | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { deployPermissionlessPoolComponentsV2 } from "../deployUtils" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
dotenv.config() | ||
|
||
await deployPermissionlessPoolComponentsV2(hre) | ||
} | ||
export default func | ||
func.tags = ["PermissionlessSwaps"] | ||
func.dependencies = [ | ||
"MasterRegistry", | ||
"PoolRegistry", | ||
"SwapUtilsV2", | ||
"AmplificationUtilsV2", | ||
"MetaSwapUtilsV1", | ||
"LPTokenV2", | ||
] |
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,36 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts } = hre | ||
const { deploy, save } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const dummyToken1 = await deploy("Dummy1", { | ||
contract: "DummyERC20", | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: ["FreeMintableDummyERC20_1", "Dummy1"], | ||
}) | ||
|
||
// save token deployment | ||
await save("Dummy1", { | ||
abi: dummyToken1.abi, | ||
address: dummyToken1.address, | ||
}) | ||
|
||
const dummyToken2 = await deploy("Dummy2", { | ||
contract: "DummyERC20", | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: ["FreeMintableDummyERC20_2", "Dummy2"], | ||
}) | ||
// save token deployment | ||
await save("Dummy2", { | ||
abi: dummyToken2.abi, | ||
address: dummyToken2.address, | ||
}) | ||
} | ||
export default func |
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,76 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { ZERO_ADDRESS } from "../../test/testUtils" | ||
|
||
// Deployment Names | ||
const POOL_NAME = "SaddleDummyPool" | ||
|
||
const TOKEN_NAMES = ["Dummy1", "Dummy2"] | ||
const LP_TOKEN_NAME = "Saddle Dummy1/Dummy2 LP Token" | ||
const LP_TOKEN_SYMBOL = "SaddleDummyBP" | ||
const INITIAL_A = 500 | ||
const SWAP_FEE = 4e6 // 4bps | ||
const ADMIN_FEE = 0 // 50% of the 3bps | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, ethers } = hre | ||
const { execute, deploy, get, getOrNull, log, read, save } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
const poolLpTokenName = `${POOL_NAME}LPToken` | ||
|
||
// Manually check if the pool is already deployed | ||
const poolContract = await getOrNull(POOL_NAME) | ||
|
||
// Check if has been initialized | ||
const isInitialized: boolean = poolContract | ||
? (await read(POOL_NAME, "swapStorage")).lpToken !== ZERO_ADDRESS | ||
: false | ||
|
||
if (poolContract && isInitialized) { | ||
log(`reusing ${POOL_NAME} at ${poolContract.address}`) | ||
} else { | ||
const TOKEN_ADDRESSES = await Promise.all( | ||
TOKEN_NAMES.map(async (name) => (await get(name)).address), | ||
) | ||
|
||
await deploy(POOL_NAME, { | ||
from: deployer, | ||
log: true, | ||
contract: "SwapV2", | ||
skipIfAlreadyDeployed: true, | ||
libraries: { | ||
SwapUtilsV2: (await get("SwapUtilsV2")).address, | ||
AmplificationUtilsV2: (await get("AmplificationUtilsV2")).address, | ||
}, | ||
}) | ||
await execute( | ||
POOL_NAME, | ||
{ | ||
from: deployer, | ||
log: true, | ||
}, | ||
"initialize", | ||
TOKEN_ADDRESSES, | ||
[18, 18], | ||
LP_TOKEN_NAME, | ||
LP_TOKEN_SYMBOL, | ||
INITIAL_A, | ||
SWAP_FEE, | ||
ADMIN_FEE, | ||
( | ||
await get("LPTokenV2") | ||
).address, | ||
) | ||
|
||
const lpTokenAddress = (await read(POOL_NAME, "swapStorage")).lpToken | ||
log(`deployed ${poolLpTokenName} at ${lpTokenAddress}`) | ||
|
||
await save(poolLpTokenName, { | ||
abi: (await get("LPTokenV2")).abi, // LPToken ABI | ||
address: lpTokenAddress, | ||
}) | ||
} | ||
} | ||
export default func | ||
func.tags = [POOL_NAME] | ||
func.dependencies = ["SwapUtilsV2"] |
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,31 @@ | ||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import { CHAIN_ID } from "../../utils/network" | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getChainId, network } = hre | ||
const { log } = deployments | ||
const network_deployments = await deployments.all() | ||
|
||
// for (const deployment in network_deployments) { | ||
if ( | ||
(await getChainId()) === CHAIN_ID.BASE_TESTNET && | ||
network.name !== "hardhat" | ||
) { | ||
try { | ||
await hre.run("etherscan-verify", { | ||
network: "base_testnet", | ||
apiKey: process.env.ETHERSCAN_API, | ||
}) | ||
} catch (e) { | ||
log(e) | ||
} | ||
} else { | ||
log( | ||
`Skipping verification since this is not running on ${CHAIN_ID.BASE_TESTNET}`, | ||
) | ||
} | ||
} | ||
// } | ||
export default func | ||
// func.skip = async (env) => true |
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 @@ | ||
84531 |
Oops, something went wrong.