Skip to content

Commit

Permalink
deployed contracts and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tkkwon1998 committed Oct 16, 2023
1 parent 0e86bd1 commit a9fa5e9
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 127 deletions.
4 changes: 2 additions & 2 deletions contracts/CrocSwapDex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ contract CrocSwapDex is HotPath, ICrocMinion {

constructor() {
// Register to CSR turnstile
// Turnstile turnstile = Turnstile(0xEcf044C5B4b867CFda001101c617eCd347095B44);
// turnstile.register(tx.origin);
Turnstile turnstile = Turnstile(0xEcf044C5B4b867CFda001101c617eCd347095B44);
turnstile.register(tx.origin);
// Authority is originally set to deployer address, which can then transfer to
// proper governance contract (if deployer already isn't)
authority_ = msg.sender;
Expand Down
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ libs = ['node_modules', 'lib']
test = 'test_other/test_foundry'
cache_path = 'forge-cache'
via_ir = true
solc-version = "0.8.19"
optimizer = true
optimizer-runs = 14900

# See more config options https://book.getfoundry.sh/reference/config.html
8 changes: 4 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ module.exports = {
url: 'http://127.0.0.1:8545',
chainId: 31337
},
canto_testnet: {
url: 'https://testnet-archive.plexnode.wtf',
chainId: 7701,
accounts: ["0x7c5e2cfbba7b00ba95e5ed7cd80566021da709442e147ad3e08f23f5044a3d5a"]
canto_mainnet: {
url: 'https://mainnode.plexnode.org:8545',
chainId: 7700,
accounts: [""]
},
ropsten: {
url: 'https://ropsten.infura.io/v3/cf3bc905d88d4f248c6be347adc8a1d8',
Expand Down
70 changes: 44 additions & 26 deletions misc/scripts/deploy_canto/deploy1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,56 @@ async function main() {

console.log("Deploying contracts with the account:", deployer.address);

// deploy CrocSwapDex contract
const dex = await ethers.deployContract("CrocSwapDex");
// deploy ColdPath
const ColdPath = await ethers.deployContract("ColdPath");
// deploy HotPath
const HotProxy = await ethers.deployContract("HotProxy");
// deploy KnockoutPath
const KnockoutLiqPath = await ethers.deployContract("KnockoutLiqPath");
// deploy CrossKnockoutPath
const KnockoutFlagPath = await ethers.deployContract("KnockoutFlagPath");
// deploy LongPath
const LongPath = await ethers.deployContract("LongPath");
// deploy MicroPath
const MicroPaths = await ethers.deployContract("MicroPaths");
// deploy SafeModePath
const SafeModePath = await ethers.deployContract("SafeModePath");
// // deploy CrocSwapDex contract
// const dex = await ethers.deployContract("CrocSwapDex");
// await dex.deployed();
// console.log("CrocSwapDex:", await dex.address);

// // deploy ColdPath
// const ColdPath = await ethers.deployContract("ColdPath");
// await ColdPath.deployed();
// console.log("ColdPath:", await ColdPath.address);

// // deploy HotPath
// const HotProxy = await ethers.deployContract("HotProxy");
// await HotProxy.deployed();
// console.log("HotProxy:", await HotProxy.address);

// // deploy KnockoutPath
// const KnockoutLiqPath = await ethers.deployContract("KnockoutLiqPath");
// await KnockoutLiqPath.deployed();
// console.log("KnockoutLiqPath:", await KnockoutLiqPath.address);

// // deploy CrossKnockoutPath
// const KnockoutFlagPath = await ethers.deployContract("KnockoutFlagPath");
// await KnockoutFlagPath.deployed();
// console.log("KnockoutFlagPath:", await KnockoutFlagPath.address);

// // deploy LongPath
// const LongPath = await ethers.deployContract("LongPath");
// await LongPath.deployed();
// console.log("LongPath:", await LongPath.address);

// // deploy MicroPath
// const MicroPaths = await ethers.deployContract("MicroPaths");
// await MicroPaths.deployed();
// console.log("MicroPaths:", await MicroPaths.address);

// // deploy SafeModePath
// const SafeModePath = await ethers.deployContract("SafeModePath");
// await SafeModePath.deployed();
// console.log("SafeModePath:", await SafeModePath.address);

// deploy WarmPath
const WarmPath = await ethers.deployContract("WarmPath");
await WarmPath.deployed();
console.log("WarmPath:", await WarmPath.address);

// deploy LiquidityMiningPath
const LiquidityMiningPath = await ethers.deployContract(
"LiquidityMiningPath"
);

console.log("CrocSwapDex:", await dex.address);
console.log("HotProxy:", await HotProxy.address);
console.log("WarmPath:", await WarmPath.address);
console.log("ColdPath:", await ColdPath.address);
console.log("LongPath:", await LongPath.address);
console.log("MicroPaths:", await MicroPaths.address);
console.log("KnockoutLiqPath:", await KnockoutLiqPath.address);
console.log("KnockoutFlagPath:", await KnockoutFlagPath.address);
console.log("SafeModePath:", await SafeModePath.address);
await LiquidityMiningPath.deployed();
console.log("LiquidityMiningPath:", await LiquidityMiningPath.address);
}

Expand Down
139 changes: 73 additions & 66 deletions misc/scripts/deploy_canto/deploy2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ var AbiCoder = require("@ethersproject/abi").AbiCoder;

const abi = new AbiCoder();

// testnet addresses 1
// mainnet addresses 1
const addresses = {
CrocSwapDex: "0xA4C0F8febA559083Fe47E396f7C4f047E8820253",
HotProxy: "0xcf883bB0B1903b96B10242696D62d54BE94Aa2f5",
WarmPath: "0xafC5554c7710F760E79f748eb900A28B7b1E4FA7",
ColdPath: "0x3b62C6B3430832B970551eab21268e7C87A48912",
LongPath: "0x4d9E727A61b8BEc65300A1b05b31E01C82d4B982",
MicroPaths: "0x663f021531BDE01C2373dA41c3144115e06f9211",
KnockoutLiqPath: "0xcA54dcD6B08687e61D0E44010af35C65C4EDefF4",
KnockoutFlagPath: "0x575298cbc88faB5433928D1cF27C57d779677844",
SafeModePath: "0xC428162feD5E33cBf604dfCBa8Eb9247DE9722a4",
LiquidityMiningPath: "0x5e27C6FD3967275E566F55A4F2f2e56A0d29A461",
CrocSwapDex: "0x9290C893ce949FE13EF3355660d07dE0FB793618",
ColdPath: "0x9B2a63F27661A468E2da22226b64A4914144f195",
HotProxy: "0x35FF0Ae8D893aC4c1Cefd4B5ac80eAb96684D9B7",
KnockoutLiqPath: "0x29BfE042158b5a213c224AFE44C749eC4429527A",
KnockoutFlagPath: "0x35E66506D8d1f456Ac0eD8fF0C50a847d43ec02C",
LongPath: "0x54861bdc3Ce98b0d11a4fEaA965dA97d239762d5",
MicroPaths: "0xB183D02122F55f928d711Ef10C3758A512aCaBd3",
SafeModePath: "0xf6153C52EEdA76728A2139F3ec5a6cE055266F40",
WarmPath: "0x74ff14e7E80DC76C355B156A06882e18C1938A19",
LiquidityMiningPath: "0x2D826ae54b06839042Da0c9B81EAB34bfeA05646",
};

const BOOT_PROXY_IDX = 0;
Expand All @@ -39,61 +39,68 @@ async function main() {
const dex = await CrocSwapDex.attach(addresses.CrocSwapDex);

// use protocolCmd to install paths
// install coldpath
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.ColdPath, COLD_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install longpath
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.LongPath, LONG_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install warm path
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.WarmPath, LP_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install hot proxy path
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.HotProxy, SWAP_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install micro paths
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.MicroPaths, MICRO_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install knockout lp proxy path
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.KnockoutLiqPath, KNOCKOUT_LP_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install cross knockout cross proxy path
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.KnockoutFlagPath, FLAG_CROSS_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// install liquidity mining path
cmd = abi.encode(
["uint8", "address", "uint16"],
[21, addresses.LiquidityMiningPath, LIQUIDITY_MINING_PROXY_IDX]
);
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);
// // install coldpath
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.ColdPath, COLD_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install longpath
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.LongPath, LONG_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install warm path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.WarmPath, LP_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install hot proxy path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.HotProxy, SWAP_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install micro paths
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.MicroPaths, MICRO_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install knockout lp proxy path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.KnockoutLiqPath, KNOCKOUT_LP_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install cross knockout cross proxy path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.KnockoutFlagPath, FLAG_CROSS_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install safe mode path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.SafeModePath, SAFE_MODE_PROXY_PATH]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);

// // install liquidity mining path
// cmd = abi.encode(
// ["uint8", "address", "uint16"],
// [21, addresses.LiquidityMiningPath, LIQUIDITY_MINING_PROXY_IDX]
// );
// await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true);
}

main()
Expand Down
2 changes: 1 addition & 1 deletion misc/scripts/deploy_canto/deploy3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Deploy Croc Lens Contracts

// testnet dex address
const dexAddress = "0xA4C0F8febA559083Fe47E396f7C4f047E8820253";
const dexAddress = "0x9290C893ce949FE13EF3355660d07dE0FB793618";

async function main() {
const [deployer] = await ethers.getSigners();
Expand Down
16 changes: 8 additions & 8 deletions misc/scripts/deploy_canto/deploy4Pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const abi = new AbiCoder();
const PRECISION = 100000000;
const Q_64 = BigNumber.from(2).pow(64);

// testnet dex address
const dexAddress = "0xA4C0F8febA559083Fe47E396f7C4f047E8820253";
const usdcAddress = "0xc51534568489f47949A828C8e3BF68463bdF3566";
const cNoteAddress = "0x04E52476d318CdF739C38BD41A922787D441900c";
// mainnet dex address
const dexAddress = "0x9290C893ce949FE13EF3355660d07dE0FB793618";
const usdcAddress = "0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd";
const cNoteAddress = "0xEe602429Ef7eCe0a13e4FfE8dBC16e101049504C";

async function main() {
const [deployer] = await ethers.getSigners();
Expand All @@ -31,7 +31,7 @@ async function main() {
approveCNOTE = await cNOTE.approve(dexAddress, BigNumber.from(10).pow(36));
await approveCNOTE.wait();

/*
/*
/ 2. set new pool liquidity (amount to lock up for new pool)
/ params = [code, liq]
*/
Expand All @@ -46,7 +46,7 @@ async function main() {
*/
let templateCmd = abi.encode(
["uint8", "uint256", "uint16", "uint16", "uint8", "uint8", "uint8"],
[110, 36000, 500, 1, 2, 64, 0]
[110, 36000, 100, 1, 8, 64, 0]
);
tx = await dex.protocolCmd(3, templateCmd, false);
await tx.wait();
Expand All @@ -58,11 +58,11 @@ async function main() {
*/
let initPoolCmd = abi.encode(
["uint8", "address", "address", "uint256", "uint128"],
[71, cNoteAddress, usdcAddress, 36000, toSqrtPrice(Math.pow(10, 12))]
[71, usdcAddress, cNoteAddress, 36000, toSqrtPrice(Math.pow(10, -12))]
);
tx = await dex.userCmd(3, initPoolCmd, { gasLimit: 6000000 });
await tx.wait();
console.log(tx);
console.log("Initialized new pool");

// // -----------------------------
// // EXTRA FUNCTIONS
Expand Down
23 changes: 11 additions & 12 deletions misc/scripts/deploy_canto/deploy5AddLiquidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const PRECISION = 100000000;
const Q_64 = BigNumber.from(2).pow(64);

// testnet dex address
const dexAddress = "0xA4C0F8febA559083Fe47E396f7C4f047E8820253";
const usdcAddress = "0xc51534568489f47949A828C8e3BF68463bdF3566";
const cNoteAddress = "0x04E52476d318CdF739C38BD41A922787D441900c";
const dexAddress = "0x9290C893ce949FE13EF3355660d07dE0FB793618";
const usdcAddress = "0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd";
const cNoteAddress = "0xEe602429Ef7eCe0a13e4FfE8dBC16e101049504C";

async function main() {
const [deployer] = await ethers.getSigners();
Expand All @@ -21,7 +21,7 @@ async function main() {
const CrocSwapDex = await hre.ethers.getContractFactory("CrocSwapDex");
const dex = await CrocSwapDex.attach(dexAddress);

const currentTick = 276324;
const currentTick = -276325;
const ZERO_ADDR = "0x0000000000000000000000000000000000000000";

// Mint concentrated liquidity
Expand All @@ -41,21 +41,20 @@ async function main() {
],
[
11, // code (mint concentrated liquidity in base token liq)
cNoteAddress, // base token
usdcAddress, // quote token
usdcAddress, // base token
cNoteAddress, // quote token
36000, // poolIDX
currentTick - 10, // tickLower
currentTick + 10, // tickUpper
BigNumber.from("100000000000000000000"), // amount of base token to send
BigNumber.from("16602069666338596454400000"), // min price
BigNumber.from("20291418481080506777600000"), // max price
currentTick - 75, // tickLower
currentTick + 75, // tickUpper
BigNumber.from("10000000"), // amount of base token to send
BigNumber.from("18446744073"), // min price
BigNumber.from("18446744073709000"), // max price
0, // reserve flag
ZERO_ADDR, // lp conduit address (0 if not using)
]
);
tx = await dex.userCmd(2, mintConcentratedLiqCmd, {
gasLimit: 6000000,
value: ethers.utils.parseUnits("1", "ether"),
});
await tx.wait();
console.log(tx);
Expand Down
Loading

0 comments on commit a9fa5e9

Please sign in to comment.