Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mumbai upgrade deployment 3-14-24 #739

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,079 changes: 1,059 additions & 20 deletions .openzeppelin/polygon-mumbai.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* @notice Deprecated. Previously the address of the RestrictedNORI contract.
* This storage gap remains to maintain the storage layout of the contract.
*/
address private _storageGap;
address private _restrictedNORI;

Check warning

Code scanning / Slither

Unused state variable Warning

Market._restrictedNORI is never used in Market

Check warning

Code scanning / Slither

State variables that could be declared constant Warning

Market._restrictedNORI should be constant

/**
* @notice The number of base tokens required to purchase one NRT.
Expand Down
8 changes: 4 additions & 4 deletions contracts/Removal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@
ICertificate private _certificate;

/**
* @dev Maps from a removal ID to the project ID it belongs to.
* @dev Deprecated. This storage gap remains to maintain the storage layout of the contract.
*/
mapping(uint256 => uint256) private _removalIdToProjectId;
mapping(uint256 => uint8) private _projectIdToHoldbackPercentage;

Check warning

Code scanning / Slither

Unused state variable Warning


/**
* @dev Deprecated. This storage gap remains to maintain the storage layout of the contract.
* @dev Maps from a removal ID to the project ID it belongs to.
*/
mapping(uint256 => uint8) private _storageGap;
mapping(uint256 => uint256) private _removalIdToProjectId;

/**
* @notice Maps from an address to an EnumerableSet of the token IDs for which that address has a non-zero balance.
Expand Down
66 changes: 45 additions & 21 deletions deploy/configure-assets-after-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
getRemoval,
} from '@/utils/contracts';

interface NetworkMarketConfig {
priceMultiple: number;
feePercentage: number;
purchaseTokenAddress: string;
feeWalletAddress: string;
}

export const deploy: DeployFunction = async (environment) => {
const hre = environment as unknown as CustomHardHatRuntimeEnvironment;
const CONFIRMATIONS =
Expand All @@ -39,30 +46,48 @@
// );

const [signer] = await hre.getSigners();
const market = await getMarket({ hre, signer });

Check warning on line 49 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value
const certificate = await getCertificate({ hre, signer });

Check warning on line 50 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value
const removal = await getRemoval({ hre, signer });

Check warning on line 51 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value
const bpNori = await getBridgedPolygonNori({ hre, signer });

Check warning on line 52 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value

const networkMarketConfig: Record<string, NetworkMarketConfig> = {
polygon: {
priceMultiple: 2000,
feePercentage: 25,
purchaseTokenAddress: PROD_USDC_TOKEN_ADDRESS,
feeWalletAddress: PROD_NORI_FEE_WALLET_ADDRESS,
},
mumbai: {
priceMultiple: 2000,
feePercentage: 25,
purchaseTokenAddress: STAGING_USDC_TOKEN_ADDRESS,
feeWalletAddress: STAGING_NORI_FEE_WALLET_ADDRESS,
},
localhost: {
priceMultiple: 100,
feePercentage: 25,
purchaseTokenAddress: bpNori.address,

Check warning on line 70 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value

Check warning on line 70 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe member access .address on an `any` value
feeWalletAddress: hre?.namedAccounts?.noriWallet,
},
hardhat: {
priceMultiple: 100,
feePercentage: 25,
purchaseTokenAddress: bpNori.address,

Check warning on line 76 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe assignment of an `any` value

Check warning on line 76 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe member access .address on an `any` value
feeWalletAddress: hre?.namedAccounts?.noriWallet,
},
};

// SW: Leaving the default local configuration as bridged polygon NORI
// for the purchase token to minimize test breakage.
let purchaseTokenAddress = bpNori.address;
let priceMultiple = BigNumber.from(100);
if (hre.network.name === 'polygon') {
purchaseTokenAddress = PROD_USDC_TOKEN_ADDRESS;
priceMultiple = BigNumber.from(2000);
} else if (hre.network.name === 'mumbai') {
purchaseTokenAddress = STAGING_USDC_TOKEN_ADDRESS;
priceMultiple = BigNumber.from(2000);
}
const restrictionScheduleDuration = 315_569_520; // seconds in 10 years
const feeWalletAddress = ['hardhat', 'localhost'].includes(hre.network.name)
? hre.namedAccounts.noriWallet
: hre.network.name === 'polygon'
? PROD_NORI_FEE_WALLET_ADDRESS
: STAGING_NORI_FEE_WALLET_ADDRESS;
const purchaseTokenAddress =
networkMarketConfig[hre.network.name].purchaseTokenAddress;
const priceMultiple = networkMarketConfig[hre.network.name].priceMultiple;
const feePercentage = networkMarketConfig[hre.network.name].feePercentage;
const feeWalletAddress =
networkMarketConfig[hre.network.name].feeWalletAddress;
let txn: ContractTransaction;
if ((await certificate.getRemovalAddress()) !== removal.address) {

Check warning on line 90 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe member access .getRemovalAddress on an `any` value

Check warning on line 90 in deploy/configure-assets-after-deployment.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe call of an `any` typed value
hre.trace('Setting removal address in Certificate contract...');
txn = await certificate.registerContractAddresses(removal.address);
await txn.wait(CONFIRMATIONS);
Expand All @@ -85,7 +110,7 @@

if (
(await market.getPurchasingTokenAddress()) !== purchaseTokenAddress ||
(await market.getPriceMultiple()) !== priceMultiple
(await market.getPriceMultiple()) !== BigNumber.from(priceMultiple)
) {
txn = await market.setPurchasingTokenAndPriceMultiple(
purchaseTokenAddress,
Expand All @@ -98,11 +123,10 @@
} as purchase token with price multiple of ${priceMultiple}`
);
}
// TODO: Configure the purchasing token and fee percentage somewhere more global
if ((await market.getNoriFeePercentage()) !== BigNumber.from(25)) {
txn = await market.setNoriFeePercentage(25);
if ((await market.getNoriFeePercentage()) !== BigNumber.from(feePercentage)) {
txn = await market.setNoriFeePercentage(feePercentage);
await txn.wait(CONFIRMATIONS);
hre.trace('Set fee percentage to 25');
hre.trace(`Set fee percentage to ${feePercentage}`);
}

if ((await market.getNoriFeeWallet()) !== feeWalletAddress) {
Expand All @@ -115,7 +139,7 @@
export default deploy;
deploy.tags = ['configure'];
// TODO is there a way to remove this 'Market' dependency?
deploy.dependencies = ['Market'];
deploy.dependencies = ['Market', 'Removal', 'market'];
deploy.skip = async (hre) =>
Promise.resolve(
!['polygon', 'mumbai', 'localhost', 'hardhat'].includes(hre.network.name)
Expand Down
6 changes: 3 additions & 3 deletions deployments/mumbai/BridgedPolygonNORI.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions deployments/mumbai/Certificate.json

Large diffs are not rendered by default.

96 changes: 8 additions & 88 deletions deployments/mumbai/Market.json

Large diffs are not rendered by default.

204 changes: 96 additions & 108 deletions deployments/mumbai/Removal.json

Large diffs are not rendered by default.

Loading