-
Notifications
You must be signed in to change notification settings - Fork 0
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
added a script for computing contract addresses #48
Changes from 8 commits
8fea83f
1136b7b
5dd1d0a
853fc84
986c650
9a94716
8ee8fde
119ebdb
8649c1d
91176b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@forge-std/src/Script.sol"; | ||
import "@forge-std/src/console.sol"; | ||
import "@comet-contracts/marketupdates/MarketUpdateTimelock.sol"; | ||
import "@comet-contracts/marketupdates/MarketUpdateProposer.sol"; | ||
import "@comet-contracts/Configurator.sol"; | ||
import "@comet-contracts/CometProxyAdmin.sol"; | ||
import "@comet-contracts/marketupdates/MarketAdminPermissionChecker.sol"; | ||
import "@comet-contracts/Create2DeployerInterface.sol"; | ||
import "./helpers/MarketUpdateAddresses.sol"; | ||
import "./helpers/MarketUpdateContractsDeployer.sol"; | ||
import "./helpers/ChainAddresses.sol"; | ||
|
||
contract ComputeContractAddresses is Script { | ||
address public deployedWalletAddress; | ||
|
||
address constant public create2DeployerAddress = 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2; | ||
address constant public ZER0_ADDRESS_MARKET_UPDATE_PROPOSAL_GUARDIAN = address(0); | ||
address constant public ZER0_ADDRESS_MARKET_ADMIN_PAUSE_GUARDIAN = address(0); | ||
address constant public INITIAL_ADDRESS_MARKET_UPDATE_MULTI_SIG = address(0x7e14050080306cd36b47DE61ce604b3a1EC70c4e); | ||
|
||
|
||
function run() external { | ||
uint256 passedChainId = vm.envUint("CHAIN_ID"); | ||
|
||
require(block.chainid == passedChainId, "Chain ID mismatch"); | ||
Check notice Code scanning / Semgrep OSS Semgrep Finding: rules.solidity.performance.use-custom-error-not-require Note
Consider using custom errors as they are more gas efficient while allowing developers
to describe the error in detail using NatSpec. |
||
|
||
ChainAddresses.Chain chain = ChainAddresses.getChainBasedOnChainId(passedChainId); | ||
ChainAddresses.ChainAddressesStruct memory chainAddresses = ChainAddresses.getChainAddresses(chain); | ||
|
||
console.log("Deploying contracts with sender: ", msg.sender); | ||
|
||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
address deployer = vm.rememberKey(deployerPrivateKey); | ||
vm.startBroadcast(deployer); | ||
|
||
console.log("Broadcasting transaction with deployer: ", deployer); | ||
|
||
bytes32 salt = keccak256(abi.encodePacked(vm.envString("SALT"))); | ||
|
||
/// Call library function | ||
MarketUpdateContractsDeployer.DeployedContracts memory deployedContracts = MarketUpdateContractsDeployer._prepareAndDeployContracts( | ||
salt, | ||
msg.sender, | ||
chainAddresses.marketAdmin, | ||
chainAddresses.marketUpdatePauseGuardian, | ||
chainAddresses.marketUpdateProposalGuardian, | ||
chainAddresses.governorTimelockAddress, | ||
false // deploy flag set to false | ||
); | ||
|
||
/// Console log deployed contracts | ||
console.log("MarketUpdateTimelock: ", deployedContracts.marketUpdateTimelock); | ||
console.log("MarketUpdateProposer: ", deployedContracts.marketUpdateProposer); | ||
console.log("NewConfiguratorImplementation: ", deployedContracts.newConfiguratorImplementation); | ||
console.log("NewCometProxyAdmin: ", deployedContracts.newCometProxyAdmin); | ||
console.log("MarketAdminPermissionChecker: ", deployedContracts.marketAdminPermissionChecker); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ interface SourceTokenParameters { | |
asset: string; | ||
address: string; | ||
blacklist: string[]; | ||
blockNumber?: number; | ||
} | ||
|
||
export async function fetchQuery( | ||
|
@@ -55,14 +56,20 @@ export async function sourceTokens({ | |
asset, | ||
address, | ||
blacklist, | ||
blockNumber, | ||
}: SourceTokenParameters) { | ||
let amount = BigNumber.from(amount_); | ||
if (amount.isZero()) { | ||
return; | ||
} else if (amount.isNegative()) { | ||
await removeTokens(dm, amount.abs(), asset, address); | ||
} else { | ||
await addTokens(dm, amount, asset, address, [address].concat(blacklist)); | ||
if(blockNumber) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove extra if statement |
||
await addTokens(dm, amount, asset, address, [address].concat(blacklist), blockNumber); | ||
} else { | ||
await addTokens(dm, amount, asset, address, [address].concat(blacklist)); | ||
} | ||
|
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,7 +260,12 @@ async function testScalingReward(properties: CometProperties, context: CometCont | |
[albert.address] | ||
); | ||
await newRewards.connect(albert.signer).setRewardConfigWithMultiplier(comet.address, rewardTokenAddress, multiplier); | ||
await context.sourceTokens(exp(1_000, rewardDecimals), rewardTokenAddress, newRewards.address); | ||
await context.sourceTokens( | ||
100000, | ||
rewardTokenAddress, | ||
newRewards.address, | ||
2751700 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment for these values. Why these values? |
||
); | ||
|
||
await baseAsset.approve(albert, comet.address); | ||
await albert.safeSupplyAsset({ asset: baseAssetAddress, amount: 100n * baseScale }); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ export class ProposalConstraint<T extends CometContext> implements StaticConstra | |
} | ||
|
||
// temporary hack to skip proposal 329 | ||
if (proposal.id.eq(329)) { | ||
if (proposal.id.eq(349) || proposal.id.eq(350)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove these |
||
console.log('Skipping proposal 329'); | ||
continue; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,7 +254,7 @@ export class CometContext { | |
throw new Error(`Unable to find asset by address ${address}`); | ||
} | ||
|
||
async sourceTokens(amount: number | bigint, asset: CometAsset | string, recipient: AddressLike) { | ||
async sourceTokens(amount: number | bigint, asset: CometAsset | string, recipient: AddressLike, blockNumber?: number) { | ||
const { world } = this; | ||
const recipientAddress = resolveAddress(recipient); | ||
const cometAsset = typeof asset === 'string' ? this.getAssetByAddress(asset) : asset; | ||
|
@@ -281,13 +281,24 @@ export class CometContext { | |
if (amountRemaining != 0n) { | ||
// Source from logs (expensive, in terms of node API limits) | ||
debug('Source Tokens: sourcing from logs...', amountRemaining, cometAsset.address); | ||
await sourceTokens({ | ||
dm: this.world.deploymentManager, | ||
amount: amountRemaining, | ||
asset: cometAsset.address, | ||
address: recipientAddress, | ||
blacklist: [comet.address], | ||
}); | ||
if (blockNumber) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra if statement can be removed |
||
await sourceTokens({ | ||
dm: this.world.deploymentManager, | ||
amount: amountRemaining, | ||
asset: cometAsset.address, | ||
address: recipientAddress, | ||
blacklist: [comet.address], | ||
blockNumber, | ||
}); | ||
} else { | ||
await sourceTokens({ | ||
dm: this.world.deploymentManager, | ||
amount: amountRemaining, | ||
asset: cometAsset.address, | ||
address: recipientAddress, | ||
blacklist: [comet.address], | ||
}); | ||
} | ||
} | ||
} | ||
|
||
|
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: compound.solidity.constant-not-in-uppercase Note