Skip to content

Commit

Permalink
add upgrade scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Oct 20, 2023
1 parent bb50fd7 commit 094af71
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
3 changes: 2 additions & 1 deletion contracts/network/BancorNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
* @inheritdoc Upgradeable
*/
function version() public pure override(IVersioned, Upgradeable) returns (uint16) {
return 9;
return 10;
}

/**
Expand Down Expand Up @@ -826,6 +826,7 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl

_pendingNetworkFeeAmount = 0;

// transferring bnt to the token's address burns the tokens
_masterVault.withdrawFunds(Token(address(_bnt)), payable(address(_bnt)), currentPendingNetworkFeeAmount);

emit NetworkFeesBurned(msg.sender, currentPendingNetworkFeeAmount);
Expand Down
44 changes: 44 additions & 0 deletions deploy/scripts/000064-upgrade-network-v10.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { DeployedContracts, execute, InstanceName, setDeploymentMetadata, upgradeProxy } from '../../utils/Deploy';
import { toWei } from '../../utils/Types';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async ({ getNamedAccounts }: HardhatRuntimeEnvironment) => {
const { deployer, bancorArbitrageAddress, carbonPOLAddress } = await getNamedAccounts();

// get the deployed contracts
const externalProtectionVault = await DeployedContracts.ExternalProtectionVault.deployed();
const masterVault = await DeployedContracts.MasterVault.deployed();
const networkSettings = await DeployedContracts.NetworkSettings.deployed();
const bntGovernance = await DeployedContracts.BNTGovernance.deployed();
const vbntGovernance = await DeployedContracts.VBNTGovernance.deployed();
const bnBNT = await DeployedContracts.bnBNT.deployed();

// upgrade the BancorNetwork contract
await upgradeProxy({
name: InstanceName.BancorNetwork,
args: [
bntGovernance.address,
vbntGovernance.address,
networkSettings.address,
masterVault.address,
externalProtectionVault.address,
bnBNT.address,
bancorArbitrageAddress,
carbonPOLAddress
],
from: deployer
});

// set the min network fee burn to 1M
await execute({
name: InstanceName.BancorNetwork,
methodName: 'setMinNetworkFeeBurn',
args: [toWei(1_000_000)],
from: deployer
});

return true;
};

export default setDeploymentMetadata(__filename, func);
18 changes: 18 additions & 0 deletions deploy/tests/000064-upgrade-network-v10.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { BancorNetwork } from '../../components/Contracts';
import { describeDeployment } from '../../test/helpers/Deploy';
import { DeployedContracts } from '../../utils/Deploy';
import { toWei } from '../../utils/Types';
import { expect } from 'chai';

describeDeployment(__filename, () => {
let network: BancorNetwork;

beforeEach(async () => {
network = await DeployedContracts.BancorNetwork.deployed();
});

it('should upgrade the network contract properly', async () => {
expect(await network.version()).to.equal(10);
expect(await network.minNetworkFeeBurn()).to.equal(toWei(1_000_000));
});
});
2 changes: 1 addition & 1 deletion test/network/BancorNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('BancorNetwork', () => {
});

it('should be properly initialized', async () => {
expect(await network.version()).to.equal(9);
expect(await network.version()).to.equal(10);

await expectRoles(network, Roles.BancorNetwork);

Expand Down

0 comments on commit 094af71

Please sign in to comment.