Skip to content

Commit

Permalink
Merge branch 'develop' into features/deploy-scripts-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Robsonsjre committed May 13, 2021
2 parents f035919 + 406e5d2 commit 4ac220c
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 2 deletions.
22 changes: 22 additions & 0 deletions contracts/mocks/tokens/WMATIC.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.6.12;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../../interfaces/IWETH.sol";

contract WMATIC is IWETH, ERC20 {
constructor() public ERC20("Wrapped Matic", "WMATIC") {}

function deposit() public payable override {
_mint(msg.sender, msg.value);
emit Deposit(msg.sender, msg.value);
}

function withdraw(uint256 amount) public override {
_burn(msg.sender, amount);
Address.sendValue(msg.sender, amount);
emit Withdrawal(msg.sender, amount);
}
}
2 changes: 1 addition & 1 deletion deployments/mumbai.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"WETH": "0x2f9374157Ef337620b19a720019A6FDB0593d20B",
"WMATIC": "0x9D6AaaDc30f8E7F248412B1B44C32a1819a23d68",
"WMATIC": "0xfe7f1ef1386E6df3D462E30aa5709FB5Ef647eC9",
"WBTC": "0x41Ec38673f377D8A8c28359CBEfc132791A6efC5",
"USDC": "0x2058A9D7613eEE744279e3856Ef0eAda5FCbaA7e",
"DAI": "0x001B3B4d0F3714Ca98ba10F6042DaEbF0B1B7b6F",
Expand Down
24 changes: 24 additions & 0 deletions tasks/configuration/getParameters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
task('getParameter', 'Get a ConfigurationManager parameter')
.addPositionalParam('parameter', 'Parameter name')
.addOptionalParam('configurator', 'An address of a deployed ConfigurationManager, defaults to current `deployments` json file')
.setAction(async ({ configurator, parameter }, bre) => {
const filePath = `../../deployments/${bre.network.name}.json`

if (!configurator) {
const json = require(filePath)
configurator = json.configurationManager
}

if (!ethers.utils.isAddress(configurator)) {
throw new Error(`\`configurator\` is not an address. Received: ${configurator}`)
}

const configurationManager = await ethers.getContractAt('ConfigurationManager', configurator)

const parameterName = ethers.utils.formatBytes32String(parameter)
const currentValue = (await configurationManager.getParameter(parameterName)).toString()

console.log(`Getting ConfigurationManager(${configurationManager.address})\nParameter: ${parameter}\nValue: ${currentValue}`)

return currentValue
})
2 changes: 1 addition & 1 deletion tasks/configuration/increaseCap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ task('increaseCap', 'Increase an option or pool cap')
const valueToSend = max ? 0 : value

const tx = await capContract.setCap(contract, valueToSend)
const txReceipt = tx.wait()
const txReceipt = await tx.wait()
console.log(`transactionHash: ${txReceipt.transactionHash}`)
console.log('======== END MODIFY CONTRACT CAP ==========')
})
2 changes: 2 additions & 0 deletions tasks/configuration/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require('./deployConfigurationManager')
require('./linkConfigurationManager')
require('./inspectConfigurationManager')
require('./getParameters')
require('./emergencyStop')
require('./increaseCap')
require('./setParameter')
50 changes: 50 additions & 0 deletions tasks/configuration/setParameter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
task('setParameter', 'Set a ConfigurationManager parameter')
.addPositionalParam('parameter', 'Parameter name')
.addPositionalParam('value', 'New value')
.addOptionalParam('configurator', 'An address of a deployed ConfigurationManager, defaults to current `deployments` json file')
.addFlag('noUpdate', 'Specifies if the param change should trigger update on dependent contract, defaults to true')
.setAction(async ({ configurator, parameter, value, noUpdate }, bre) => {
const filePath = `../../deployments/${bre.network.name}.json`

if (!configurator) {
const json = require(filePath)
configurator = json.configurationManager
}

if (!ethers.utils.isAddress(configurator)) {
throw new Error(`\`configurator\` is not an address. Received: ${configurator}`)
}

const configurationManager = await ethers.getContractAt('ConfigurationManager', configurator)

const parameterName = ethers.utils.formatBytes32String(parameter)
const parameterValue = ethers.BigNumber.from(value)
const currentValue = (await configurationManager.getParameter(parameterName)).toString()

console.log(`Setting ConfigurationManager(${configurationManager.address})\nParameter: ${parameter}\nValue: ${currentValue}${value}`)

const tx = await configurationManager.setParameter(parameterName, parameterValue)
const txReceipt = await tx.wait()
console.log(`Done! Transaction hash: ${txReceipt.transactionHash}`)

if (!noUpdate) {
let updateTx, updateReceipt

switch (parameter) {
case 'MIN_UPDATE_INTERVAL':
const priceProvider = await ethers.getContractAt('PriceProvider', await configurationManager.getPriceProvider())
console.log(`Updating PriceProvider(${priceProvider.address})`)
updateTx = await priceProvider.updateMinUpdateInterval()
updateReceipt = await updateTx.wait()
console.log(`Done! Transaction hash: ${updateReceipt.transactionHash}`)
break
case 'GUESSER_ACCEPTABLE_RANGE':
const sigmaGuesser = await ethers.getContractAt('SigmaGuesser', await configurationManager.getSigmaGuesser())
console.log(`Updating SigmaGuesser(${sigmaGuesser.address})`)
updateTx = await sigmaGuesser.updateAcceptableRange()
updateReceipt = await updateTx.wait()
console.log(`Done! Transaction hash: ${updateReceipt.transactionHash}`)
break
}
}
})

0 comments on commit 4ac220c

Please sign in to comment.