From 2f75db6d9bb03883418f381bfe3c3a0488340c59 Mon Sep 17 00:00:00 2001 From: Baptiste Guerin Date: Fri, 1 Mar 2024 17:44:16 +0100 Subject: [PATCH] fix: reward script --- .env.example | 2 +- hardhat.config.ts | 36 +++++++++++++++--------------- package.json | 2 +- scripts/setRewardTokenMinAmount.ts | 26 ++++++++++++++++----- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.env.example b/.env.example index 5d9f288..68d4575 100644 --- a/.env.example +++ b/.env.example @@ -13,4 +13,4 @@ #MNEMONIC_ARBITRUM="" #ARBITRUM_ETHERSCAN_API_KEY="" - +# DEPLOYER_PRIVATE_KEY="" diff --git a/hardhat.config.ts b/hardhat.config.ts index c06132e..1d84877 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -91,7 +91,7 @@ const config: HardhatUserConfig = { // For the lists of Chain ID: https://chainlist.org networks: { hardhat: { - accounts: accounts('coredao'), + accounts: accountsPkey, live: false, blockGasLimit: 125e5, initialBaseFeePerGas: 0, @@ -138,12 +138,12 @@ const config: HardhatUserConfig = { interval: 1000, } : { auto: true }, - chainId: 1337, + chainId: 100, }, polygon: { live: true, url: nodeUrl('polygon'), - accounts: accounts('polygon'), + accounts: [getPkey()], gas: 'auto', chainId: 137, // gasPrice: 400e9, @@ -157,7 +157,7 @@ const config: HardhatUserConfig = { fantom: { live: true, url: nodeUrl('fantom'), - accounts: accounts('fantom'), + accounts: [getPkey()], gas: 'auto', chainId: 250, verify: { @@ -195,7 +195,7 @@ const config: HardhatUserConfig = { optimism: { live: true, url: nodeUrl('optimism'), - accounts: accounts('optimism'), + accounts: [getPkey()], gas: 'auto', chainId: 10, verify: { @@ -207,7 +207,7 @@ const config: HardhatUserConfig = { arbitrum: { live: true, url: nodeUrl('arbitrum'), - accounts: accounts('arbitrum'), + accounts: [getPkey()], gas: 'auto', chainId: 42161, verify: { @@ -219,7 +219,7 @@ const config: HardhatUserConfig = { avalanche: { live: true, url: nodeUrl('avalanche'), - accounts: accounts('avalanche'), + accounts: [getPkey()], gas: 'auto', chainId: 43114, verify: { @@ -231,7 +231,7 @@ const config: HardhatUserConfig = { aurora: { live: true, url: nodeUrl('aurora'), - accounts: accounts('aurora'), + accounts: [getPkey()], gas: 'auto', chainId: 1313161554, verify: { @@ -243,7 +243,7 @@ const config: HardhatUserConfig = { bsc: { live: true, url: nodeUrl('bsc'), - accounts: accounts('bsc'), + accounts: [getPkey()], gas: 'auto', chainId: 56, verify: { @@ -255,7 +255,7 @@ const config: HardhatUserConfig = { gnosis: { live: true, url: nodeUrl('gnosis'), - accounts: accounts('gnosis'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 2, chainId: 100, @@ -269,7 +269,7 @@ const config: HardhatUserConfig = { polygonzkevm: { live: true, url: nodeUrl('polygonzkevm'), - accounts: accounts('polygonzkevm'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 1101, @@ -282,7 +282,7 @@ const config: HardhatUserConfig = { base: { live: true, url: nodeUrl('base'), - accounts: accounts('base'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 8453, @@ -295,7 +295,7 @@ const config: HardhatUserConfig = { linea: { live: true, url: nodeUrl('linea'), - accounts: accounts('linea'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 59144, @@ -308,7 +308,7 @@ const config: HardhatUserConfig = { zksync: { live: true, url: nodeUrl('zksync'), - accounts: accounts('zksync'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 324, @@ -321,7 +321,7 @@ const config: HardhatUserConfig = { mantle: { live: true, url: nodeUrl('mantle'), - accounts: accounts('mantle'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 5000, @@ -334,7 +334,7 @@ const config: HardhatUserConfig = { filecoin: { live: true, url: nodeUrl('filecoin'), - accounts: accounts('filecoin'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 314, @@ -347,7 +347,7 @@ const config: HardhatUserConfig = { thundercore: { live: true, url: nodeUrl('thundercore'), - accounts: accounts('thundercore'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 108, @@ -360,7 +360,7 @@ const config: HardhatUserConfig = { coredao: { live: true, url: nodeUrl('coredao'), - accounts: accounts('coredao'), + accounts: [getPkey()], gas: 'auto', gasMultiplier: 1.3, chainId: 1116, diff --git a/package.json b/package.json index bf3bbc7..1df3fe7 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "hardhat:test": "hardhat test", "check-upgradeability": "hardhat run scripts/checkUpgradeability.ts", "license": "hardhat prepend-spdx-license", - "node:fork": "FORK=true hardhat node --tags", + "node:fork": "FORK=true hardhat node", "size": "yarn hardhat:compile && hardhat size-contracts", "lint": "yarn lint:sol && yarn lint:js", "lint:check": "yarn lint:sol:check && yarn lint:js:check", diff --git a/scripts/setRewardTokenMinAmount.ts b/scripts/setRewardTokenMinAmount.ts index 482fa83..cc486d7 100644 --- a/scripts/setRewardTokenMinAmount.ts +++ b/scripts/setRewardTokenMinAmount.ts @@ -1,12 +1,19 @@ import { deployments, ethers } from 'hardhat'; import { DistributionCreator, DistributionCreator__factory } from '../typechain'; -import { parseEther,parseUnits } from 'ethers/lib/utils'; +import { parseEther,parseUnits, getAddress } from 'ethers/lib/utils'; +import { registry } from '@angleprotocol/sdk'; async function main() { let manager: DistributionCreator; const { deployer } = await ethers.getNamedSigners(); - const managerAddress = (await deployments.get('DistributionCreator')).address; + const chainId = (await deployer.provider?.getNetwork())?.chainId; + console.log('chainId', chainId) + const managerAddress = registry(chainId as unknown as number)?.Merkl?.DistributionCreator // (await deployments.get('DistributionCreator')).address; + + if (!managerAddress) { + throw new Error('Manager address not found'); + } manager = new ethers.Contract( managerAddress, @@ -15,13 +22,20 @@ async function main() { ) as DistributionCreator; console.log('Setting reward token min amount'); - await ( + + const token = { + address: '', + decimals: 0, + minAmount: '0', + } + + const res = await ( await manager .connect(deployer) - .setRewardTokenMinAmounts(['0xa709aaD0691Fc67279577566640ae1D6515c1b81'], [parseEther('0.04')]) + .setRewardTokenMinAmounts([getAddress(token.address)], [parseUnits(token.minAmount, token.decimals)]) ).wait(); - // 18 decimals - // 000000000000000000 + + console.log(res); } main().catch(error => {