Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion spot-contracts/deployments/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"proxyAdmin": "0x47bF554606254dCEC37119348AA201c5A4ef2C58",
"router": "0x5e902bdCC408550b4BD612678bE2d57677664Dc9",
"previousIssuers": ["0xAb7d17864463dEdA6c19060Ad6556e1B218c5Ba0"],
"rolloverVault": "0x942f35ce5885F737Beccd8EE3FDAAC81574D058E"
Comment thread
aalavandhan marked this conversation as resolved.
"rolloverVault": "0xca36B64BEbdf141623911987b93767dcA4bF6F1f"
}
1 change: 1 addition & 0 deletions spot-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
},
ganache: {
url: "http://127.0.0.1:8545",
chainId: 1337,
},
goerli: {
url: `https://eth-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_SECRET}`,
Expand Down
17 changes: 11 additions & 6 deletions spot-contracts/tasks/deploy/ampl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getContractFactoryFromExternalArtifacts } from "../helpers";

task("deploy:MockAMPL")
.addParam("fromIdx", "the index of sender", 0, types.int)
.addParam("verify", "flag to set false for local deployments", true, types.boolean)
.setAction(async function (args: TaskArguments, hre) {
const signer = (await hre.ethers.getSigners())[args.fromIdx];
const signerAddress = await signer.getAddress();
Expand All @@ -19,12 +20,16 @@ task("deploy:MockAMPL")
const tx2 = await ampl.setMonetaryPolicy(signerAddress);
await tx2.wait();

try {
await hre.run("verify:contract", {
address: ampl.address,
});
} catch (e) {
console.log("Unable to verify on etherscan", e);
if (args.verify) {
try {
await hre.run("verify:contract", {
address: ampl.address,
});
} catch (e) {
console.log("Unable to verify on etherscan", e);
}
} else {
console.log("Skipping verification");
}

console.log("AMPL", ampl.address);
Expand Down
92 changes: 49 additions & 43 deletions spot-contracts/tasks/deploy/buttonwood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,60 @@ import { getContractFactoryFromExternalArtifacts } from "../helpers";

const DUMMY_ADDRESS = "0x000000000000000000000000000000000000dead";

task("deploy:BondFactory").setAction(async function (_args: TaskArguments, hre) {
console.log("Signer", await (await hre.ethers.getSigners())[0].getAddress());
const BondController = await getContractFactoryFromExternalArtifacts(hre.ethers, "BondController");
const bondController = await BondController.deploy();
await bondController.deployed();
console.log("Bond controller", bondController.address);
task("deploy:BondFactory")
.addParam("verify", "flag to set false for local deployments", true, types.boolean)
.setAction(async function (args: TaskArguments, hre) {
console.log("Signer", await (await hre.ethers.getSigners())[0].getAddress());
const BondController = await getContractFactoryFromExternalArtifacts(hre.ethers, "BondController");
const bondController = await BondController.deploy();
await bondController.deployed();
console.log("Bond controller", bondController.address);

const Tranche = await getContractFactoryFromExternalArtifacts(hre.ethers, "Tranche");
const tranche = await Tranche.deploy();
await tranche.deployed();
console.log("Tranche", tranche.address);
const Tranche = await getContractFactoryFromExternalArtifacts(hre.ethers, "Tranche");
const tranche = await Tranche.deploy();
await tranche.deployed();
console.log("Tranche", tranche.address);

const TrancheFactory = await getContractFactoryFromExternalArtifacts(hre.ethers, "TrancheFactory");
const trancheFactory = await TrancheFactory.deploy(tranche.address);
await trancheFactory.deployed();
console.log("Tranche Factory", trancheFactory.address);
const TrancheFactory = await getContractFactoryFromExternalArtifacts(hre.ethers, "TrancheFactory");
const trancheFactory = await TrancheFactory.deploy(tranche.address);
await trancheFactory.deployed();
console.log("Tranche Factory", trancheFactory.address);

await tranche["init(string,string,address,address)"]("IMPLEMENTATION", "IMPL", DUMMY_ADDRESS, DUMMY_ADDRESS);
await bondController.init(
trancheFactory.address,
tranche.address,
DUMMY_ADDRESS,
[200, 300, 500],
hre.ethers.constants.MaxUint256,
0,
);
await tranche["init(string,string,address,address)"]("IMPLEMENTATION", "IMPL", DUMMY_ADDRESS, DUMMY_ADDRESS);
await bondController.init(
trancheFactory.address,
tranche.address,
DUMMY_ADDRESS,
[200, 300, 500],
hre.ethers.constants.MaxUint256,
0,
);

const BondFactory = await getContractFactoryFromExternalArtifacts(hre.ethers, "BondFactory");
const bondFactory = await BondFactory.deploy(bondController.address, trancheFactory.address);
await bondFactory.deployed();
console.log("Bond Factory", bondFactory.address);
const BondFactory = await getContractFactoryFromExternalArtifacts(hre.ethers, "BondFactory");
const bondFactory = await BondFactory.deploy(bondController.address, trancheFactory.address);
await bondFactory.deployed();
console.log("Bond Factory", bondFactory.address);

try {
await hre.run("verify:Template", { address: bondController.address });
await hre.run("verify:Template", { address: tranche.address });
await hre.run("verify:TrancheFactory", {
address: trancheFactory.address,
template: tranche.address,
});
await hre.run("verify:BondFactory", {
address: bondFactory.address,
template: bondController.address,
trancheFactory: trancheFactory.address,
});
} catch (e) {
console.log("Unable to verify on etherscan", e);
}
});
if (args.verify) {
try {
await hre.run("verify:Template", { address: bondController.address });
await hre.run("verify:Template", { address: tranche.address });
await hre.run("verify:TrancheFactory", {
address: trancheFactory.address,
template: tranche.address,
});
await hre.run("verify:BondFactory", {
address: bondFactory.address,
template: bondController.address,
trancheFactory: trancheFactory.address,
});
} catch (e) {
console.log("Unable to verify on etherscan", e);
}
} else {
console.log("Skipping verification");
}
});

task("verify:Template", "Verifies on etherscan")
.addParam("address", "the contract address", undefined, types.string, false)
Expand Down
88 changes: 53 additions & 35 deletions spot-contracts/tasks/deploy/perp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ task("deploy:BondIssuer")
.addParam("bondDuration", "length of the bonds", undefined, types.int, false)
.addParam("collateralTokenAddress", "address of the collateral token", undefined, types.string, false)
.addParam("trancheRatios", "list of tranche ratios", undefined, types.json, false)
.addParam("verify", "flag to set false for local deployments", true, types.boolean)
.setAction(async function (args: TaskArguments, hre) {
const {
bondFactoryAddress,
Expand All @@ -17,6 +18,7 @@ task("deploy:BondIssuer")
bondDuration,
collateralTokenAddress,
trancheRatios,
verify,
} = args;
console.log("Signer", await (await hre.ethers.getSigners())[0].getAddress());

Expand All @@ -27,11 +29,15 @@ task("deploy:BondIssuer")
await (await bondIssuer.init(bondDuration, trancheRatios, issueFrequency, issueWindowOffset)).wait();
await (await bondIssuer.issue()).wait();

await sleep(15);
await hre.run("verify:contract", {
address: bondIssuer.address,
constructorArguments: [bondFactoryAddress, collateralTokenAddress],
});
if (verify) {
await sleep(15);
await hre.run("verify:contract", {
address: bondIssuer.address,
constructorArguments: [bondFactoryAddress, collateralTokenAddress],
});
} else {
console.log("Skipping verification");
}

console.log("Bond issuer", bondIssuer.address);
});
Expand All @@ -42,8 +48,10 @@ task("deploy:PerpetualTranche")
.addParam("name", "the ERC20 name", undefined, types.string, false)
.addParam("symbol", "the ERC20 symbol", undefined, types.string, false)
.addParam("pricingStrategyRef", "the pricing strategy to be used", "CDRPricingStrategy", types.string)
.addParam("verify", "flag to set false for local deployments", true, types.boolean)

.setAction(async function (args: TaskArguments, hre) {
const { bondIssuerAddress, collateralTokenAddress, name, symbol, pricingStrategyRef } = args;
const { bondIssuerAddress, collateralTokenAddress, name, symbol, pricingStrategyRef, verify } = args;
const deployer = (await hre.ethers.getSigners())[0];
console.log("Signer", await deployer.getAddress());

Expand All @@ -52,7 +60,7 @@ task("deploy:PerpetualTranche")
await perp.deployed();

const BasicFeeStrategy = await hre.ethers.getContractFactory("BasicFeeStrategy");
const feeStrategy = await BasicFeeStrategy.deploy(perp.address);
const feeStrategy = await BasicFeeStrategy.deploy(perp.address, perp.address);
await feeStrategy.deployed();
await (await feeStrategy.init("0", "0", "0")).wait();

Expand Down Expand Up @@ -81,23 +89,27 @@ task("deploy:PerpetualTranche")
);
await initTx.wait();

await sleep(15);
await hre.run("verify:contract", {
address: feeStrategy.address,
constructorArguments: [perp.address, perp.address, "1000000", "1000000", "0"],
});

await hre.run("verify:contract", {
address: pricingStrategy.address,
});

await hre.run("verify:contract", {
address: discountStrategy.address,
});

await hre.run("verify:contract", {
address: perp.address,
});
if (verify) {
await sleep(15);
await hre.run("verify:contract", {
address: feeStrategy.address,
constructorArguments: [perp.address, perp.address, "1000000", "1000000", "0"],
});

await hre.run("verify:contract", {
address: pricingStrategy.address,
});

await hre.run("verify:contract", {
address: discountStrategy.address,
});

await hre.run("verify:contract", {
address: perp.address,
});
} else {
console.log("Skipping verification");
}
});

task("deploy:DiscountStrategy:computeDiscountHash")
Expand Down Expand Up @@ -134,16 +146,22 @@ task("deploy:DiscountStrategy:setDiscount")
await tx.wait();
});

task("deploy:Router").setAction(async function (args: TaskArguments, hre) {
console.log("Signer", await (await hre.ethers.getSigners())[0].getAddress());

const RouterV1 = await hre.ethers.getContractFactory("RouterV1");
const router = await RouterV1.deploy();
await router.deployed();
console.log("router", router.address);
task("deploy:Router")
.addParam("verify", "flag to set false for local deployments", true, types.boolean)
.setAction(async function (args: TaskArguments, hre) {
console.log("Signer", await (await hre.ethers.getSigners())[0].getAddress());

await sleep(15);
await hre.run("verify:contract", {
address: router.address,
const RouterV1 = await hre.ethers.getContractFactory("RouterV1");
const router = await RouterV1.deploy();
await router.deployed();
console.log("router", router.address);

if (args.verify) {
await sleep(15);
await hre.run("verify:contract", {
address: router.address,
});
} else {
console.log("Skipping verification");
}
});
});
15 changes: 10 additions & 5 deletions spot-contracts/tasks/deploy/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ task("deploy:RolloverVault")
.addParam("perpAddress", "The address of the perpetual tranche contract", undefined, types.string, false)
.addParam("name", "the ERC20 name", undefined, types.string, false)
.addParam("symbol", "the ERC20 symbol", undefined, types.string, false)
.addParam("verify", "flag to set false for local deployments", true, types.boolean)
.setAction(async function (args: TaskArguments, hre) {
const { perpAddress, name, symbol } = args;
const { perpAddress, name, symbol, verify } = args;
const deployer = (await hre.ethers.getSigners())[0];
console.log("Signer", await deployer.getAddress());

Expand All @@ -25,8 +26,12 @@ task("deploy:RolloverVault")
const initTx = await vault.init(name, symbol, perpAddress);
await initTx.wait();

await sleep(15);
await hre.run("verify:contract", {
address: implAddress,
});
if (verify) {
await sleep(15);
await hre.run("verify:contract", {
address: implAddress,
});
} else {
console.log("Skipping verification");
}
});
Loading