From 4b92c2af4ef032b920a12cdf28219c5225c66404 Mon Sep 17 00:00:00 2001 From: Ivan Zhelyazkov Date: Tue, 15 Oct 2024 19:42:19 +0300 Subject: [PATCH] add fee exemption whitelist - deployment scripts --- deploy/scripts/000065-upgrade-network-v11.ts | 42 ++++++++++++++++++++ deploy/tests/000065-upgrade-network-v11.ts | 26 ++++++++++++ deployments/run-fork.sh | 34 ++-------------- hardhat.config.ts | 2 +- 4 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 deploy/scripts/000065-upgrade-network-v11.ts create mode 100644 deploy/tests/000065-upgrade-network-v11.ts diff --git a/deploy/scripts/000065-upgrade-network-v11.ts b/deploy/scripts/000065-upgrade-network-v11.ts new file mode 100644 index 000000000..580314b24 --- /dev/null +++ b/deploy/scripts/000065-upgrade-network-v11.ts @@ -0,0 +1,42 @@ +import { DeployedContracts, execute, InstanceName, setDeploymentMetadata, upgradeProxy } from '../../utils/Deploy'; +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, + carbonPOLAddress + ], + from: deployer + }); + + // add bancor arbitrage contract address to fee exemption whitelist + await execute({ + name: InstanceName.BancorNetwork, + methodName: 'addToWhitelist', + args: [bancorArbitrageAddress], + from: deployer + }); + + return true; +}; + +export default setDeploymentMetadata(__filename, func); diff --git a/deploy/tests/000065-upgrade-network-v11.ts b/deploy/tests/000065-upgrade-network-v11.ts new file mode 100644 index 000000000..9aec892ab --- /dev/null +++ b/deploy/tests/000065-upgrade-network-v11.ts @@ -0,0 +1,26 @@ +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'; +import { getNamedAccounts } from 'hardhat'; + +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(11); + expect(await network.minNetworkFeeBurn()).to.equal(toWei(1_000_000)); + }); + + it('should have added bancor arbitrage contract address to fee exemption whitelist', async () => { + const { bancorArbitrageAddress } = await getNamedAccounts(); + + const whitelist = await network.feeExemptionWhitelist(); + expect(whitelist).to.include(bancorArbitrageAddress); + }); +}); diff --git a/deployments/run-fork.sh b/deployments/run-fork.sh index f1b737e70..244f3f0d3 100755 --- a/deployments/run-fork.sh +++ b/deployments/run-fork.sh @@ -12,18 +12,6 @@ else project=${TENDERLY_PROJECT} fi -# Read the network name from the environment variable, default to 'mainnet' if not set -network_name=${TENDERLY_NETWORK_NAME:-'mainnet'} - -# Check if network_id is null or empty -if [ -z "$network_id" ] || [ "$network_id" == "null" ]; then - # Fallback to the default network ID - network_id=${TENDERLY_NETWORK_ID:-"1"} -fi - -echo "Creating a $network_name Tenderly Fork with Chain Id $network_id... " -echo - TENDERLY_FORK_API="https://api.tenderly.co/api/v1/account/${username}/project/${project}/fork" cleanup() { @@ -40,29 +28,15 @@ trap cleanup TERM EXIT fork_id=$(curl -sX POST "${TENDERLY_FORK_API}" \ -H "Content-Type: application/json" -H "X-Access-Key: ${TENDERLY_ACCESS_KEY}" \ - -d '{"network_id": "'${network_id}'"}' | jq -r '.simulation_fork.id') + -d '{"network_id": "1"}' | jq -r '.simulation_fork.id') -echo "Created Tenderly Fork ${fork_id} at ${username}/${project}..." +echo "Created a fork ${fork_id} at ${username}/${project}..." echo -# if deployments/${network_name} doesn't exist, create it and create a .chainId file -if [ ! -d "./deployments/${network_name}" ]; then - mkdir -p ./deployments/${network_name} - echo ${network_id} > ./deployments/${network_name}/.chainId -fi - -# if deploy/scripts/${network_name} doesn't exist, create it and copy the network scripts -if [ ! -d "./deploy/scripts/${network_name}" ]; then - rsync -a --delete ./deploy/scripts/network/ ./deploy/scripts/${network_name}/ -fi - -# Create a new dir for the deploy script files and copy them there -rm -rf deployments/tenderly && cp -rf deployments/${network_name}/. deployments/tenderly - -command="TENDERLY_FORK_ID=${fork_id} TENDERLY_NETWORK_NAME=${network_name} ${@:1}" +command="TENDERLY_FORK_ID=${fork_id} ${@:1}" echo "Running:" echo echo ${command} -eval ${command} +eval ${command} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 53135eb2d..0e7731cb5 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -124,7 +124,7 @@ const config: HardhatUserConfig = { settings: { optimizer: { enabled: true, - runs: 200 + runs: 180 }, metadata: { bytecodeHash: 'none'