Created
September 13, 2021 17:46
-
-
Save PJColombo/e46b891bc4a4e52733df7aeea2ffd464 to your computer and use it in GitHub Desktop.
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
import { ethers } from "hardhat"; | |
import ora from "ora"; | |
import { EVMcrispr } from "../src"; | |
import { Contract } from "ethers"; | |
import { toDecimals, TX_GAS_LIMIT, TX_GAS_PRICE } from "../src/helpers"; | |
let spinner = ora(); | |
// COMMONS UPGRADE PARAMETERS | |
// const gardensDAOAddress = "0x8bebd1c49336Bf491ef7bd8a7f9A5d267081b33E"; | |
// const gardensDAOAddress = "0x1384504dEdEeE896BD10f723cF14fb1aB0Af2ceA"; // Gardens DAO to be upgraded. | |
// const gardensDAOAddress = "0xe6313a030b7f8089f9af11c9f823175b524c7d6d"; // TEC gardens | |
const gardensDAOAddress = "0x8816c0e78dd45408d7ee92ca67e297b0ea99e606"; // Gardens 3 | |
const collateralTokenAddress = "0xc7ad46e0b8a400bb3c915120d284aafba8fc4735"; // ABC's collateral token (e.g. wxDAI). | |
const hatchMigrationToolsAddress = "0xcee0b7f18d12943926f31c627104024113faa6be"; // Migration tools app installed on the Hatch. | |
const entryTribute = 0.1; // The entry tribute to be deducted from buy order. | |
const exitTribute = 0.2; // The exit tribute to be deducted from sell orders. | |
const reserveRatio = 0.2; // The reserve ratio to be used for that collateral token. | |
const PPM = 1000000; | |
/** | |
* Agent:1 Funding pool | |
* Agent:reserve: Reserve pool | |
*/ | |
async function main() { | |
const signer = (await ethers.getSigners())[0]; | |
const evmcrispr = await EVMcrispr.create(signer, gardensDAOAddress, { ipfsGateway: "https://ipfs.io/ipfs/" }); | |
spinner = spinner.start(`Connect evmcrispr to DAO ${gardensDAOAddress}`); | |
const cache = evmcrispr.appCache; | |
spinner = spinner.succeed(); | |
// const { codeAddress: bancorFormulaBaseAddress } = await evmcrispr.connector.repo("bancor-formula", "aragonpm.eth"); | |
spinner = spinner.start(`Encode script`); | |
console.log(`Vault1: ${evmcrispr.app("agent:1")()}`); | |
// console.log(`Vault1: ${evmcrispr.app("agent:reserve")}`) | |
const encodedAction = await evmcrispr.encode( | |
[ | |
evmcrispr.installNewApp("agent:reserve"), | |
evmcrispr.installNewApp("migration-tools.open:mtb", [ | |
evmcrispr.app("wrappable-hooked-token-manager.open"), | |
evmcrispr.app("agent:1"), // Common pool as Migration Tools' vault 1 | |
evmcrispr.app("agent:reserve"), // Reserve pool as Migration Tools' vault 2 | |
0, | |
]), | |
], | |
["disputable-voting.open"], | |
{ | |
context: "Commons Upgrade", | |
} | |
); | |
console.log(encodedAction.action); | |
// const encodedAction = await evmcrispr.encode( | |
// [ | |
// evmcrispr.installNewApp("agent:reserve"), | |
// evmcrispr.installNewApp("augmented-bonding-curve.open:abc", [ | |
// evmcrispr.app("wrappable-hooked-token-manager.open"), | |
// bancorFormulaBaseAddress, | |
// evmcrispr.app("agent:reserve"), | |
// // Fees are going to the common pool | |
// evmcrispr.app("agent:1"), | |
// // Percentage values are represented in 18-decimal base | |
// toDecimals(entryTribute), | |
// toDecimals(exitTribute), | |
// ]), | |
// evmcrispr.installNewApp("migration-tools.open:mtb", [ | |
// evmcrispr.app("wrappable-hooked-token-manager.open"), | |
// evmcrispr.app("agent:1"), // Common pool as Migration Tools' vault 1 | |
// evmcrispr.app("agent:reserve"), // Reserve pool as Migration Tools' vault 2 | |
// 0, | |
// ]), | |
// evmcrispr.addPermissions( | |
// [ | |
// ["disputable-voting", "augmented-bonding-curve.open:abc", "OPEN_TRADING_ROLE"], | |
// [evmcrispr.ANY_ENTITY, "augmented-bonding-curve.open:abc", "MAKE_BUY_ORDER_ROLE"], | |
// [evmcrispr.ANY_ENTITY, "augmented-bonding-curve.open:abc", "MAKE_SELL_ORDER_ROLE"], | |
// ["disputable-voting", "augmented-bonding-curve.open:abc", "ADD_COLLATERAL_TOKEN_ROLE"], | |
// ["augmented-bonding-curve.open:abc", "wrappable-hooked-token-manager.open", "MINT_ROLE"], | |
// ["augmented-bonding-curve.open:abc", "wrappable-hooked-token-manager.open", "BURN_ROLE"], | |
// ["augmented-bonding-curve.open:abc", "agent:reserve", "TRANSFER_ROLE"], | |
// [hatchMigrationToolsAddress, "migration-tools.open:mtb", "PREPARE_CLAIMS_ROLE"], | |
// ["migration-tools.open:mtb", "wrappable-hooked-token-manager.open", "ISSUE_ROLE"], | |
// ["migration-tools.open:mtb", "wrappable-hooked-token-manager.open", "ASSIGN_ROLE"], | |
// ], | |
// "disputable-voting" | |
// ), | |
// evmcrispr.revokePermissions([ | |
// ["dynamic-issuance.open", "wrappable-hooked-token-manager.open", "MINT_ROLE"], | |
// ["dynamic-issuance.open", "wrappable-hooked-token-manager.open", "BURN_ROLE"], | |
// ["disputable-voting", "dynamic-issuance.open", "UPDATE_SETTINGS_ROLE"], | |
// ]), | |
// evmcrispr | |
// .call("augmented-bonding-curve.open:abc") | |
// .addCollateralToken(collateralTokenAddress, 1, 0, reserveRatio * PPM), | |
// ], | |
// ["disputable-voting.open"], | |
// { context: "Commons Upgrade" } | |
// ); | |
spinner.succeed(); | |
spinner = spinner.start(`Forwarding script`); | |
const txReceipt = await ( | |
await signer.sendTransaction({ | |
...encodedAction.action, | |
gasLimit: TX_GAS_LIMIT, | |
gasPrice: TX_GAS_PRICE, | |
}) | |
).wait(); | |
spinner.succeed(); | |
console.log(txReceipt.transactionHash); | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch((error) => { | |
spinner.fail(); | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment