npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

contract-deployments

v0.3.6

Published

Tool for deploying and upgrading:

Downloads

9

Readme

contract-deployments

Tool for deploying and upgrading:

  • price feeds
  • price feeds adapters

Initial setup

Create an .env file with PRIVATE_KEY=0x123.... line

If first deployment on new blockchain

  • check if network is supported by https://app.safe.global (for example celo: https://app.safe.global/welcome?chain=celo) if true then create safe instance using UI

If is not supported by https://app.safe.global

  • if safe factory contracts doesn't exists then you have to first deploy factories - https://wiki.redstone.vip/docs/guidelines/gnosis-safe (then safe instance next step)
  • if factories already exists you have to create safe instance with npx hardhat create-gnosis-safe (add it to custom-safes.json)
    • check Upgrades without defender section for more details

Deployment

  1. Create new deployment config json in deployments dir. (example deployments/example.json)
    1. Deployment name should contain name of the network used for deployment like voltzEthGoerli (to distinguish contracts deployed between different networks)
    2. For networks listed here: https://docs.gelato.network/developer-services/automate/supported-networks add gelatoUpdaterAddress: 0xc4D1AE5E796E6d7561cdc8335F85e6B57a36e097
  2. Run hardhat task to generate and deploy contracts npx hardhat --network avalanche-fuji deploy-all --name example
  3. Test if deployed contracts can be updated. Using local fork usage: FORK="https://canto.slingshot.finance" npx hardhat verify-upgradability-on-fork --name cadenceCantoEth
  • All contracts were deployed behind proxies.
  • All contracts share common ProxyAdmin contract which has common owner
  • There exist a common owner per network, so reuse the existing one if they exist.

Testing before upgrades

  • scripts/upgrade-tests/common contains common function which can be helpful for testing upgrades
  • example testing swell upgrade from V2 to V3 is in file scripts/upgrade-tests/example-with-round-adapter.ts
  • each time you want to add new test you should write file like this yourself, this is very dependent on upgrade which will be done
  • To run such a test: FORK="https://eth-mainnet.public.blastapi.io" npx hardhat --network hardhat run scripts/upgrade-tests/example-with-rounds-adapter.ts
    • Where FORK is rpc-url of the network which you want to fork. It is forking with latest blockNumber
    • rpc-url has to support archival data

Upgrades

  1. Prepare new contract
  2. Propose upgrade using task propose-upgrade (example npx hardhat propose-upgrade --network avalanche-fuji --name example --initial-contract-name PriceFeedsAdapterVoltzArb --new-contract-name PriceFeedsAdapterVoltzArbProd)
  3. Send generated URL to owners of multisig

Note: In --no-defender You can also upgrade to concrete impl address instead of deploying new contract. This can be particularly useful, when you want rollback to previous implementation. To do that, we need to pass --new-contract-address followed by impl address instead of --new-contract-name. IMPORTANT: be aware that this option doesn't verify if new implementation is safe to upgrade, by verifying source code compatibility.

Verify Single Contract

  1. To verify single contract just run: npx hardhat verify --network mainnet DEPLOYED_CONTRACT_ADDRESS
    1. DEPLOYED_CONTRACT_ADDRESS should not be proxy contract address

Verify sources

  1. Every time you deploy new contract or update existing you should verify sources npx hardhat verify-sources --network avalanche --name example

Verify manually (if script doesnt work)

We cannot use hardhat commnad, we have to do this manually

  1. Go to https://sourcify.dev/
  2. Click verify contract and choose "Import from Solidity JSON"
  3. Select solidity version from "hardhat.config.ts" (currently "0.8.17")
  4. Upload JSON file from "artifacts/build-info"
  5. On the right section on the screen select contract which require verification f.g. MentoAdapterBaklavaV2
  6. Populate address with IMPLEMENTATION CONTRACT ADDRESS, not proxy contract address and choose proper chain
  7. Now verify proxy contract by selecting "Import from Etherscan" on https://sourcify.dev/
  8. Provide address one of already deployed proxy contracts f.g. "0x68ba9602B2AeE30847412109D2eE89063bf08Ec2" on ethereum mainnet
  9. Select "TransparentUpgradeableProxy" on the righ section
  10. Provide address of the REDSTONE ADAPTER and select proper chain
  11. Adapter contract behind proxy should be verified

Upgrades without defender

  1. npx hardhat create-gnosis-safe --signers 0x3d62C20583AefDAe7959bad67D457e6D24d7A656, 0x2d62C20583AefDAe7959bad67D457e6D24d7A656 --threshold 1 --network mantle
    • If we get an error about missing info about safe first do this instructions: https://wiki.redstone.vip/docs/guidelines/gnosis-safe
    • use outcome safe address as proxyAdminOwner in deployment manifests
  2. npx hardhat propose-upgrade --network mantle --name mantleMnt --initial-contract-name PriceFeedsAdapterMantleMnt --new-contract-name PriceFeedsAdapterMantleMntV2 --no-defender
    • The file with upgrade transaction will be created. Owners of the multi sig has to approve it as in the next step.
  3. LEDGER=2 npx hardhat gnosis-safe-approve --file <<file_name_from_step_2_without_dir_name>> --network mantle
    • It is possible to use ledger in this scenario by default using BIP44 derivation path. To use ledger device set LEDGER to index of your ledger account in metamask - 44'/60'/0'/0/${process.env.LEDGER}
    • If enough people approved. You can approve and execute as single transaction.
  4. LEDGER=2 npx hardhat gnosis-safe-approve --file <<file_name_from_step_2_without_dir_name>> --network mantle --execute
    • IMPORTANT: even if transaction finished successfully internal transaction could have failed. Check to be sure in block explorer.

Adding new data feeds to existing adapter

  1. Update adapter contract, especially getDataFeedIds and getDataFeedIndex functions to support new data feeds
  2. Create and deploy new data feeds contracts npx hardhat deploy-price-feeds-contracts --network ethereum-goerli --name example --adapter 0x3B025A4E7d442c5CAF9F25Fb9d5A66c23d07C076, where --name is the name from deployments dir (example deployments/example.json) and --adapter is the address of already deployed adapter contract
  3. Verify new data feeds contracts