Welcome to Magnify Cash V1! This repository serves as the central hub for various subprojects that collectively constitute the Magnify Cash protocol. If you wish to learn more about the contracts, protocol design, and other related aspects, please navigate to the /contracts
directory.
This monorepo utilizes yarn workspaces to manage dependencies across subprojects seamlessly. To get started, simply run yarn install
from the root directory, and it will automatically handle all the dependencies for the subprojects.
Currently, the monorepo comprises the following four subprojects:
-
contracts: This section contains the smart contracts that form the backbone of the Magnify Cash protocol. For in-depth details, please refer to the
/contracts
directory. -
subgraph: Here, you can find the code responsible for managing the subgraph of the Magnify Cash protocol. (You may include additional context or purpose of the subgraph here.)
-
faucet: The faucet subproject deals with setting up and managing the faucet service. (Feel free to elaborate further on the functionality of the faucet if needed.)
-
dapp: The dapp subproject encompasses the decentralized application (dApp) for Magnify Cash. (Provide more information on the features and functionalities of the dApp as necessary.)
To begin local development, carefully follow the steps outlined below:
-
Install Docker v4.10.1 from here.
-
Clone the graph-node repository into a shared parent directory with the current repository. Both repositories should be located in the same parent folder.
-
Build graph-node images locally by following these steps. Note: Before proceeding, you must increase Docker's memory allowance to 8GB from Preferences → Resources. After completion, you can revert it to the default 4GB.
-
Begin by running
yarn install
to install all the necessary dependencies. -
Execute
yarn contracts start
to bring up the local hardhat chain. -
Start the local graph stack with
yarn graph-node
. Please wait until the logs indicateDownloading latest blocks from Ethereum, this may take a few minutes...
. -
Deploy a fresh version of all contracts and the subgraph by running
yarn deploy:local
.
The environment is now ready for development. You can launch the faucet service using yarn faucet start
and/or start the dApp with yarn dapp-v1 start
.
- Make sure you have a valid
PRIVATE_KEY
with testnet ETH in your.env
. - Run
graph auth --product hosted-service <SUBGRAPH_ACCESS_TOKEN>
.
- Run
yarn contracts deploy:<network>
. - Change the addresses and block numbers in
subgraph/subgraph.yaml
anddapp-v1/wagmi.config.ts
as needed by copying them from the newdeployments.json
. Also, forsubgraph/networks.json
, copy the values from "mainnet" into the desired network. - Run
yarn subgraph deploy:<network>
. - Make sure
yarn dapp build
is working locally with the production.env
s, and without the local graph node running. - Push changes to
staging
branch for them to be deployed.
Note: After deploying a new version of the subgraph, you must wait for the graph-node to sync the latest blocks before you can run the dapp. This usually takes 10-15 minutes.
If you just want to deploy the subgraph and dapp and not the contracts, you can do the following:
- Make sure the addresses and block numbers are correct in
subgraph/subgraph.yaml
anddapp-v1/wagmi.config.ts
. - Do step 3 to 5 from above.
Notes:
-
When you make changes to the contracts, always run
yarn deploy:local
to deploy the updated contracts and subgraph. -
If you close the hardhat chain process, ensure to restart the
graph-node
script as well. -
For the scripts to work correctly, ensure that both this repo and the graph-node repo are present in the same parent directory.
- Ensure you have
.env
andcontracts/.env
filled out. This includes the following variables:.env
INFURA_API_KEY
PRIVATE_KEY
contracts/.env
SOLC_VERSION
DAPP_SRC
REPORT_GAS
CMC_KEY
PLATFORM_WALLET
OBLIGATION_URI
KEYS_URI
LOF
CONTRACT_OWNER
MAINNET_URL
ETHERSCAN_API_KEY
- Run
yarn contracts deploy:<network>
. - Change the addresses and block numbers in
dapp-v1/wagmi.config.ts
as needed by copying them from the newdeployments.json
. - Make sure
yarn dapp build
is working locally. - Push changes to
staging
branch for them to be deployed.
- add new network in contracts/hardhat.config.ts
- add new
deploy:<network>
command incontracts/package.json
- add deployed contract address in
dapp-v1/wagmi.config.ts
- add new chain in
dapp-v1/src/wagmi.ts
- update protocol defaults in
dapp-v1/src/helpers/protocolDefaults
- update alchemy networks in
dapp-v1/src/helpers/utils.ts
- add new
deploy:<network>
command insubgraph/package.json
To run all smart contract tests, execute yarn contracts test
.