Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const usnAddress = "0x5183e1b1091804bc2602586919e6880ac1cf2896";
export const usdTLPAddress = "0x87BCC091d0A7F9352728100268Ac8D25729113bB";
export const pTRIAddress = "0xe559092D2e80d9B1d91a641CE25bACC3cFdCF689";
export const nusdAddress = "0x07379565cD8B0CaE7c60Dc78e7f601b34AF2A21c";
export const auUSDCAddress = "0x4f0d864b1ABf4B701799a0b30b57A22dFEB5917b";
export const auUSDTAddress = "0xaD5A2437Ff55ed7A8Cad3b797b3eC7c5a19B1c54";

export const babooRecepientAddress = "0x7F188C75E887454f5f47bDF76fe2Fa048985930F";
export const donRecepientAddress = "0xB1B0831466E6432843a27aF36924Df9E56E6C649";
Expand Down Expand Up @@ -80,5 +82,12 @@ export const nusdPoolSwapUtilsAddress = "0xedbc9d412854585F71c3765697167b462e51B
export const nusdPoolSwapDepositAddress = "0xCCd87854f58773fe75CdDa542457aC48E46c2D65";
export const nusdPoolSwapFlashLoanAddress = "0x3CE7AAD78B9eb47Fd2b487c463A17AAeD038B7EC";

// Aurigami Stableswap core contracts
export const aurigamiTwoPoolLPTokenBaseAddress = "0x895BDc6644Ae2652dB22b9387b004C091eF868fE";
export const aurigamiTwoPoolAmplificationUtilsAddress = "0x2F928da9eaeCECA6f1D284f48589F7E456A1aBc2";
export const aurigamiTwoPoolSwapUtilsAddress = "0x0982eBCbf1B77b4dBFB6BcAD62340687237Ac663";
export const aurigamiTwoPoolSwapFlashLoanAddress = "0x46F27692de8aA76E86e7E665e573828b9ddcB2b8";
export const aurigamiTwoPoolLpTokenAddress = "0x2e5F03c34A771F50C97E8f77EF801C426636e5Cd";

export const dao = "0xf86119de6ee8d4447C8219eEC20E7561d09816d3";
export const ops = "0x99cbfCf7134228e12e9ED0F534C73C85A03C91E1";
126 changes: 126 additions & 0 deletions scripts/deployAuStableswap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import { ethers } from "hardhat";
import { auUSDCAddress, auUSDTAddress } from "./constants";

type DeployedContracts = {
lpTokenBaseAddress: string;
amplificationUtilsAddress: string;
swapUtilsAddress: string;
swapFlashLoanAddress: string;
lpTokenAddress: string;
};

async function main(): Promise<DeployedContracts> {
// Hardhat always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
// to make sure everything is compiled
// await run("compile");
// We get the contract to deploy

// Constants
const [_, deployer] = await ethers.getSigners();
console.log(`Deploying contracts with ${deployer.address}`);

const erc20Factory = await ethers.getContractFactory("ERC20Mock");
const auUSDC = erc20Factory.attach(auUSDCAddress);
const auUSDT = erc20Factory.attach(auUSDTAddress);

const auUSDCDecimals = await auUSDC.decimals();
const auUSDTDecimals = await auUSDT.decimals();

const LpTokenFactory = await ethers.getContractFactory("LPToken", deployer);
const lpTokenBase = await LpTokenFactory.deploy();
await lpTokenBase.deployed();
console.log(`LPToken Base deployed at ${lpTokenBase.address}`);

const AmpUtilsFactory = await ethers.getContractFactory("AmplificationUtils", deployer);
const amplificationUtils = await AmpUtilsFactory.deploy();
await amplificationUtils.deployed();
console.log(`amplificationUtils deployed at ${amplificationUtils.address}`);

const SwapUtilsFactory = await ethers.getContractFactory("SwapUtils", deployer);
const swapUtils = await SwapUtilsFactory.deploy();
await swapUtils.deployed();
console.log(`swapUtils deployed at ${swapUtils.address}`);

const SwapFlashLoanFactory = await ethers.getContractFactory("SwapFlashLoan", {
libraries: {
SwapUtils: swapUtils.address,
AmplificationUtils: amplificationUtils.address,
},
});
const swapFlashLoan = await SwapFlashLoanFactory.connect(deployer).deploy();
await swapFlashLoan.deployed();
console.log(`swapFlashLoan deployed at ${swapFlashLoan.address}`);

// Constructor arguments
const TOKEN_ADDRESSES = [auUSDC.address, auUSDT.address];
const TOKEN_DECIMALS = [auUSDCDecimals, auUSDTDecimals];
const LP_TOKEN_NAME = "Trisolaris auUSDC/auUSDT";
const LP_TOKEN_SYMBOL = "auUSDC/auUSDT TLP";
const INITIAL_A = 500;
const SWAP_FEE = 10e6; // 10bps
const ADMIN_FEE = 5 * 10e8; // 50%

await swapFlashLoan
.connect(deployer)
.initialize(
TOKEN_ADDRESSES,
TOKEN_DECIMALS,
LP_TOKEN_NAME,
LP_TOKEN_SYMBOL,
INITIAL_A,
SWAP_FEE,
ADMIN_FEE,
lpTokenBase.address,
);
const swapStorage = await swapFlashLoan.swapStorage();
const lpToken = LpTokenFactory.attach(swapStorage.lpToken);
console.log(`lpToken deployed at ${lpToken.address}`);

// Verify contracts

// await run("verify:verify", {
// address: amplificationUtils.address,
// constructorArguments: [],
// });

// await run("verify:verify", {
// address: lpTokenBase.address,
// constructorArguments: [],
// });

// await run("verify:verify", {
// address: swapUtils.address,
// constructorArguments: [],
// });

// await run("verify:verify", {
// address: swapFlashLoan.address,
// constructorArguments: [],
// });

// Can't verify lpToken because it's internally deployed via swapFlashLoan constructor

const deployedContracts: DeployedContracts = {
lpTokenBaseAddress: lpTokenBase.address,
amplificationUtilsAddress: amplificationUtils.address,
swapUtilsAddress: swapUtils.address,
swapFlashLoanAddress: swapFlashLoan.address,
lpTokenAddress: lpToken.address,
};

return deployedContracts;
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error);
process.exit(1);
});