@bluejayfinance/contracts
TypeScript icon, indicating that this package has built-in type declarations

0.14.0 • Public • Published

@bluejayfinance/contracts

The repo contains all the smart contracts used for Bluejay Finance.

Testing

hh test

Environment Variables

BLUEJAY_API_KEY - API key of deployed functions API to be used for fetching the latest merkle tree.

ETHERSCAN_API_KEY - API key of Etherscan pro API to be used for fetching list of holders of certain ERC20 tokens.

POAP_API_KEY - API key of POAP to be used for getting information about the POAPs.

PUBLIC_RPC_ENDPOINT - RPC endpoint used by Hardhat when performing operations

Merkle Tree Distributor

To generate the merkle tree for distribution for either PreBluejayToken, WhitelistSalePublic or WhitelistSalePrivate, you will need a balance map. See an example at examples/balance-map.json.

To generate the merkle tree, use the script at scripts/generateMerkleRoot.ts.

To verify the merkle tree, use the script at scripts/verifyMerkleRoot.ts.

External dependencies

Remove from dependencies field in generateNetworks so that hh will deploy the contract for us.

Deployment Validation

To validate that roles and mint/withdrawal limits are set correctly for a deployment, simply run the deployment validation script.

DEBUG=bluejay:* hh validate --network local --deployment-export src/deployments/hardhatDeployment/local.json --multisig-wallet 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --deployer-wallet 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keeper-wallet 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

To validate development deployment:

DEBUG=bluejay:* hh validate --network development --deployment-export src/deployments/hardhatDeployment/development.json --multisig-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE --deployer-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE --keeper-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE

To validate testnet deployment:

DEBUG=bluejay:* hh validate --network testnet --deployment-export src/deployments/hardhatDeployment/testnet.json --multisig-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE --deployer-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE --keeper-wallet 0x410159FB9EA1222b27eb0edA2f4d416Ce5ccdBaE

To validate staging deployment:

DEBUG=bluejay:* hh validate --network staging --deployment-export src/deployments/hardhatDeployment/staging.json --multisig-wallet 0xD6A722e6811Bfc0b2bDbDd4C6124f14Ef2fdbe95 --deployer-wallet 0x09b63C4a7D33853dB70FcB6500117aBFceb50c96 --keeper-wallet 0x3c4DC9F4B6573a9b2Bd5B727cb94436c6f2F6BFB

To test on local machine, you may use the command to deploy to a specific stage:

# For full deployment
npm run deploy:local:override

# For specific stage
npm run deploy:local:override -- --tags BASE

Deploy to a specific stage

If you open anyscripts in the deploy folder, you will find tags at the bottom of the files. For instance:

deploymentScript.tags = ["BluejayToken", "BASE"];

With the help of the tags we can control what we want to deploy on the blockchain. Follow the instructions below to deploy to a specific state:

  • clean the deployment folder: rm -rf ./deployments/local
  • start hardhat node: npx hardhat node --no-deploy
  • deploy to a specific stage: npx hardhat deploy --network local --tags TAGS where TAGS can be
    • BASE
    • PREMINT
    • WHITELIST_SALE
    • BLU_LAUNCH
    • SGD_LAUNCH
    • PSM
    • LENDING_POOL

Export the contracts file

In order to get the file containing the contracts address and ABIs, we can export it from hardhat. For instance, the following command will export all the information into a file called local.json from the local network

npx hardhat export --export local.json --network local

Take note that you will have to delete the files from previous deployment in the folder deployments/<network> and deployments/transactions/<network> to allow the script to re-run from start as presence of those file may cause a contract deployment or transaction to be skipped as we are using deterministic deployment (ie each action will only run once).

Also, take note that for the export command to work, you will need to enable the saveDeployments flag in the config file for the specific network.

Validating Smart Contracts

To validate the smart contract, you will need to use the hardhat-etherscan plugin. You can call the verify task with the network, contract address and deployment arguments.

Example of verifying the ContributorTokenStreamable contract on the development network:

npx hardhat verify --network development 0xc7919AaD1fD977136CEab12e634B8DA3B548Fa7b 0x787f7893474191847c7DDF3a9040509f225Dd820 10000000000000000000000000 true true

Analysis

Get balance of addresses

To get balance of a list of accounts, prepare a list of addresses in a text file, one address per line. The script will export the balance into balances.json

ts-node scripts/analyzeBalances.ts -i <file> -o balances.json

Get list of whitelisted addresses

To get the whitelisted addresses in a list for the first call:

ts-node scripts/fetchWhitelistedAddresses.ts -k <key> -o whitelistedAddresses.txt

Tips & Tricks

To run specific test on watch mode while writing test and code:

nodemon --watch test --watch contracts -e ts,sol --exec "hh test test/ContributorToken.test.ts"

Readme

Keywords

none

Package Sidebar

Install

npm i @bluejayfinance/contracts

Weekly Downloads

1

Version

0.14.0

License

none

Unpacked Size

14.4 MB

Total Files

1445

Last publish

Collaborators

  • tiongshankai97
  • shioju
  • whitefables