Skip to content

Latest commit

 

History

History
186 lines (133 loc) · 3.11 KB

DEVELOPER-GUIDE.md

File metadata and controls

186 lines (133 loc) · 3.11 KB

Developer Guide

Getting Started

Follow these steps to get started with the ParaSpace development 🛠️

Initialize and install deps

yarn
touch .env
make init

Build

make build

Test

make test
make fast-test

Launch Goerli Fork

  1. Download artifacts
wget https://paraspace-static-files.s3.amazonaws.com/contracts/goerli/latest/deployed-contracts.json
  1. Prepare envs
NETWORK=localhost
ALCHEMY_KEY=
DEPLOYER_MNEMONIC=<goerli admin mnemonic>
ETHERSCAN_VERIFICATION=false
MOCHA_JOBS=1
DB_PATH=deployed-contracts.json
FORK=goerli
JSONRPC_VARIANT=hardhat

make shutdown
make hardhat

Upgrade Pools

make reset-pool

Upgrade NTokens

make upgrade-ntoken

Upgrade PToken

make upgrade-ptoken

Upgrade DebtToken

make upgrade-debt-token

Upgrade P2P

make upgrade-p2p-pair-staking

Upgrade Configurator & cAPE & TimeLock

make upgrade-configurator
make upgrade-auto-compound-ape
make upgrade-timelock

Upgrade Existing Fork

Before upgrading, you need to update REVISIONs of Pools, NTokens, PTokens

NETWORK=localhost
ALCHEMY_KEY=
DEPLOYER_MNEMONIC=
ETHERSCAN_VERIFICATION=false
MOCHA_JOBS=1
DB_PATH=deployed-contracts.json # must be the live fork's deployed-contracts.json
RPC_URL=http://localhost:8545 # impersonate to paraspace admin for upgrading
FORK=goerli|mainnet

make upgrade

Upgrade Live Network

Before upgrading, you need to update REVISIONs of Pools, NTokens, PTokens

NETWORK=goerli|mainnet
DEPLOYER_MNEMONIC=
ALCHEMY_KEY=
ETHERSCAN_VERIFICATION=false
MOCHA_JOBS=1
DB_PATH=deployed-contracts.json

make upgrade

Update artifacts

aws s3 cp deployed-contracts.json  s3://paraspace-static-files/contracts/goerli/latest/deployed-contracts.json
aws s3 cp deployed-contracts.json  s3://paraspace-static-files/contracts/goerli/v1.4.6/deployed-contracts.json

Available commands


make help

Tests Instructure

Structure

Use flatten layout

Coding

  1. Use fixtures to manage evm state: We have a pre-built pure evm snapshot call testEnv which contains all used contracts and necessary transactions.

Example 1: You make a story that contains two steps, and steps have to be executed in sequence. You should init the testEnv at the before hook.

describe("A story", () => {
  let testEnv: TestEnv;
  before(async () => {
    testEnv = await loadFixture(testEnvFixture);
  });

  it("Step 01", async () => {});
  it("Step 02", async () => {});
});

Example 2: You wanna do a serial of tests for different paths of a certain scenario. You make changes and wanna reset to that state during following steps.

const fixture = async () => {
  const testEnv = await loadFixture(testEnvFixture);
  testEnv.doSomething();
  return testEnv;
};

describe("A secenrio", () => {
  it("Should succeed", async () => {
    const testEnv = await loadFixture(fixture);
  });

  it("should fail", async () => {
    const testEnv = await loadFixture(fixture);
  });
});

Hint: Happy to see you fix the code smell when you were refacting this file.