Smart Contracts for Krystal to help interact with protocols on Binance Smart Chain;
We use yarn
as the package manager. You may use npm
and npx
instead, but commands in bash scripts may have to be changed accordingly.
- Clone this repo
yarn install
yarn compile
to compile contracts for all solidity versions.
Create .env
and .env.<chain>.<network>
following the samples in this repo.
.env
includes some common configs, such as PRIVATE_KEY
and the common INFURA_API_KEY
.
Meanwhile, the .env.<chain>.<network>
is the config the particular chain - network .i.e ETHERSCAN_KEY
, MULTISIG
, etc.
.env.sample
PRIVATE_KEY=0x // private key to interact with blockchain
INFURA_API_KEY=xxx
.env.eth.mainnet.sample
ETHERSCAN_KEY=xxx
MAINNET_FORK=https://eth-mainnet.alchemyapi.io // archive chain url, for testing
MAINNET_ID=1 // chain ID
MAINNET_FORK_BLOCK=12644714 // start forking from this block for testing
MULTISIG=0x // multisig address if have, only gnosis-safe[https://gnosis-safe.io/] is supported
- If contracts have not been compiled, run
yarn compile
oryarn c
. This step can be skipped subsequently. - Run
yarn test -h
for instruction
yarn <deploy,test> [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network
where:
-h show this help text
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,testnet,ropsten,mumbai>
-f specific test to run if any
- Run
yarn deploy -h
for instruction
yarn <deploy,test> [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network
where:
-h show this help text
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,testnet,ropsten,mumbai>
-f specific test to run if any
yarn test
(Runs all tests)yarn test -f ./test/swap.test.ts
(Test only swap.test.ts)
- Run
yarn coverage
for coverage on files