Skip to content

Commit

Permalink
add fee exemption whitelist - deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Oct 15, 2024
1 parent d023342 commit 4b92c2a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 31 deletions.
42 changes: 42 additions & 0 deletions deploy/scripts/000065-upgrade-network-v11.ts
Original file line number Diff line number Diff line change
@@ -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);
26 changes: 26 additions & 0 deletions deploy/tests/000065-upgrade-network-v11.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
34 changes: 4 additions & 30 deletions deployments/run-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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}
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const config: HardhatUserConfig = {
settings: {
optimizer: {
enabled: true,
runs: 200
runs: 180
},
metadata: {
bytecodeHash: 'none'
Expand Down

0 comments on commit 4b92c2a

Please sign in to comment.