diff --git a/contracts/carbon/CarbonController.sol b/contracts/carbon/CarbonController.sol index f7f91d02..fd9680ce 100644 --- a/contracts/carbon/CarbonController.sol +++ b/contracts/carbon/CarbonController.sol @@ -92,7 +92,7 @@ contract CarbonController is * @inheritdoc Upgradeable */ function version() public pure virtual override(IVersioned, Upgradeable) returns (uint16) { - return 4; + return 5; } /** diff --git a/data/named-accounts.ts b/data/named-accounts.ts index eb96e925..972528a3 100644 --- a/data/named-accounts.ts +++ b/data/named-accounts.ts @@ -21,7 +21,7 @@ const TestNamedAccounts = { ...mainnet('0x55FE002aefF02F77364de339a1292923A15844B8') }, wbtcWhale: { - ...mainnet('0x77134cbC06cB00b66F4c7e623D5fdBF6777635EC') + ...mainnet('0x051d091B254EcdBBB4eB8E6311b7939829380b27') }, bntWhale: { ...mainnet('0x221A0e3C9AcEa6B3f1CC9DfC7063509c89bE7BC3') diff --git a/deploy/scripts/0010-CarbonController-upgrade.ts b/deploy/scripts/0010-CarbonController-upgrade.ts new file mode 100644 index 00000000..f0e41a0c --- /dev/null +++ b/deploy/scripts/0010-CarbonController-upgrade.ts @@ -0,0 +1,22 @@ +import { DeployedContracts, InstanceName, setDeploymentMetadata, upgradeProxy } from '../../utils/Deploy'; +import { DeployFunction } from 'hardhat-deploy/types'; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; + +/** + * @dev trade by source extended input upgrade + */ +const func: DeployFunction = async ({ getNamedAccounts }: HardhatRuntimeEnvironment) => { + const { deployer } = await getNamedAccounts(); + const voucher = await DeployedContracts.Voucher.deployed(); + + const carbonController = await DeployedContracts.CarbonController.deployed(); + await upgradeProxy({ + name: InstanceName.CarbonController, + from: deployer, + args: [voucher.address, carbonController.address] + }); + + return true; +}; + +export default setDeploymentMetadata(__filename, func); diff --git a/deploy/tests/0010-carbon-controller-upgrade.ts b/deploy/tests/0010-carbon-controller-upgrade.ts new file mode 100644 index 00000000..175ce060 --- /dev/null +++ b/deploy/tests/0010-carbon-controller-upgrade.ts @@ -0,0 +1,31 @@ +import { CarbonController, ProxyAdmin } from '../../components/Contracts'; +import { DeployedContracts } from '../../utils/Deploy'; +import { describeDeployment } from '../../utils/helpers/Deploy'; +import { expect } from 'chai'; +import { ethers } from 'hardhat'; + +describeDeployment(__filename, () => { + let proxyAdmin: ProxyAdmin; + let carbonController: CarbonController; + + beforeEach(async () => { + proxyAdmin = await DeployedContracts.ProxyAdmin.deployed(); + carbonController = await DeployedContracts.CarbonController.deployed(); + }); + + it('should deploy and configure the carbon controller contract', async () => { + expect(await proxyAdmin.getProxyAdmin(carbonController.address)).to.equal(proxyAdmin.address); + expect(await carbonController.version()).to.equal(5); + }); + + it('carbon controller implementation should be initialized', async () => { + const implementationAddress = await proxyAdmin.getProxyImplementation(carbonController.address); + const carbonControllerImpl: CarbonController = await ethers.getContractAt( + 'CarbonController', + implementationAddress + ); + // hardcoding gas limit to avoid gas estimation attempts (which get rejected instead of reverted) + const tx = await carbonControllerImpl.initialize({ gasLimit: 6000000 }); + await expect(tx.wait()).to.be.reverted; + }); +}); diff --git a/deployments/setup-fork.ts b/deployments/setup-fork.ts index d1e91805..271e3a77 100644 --- a/deployments/setup-fork.ts +++ b/deployments/setup-fork.ts @@ -41,17 +41,23 @@ const fundAccount = async (account: string, fundingRequests: FundingRequest[]) = Logger.log(`Funding ${account}...`); for (const fundingRequest of fundingRequests) { - if (fundingRequest.token === NATIVE_TOKEN_ADDRESS) { - await fundingRequest.whale.sendTransaction({ - value: fundingRequest.amount, - to: account - }); - - continue; + try { + if (fundingRequest.token === NATIVE_TOKEN_ADDRESS) { + await fundingRequest.whale.sendTransaction({ + value: fundingRequest.amount, + to: account + }); + + continue; + } + + const tokenContract = await Contracts.ERC20.attach(fundingRequest.token); + await tokenContract.connect(fundingRequest.whale).transfer(account, fundingRequest.amount); + } catch (error) { + Logger.error(`Failed to fund ${account} with ${fundingRequest.amount} of token ${fundingRequest.token}`); + Logger.error(error); + Logger.error(); } - - const tokenContract = await Contracts.ERC20.attach(fundingRequest.token); - await tokenContract.connect(fundingRequest.whale).transfer(account, fundingRequest.amount); } }; @@ -80,7 +86,7 @@ const fundAccounts = async () => { }, { token: wbtc, - amount: toWei(100, 8), + amount: toWei(70, 8), whale: wbtcWhale } ]; diff --git a/deployments/setup-testnet.ts b/deployments/setup-testnet.ts index 90ff2071..cec968b1 100644 --- a/deployments/setup-testnet.ts +++ b/deployments/setup-testnet.ts @@ -50,17 +50,23 @@ const fundAccount = async (account: string, fundingRequests: FundingRequest[]) = if (fundingRequest.token === ZERO_ADDRESS) { continue; } - if (fundingRequest.token === NATIVE_TOKEN_ADDRESS) { - await fundingRequest.whale.sendTransaction({ - value: fundingRequest.amount, - to: account - }); - - continue; + try { + if (fundingRequest.token === NATIVE_TOKEN_ADDRESS) { + await fundingRequest.whale.sendTransaction({ + value: fundingRequest.amount, + to: account + }); + + continue; + } + + const tokenContract = await Contracts.ERC20.attach(fundingRequest.token); + await tokenContract.connect(fundingRequest.whale).transfer(account, fundingRequest.amount); + } catch (error) { + Logger.error(`Failed to fund ${account} with ${fundingRequest.amount} of token ${fundingRequest.tokenName}`); + Logger.error(error); + Logger.error(); } - - const tokenContract = await Contracts.ERC20.attach(fundingRequest.token); - await tokenContract.connect(fundingRequest.whale).transfer(account, fundingRequest.amount); } };