-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into features/deploy-scripts-fixes
- Loading branch information
Showing
6 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
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
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); | ||
} | ||
} |
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
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
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 | ||
}) |
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
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
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') |
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
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 | ||
} | ||
} | ||
}) |