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

@pier-wallet/contracts

v0.24.0

Published

pier wallet smart wallet and integration contracts

Downloads

13

Readme

Contracts

Project setup

  1. Copy .env.sample to .env and fill in all the required variables. You will get an error if you don't specify all required env variables.
  2. Run yarn to install dependencies
  3. Run yarn dev:build to setup the project.

Serve local blockchain with deployed contracts

Starts a fork of harmony mainnet on http://localhost:8545 and deploys all contracts. The addresses of smart contracts should not change, unless the deploy scripts are changed.

yarn dev:serve

Running tests

yarn test:unit

If in doubt - run yarn dev:typechain

Deployment

Deploy: Available networks:

  • localhost

  • harmonytestnet

  • polygontestnet

  • bsctestnet

  • fantomtestnet

  • harmonymainnet

  • polygonmainnet

  • bscmainnet

  • fantommainnet

yarn deploy:wallet-factory --network [network] --gasprice [gas price in wei]
yarn deploy:v3 --network [network] --gasprice [gas price in wei]
yarn deploy:periphery --network [network] --gasprice [gas price in wei]
yarn deploy:products --network [network] --gasprice [gas price in wei]

Post Deploy

Build NPM Package

for testnet: preid= alpha

npm version patch/minor/major [prerelease --preid=...]

To verify on explorer

yarn hardhat verify --network harmonymainnet [contract address]

Close PR!

Wallet Upgrade

  • Put all upgrades of the wallet into /contracts/wallets/ folder with naming convention SmartWallet[VERSION]
  • Inherit the latest version in the new Wallet:
contract SmartWallet[NEW_VERSION] is SmartWallet[PREVIOUS_VERSION] {...}

IF

  • you need to DECLARE new variables - declare them
  • you need to INITIALIZE new variables - add function to initialize and call on upgrade [WORKAROUND / TO BE FIXED WITH WALLET_FACTORY UPGRADE]
  • you need to DECLARE new functions - declare them

In any case

  • SET the new version function:
function version() external pure override returns (uint256) {
   return [NEW_VERSION]
}
  • CREATE deployment script for NEW_VERSION in /deploy with naming convention [+increment]_deploy_v[NEW_VERSION].ts
  • UPDATE in new deployment script the deploy.tags to [NEW_VERSION] (e.g. "v2")
  • UPDATE package.json script to
deploy:v[NEW_VERSION]: ".... --tags v[NEW_VERSION]"
  • CREATE new Entry in test/otpWallet.test.ts [TODO: TO BE FIXED / NOT YET WORKING]
const SMART_WALLET_CONTRACTS_MAP = [
  ...PREVIOUS_VERSIONS,
  {
    name: SmartWallet[NEW_VERSION],
    version: [NEW_VERSION],
  },
] as const;

Wallet Factory Upgrade

Product Reference Data

do this on etherscan / polygonscan / etc

Calculate percentages, then on ..scan, add. Example:

[
  ["0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", 500000000000],
  ["0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", 200000000000],
  ["0x7DfF46370e9eA5f0Bad3C4E29711aD50062EA7A4", 100000000000],
  ["0xeCDCB5B88F8e3C15f95c720C51c71c9E2080525d", 150000000000],
  ["0xB85517b87BF64942adf3A0B9E4c71E4Bc5Caa4e5", 50000000000]
]

OR

[
  {
    "token": "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
    "percentage": 500000000000
  },
  {
    "token": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "percentage": 200000000000
  },
  {
    "token": "0x7DfF46370e9eA5f0Bad3C4E29711aD50062EA7A4",
    "percentage": 100000000000
  },
  {
    "token": "0xeCDCB5B88F8e3C15f95c720C51c71c9E2080525d",
    "percentage": 150000000000
  },
  {
    "token": "0xB85517b87BF64942adf3A0B9E4c71E4Bc5Caa4e5",
    "percentage": 50000000000
  }
]

To set the Management fee (e.g. 2% per annum):

  1. Calculate hourly management Fee using wolfram alpha

    (1-x)^(24*365) = (1-0.02)
    Where 0.02 is the annual mgmt fee and x is the hourly mgmt fee
    
    https://www.wolframalpha.com/input?i=%281-x%29%5E%2824*365%29+%3D+%281-0.02%29
  2. Evaluate expression (e.g. 2% per year --> 2.30624246818947 10^-6)

    2.30624246818947*10^-6 => 0.000002306242468
  3. Set the management fee

    yarn hardhat --network polygontestnet product:set-product-reference-data-fees --product-name SimpleIndexProduct --management-fee-per-hour 0.000002306242468 --gasprice 5000000000

Guidelines

  • Do not deploy to testnet or mainnet from branch
  • Bump the version in package.json before PR close
  • At closing PR (ideally scipted via actions)
    • install with yarn --fixed lock
    • Run all tests [yarn dev:test]
    • Deploy to testnet [yarn migrate:testnet]
    • Add latest JSON to code!!!
  • After merging / PR
    • Publish new release via github
    • Update release version in lib
    • Run all the tests in lib
    • IF SUCCESSFUL IN LIB, update release verion on relayer
    • IF SUCCESSFUL IN LIB, deploy to mainnet
    • IF SUCCESSFUL IN LIB, Migrate over funds from old walletFactory address