XUSD is a new kind of stablecoin that passively accrues yield while you are holding it. If you want to learn about XUSD, visit the docs
^8.11.2 >= node <=^14.0.0
^14.0.0
# Clone the xusd-contracts project
git clone git@github.com:factor-finance/xusd-contracts.git
The xusd-contracts
project houses the smart contracts
codebase. In order to run this project locally, you will need to run both the node
and the dapp
from xusd-dapp in separate processes or terminals.
The smart contracts
and all of their associated code is located in the <project-root>/
directory. Contract tests and local EVM are managed by Hardhat.
A variety of Hardhat tasks are available to interact with the contracts. Additional information can be found by running npx hardhat
You have two options for running the EVM node locally via hardhat.
.env
file)Preferred default development mode is Forked mode. It has a benefit of more closely mimicking behavior of mainnet which is helpful for discovering bugs (that are not evident in local mode) and not requiring setting up complex third party contracts (like Aave and Pangolin).
Open a separate terminal to run the hardhat node in.
# Install the dependencies - Note your Node version 'Requirements'
yarn install
If you would like the forked net to mimic a more recent state of mainnet or fuji update the BLOCK_NUMBER
. And add your mainnet testing account(s) (if more than one comma separate them) under the ACCOUNTS_TO_FUND
. After the node is started up the script will transfer 100k of USDT, XUSD and DAI to those accounts.
# Run the local hardhat node in forked mainnet mode
`FORK=mainnet yarn run_node:fork`
# Run the local hardhat node in forked fuji mode
`FORK=fuji yarn run_node:fork`
# Run the local hardhat node
yarn run_node
# Mint 1000 of each supported stablecoin to each account defined in the mnemonic
FORK=mainnet yarn hardhat fund --amount 1000 --network localhost
Metamask
instructions.You will need a web3 wallet to interact with the dApp and sign transactions. Below are the instructions to setup Metamask
to interact with the dApp running locally.
Metamask
Chrome extension HEREMetamask
walletxusd
- just an examplehttp://localhost:8545
43114
Just use account(s) you normally use on mainnet.
You can get all the accounts for the locally running node and their associate private keys by running the command
# For Standalone mode
npx hardhat accounts --network localhost
Choose a test account past index 3 - accounts 0-3 are reserved. Copy the private key and import it into Metamask as follows:
Metamask
Import Account
=> paste private key => Click Import
Make sure that you select your newly created RPC endpoint in the networks dropdown and use your newly imported account in Metamask
. You should now be setup to use Metamask
to interact with the dApp.
Note:
If you want to add all the accounts via a new Metamask
wallet and import the mnemonic
it is located in contracts/hardhat.config.js
. Make sure that you use Account 4 and up for test accounts as 0-3 are reserved.
When freshly starting a node it is usually necessary to also reset Metamask Account being used:
Metamask
=> Settings
=> Advanced
=> Reset Account
If you get an error Command "husky-run" not found.
type of error:
Go to root of the project and run npx husky install
Smoke tests can be run in 2 modes:
scripts/smokeTest.sh
to launch interactive mode. All the "before contract changes" parts of tests
will execute and wait for the user to manually using a console performs contract changes. Once those are done
hit "Enter" in the smoke test console and the second part of the tests shall be ran that validate that contract
changes haven't broken basic functionality.scripts/smokeTest.sh --deployid [numeric_id_of_deploy]
will run smoke tests against a specific
deployid. Validating that that deploy didn't break basic functionality.