A simple web application for interacting with ERC-4626 vault contracts on Ethereum mainnet in order to integrate with Valence cross-chain vaults. Built with Next.js, Tailwind CSS, and wagmi. Uses Foundry/Anvil for local Ethereum development.
You will need an EVM endpoint with a deployed vault contract. For now, easiest way to deploy the vault used here is with the valence-protocol
repository.
-
Prerequisities Install rust, docker, foundry
-
Clone the deployment script
git clone https://github.com/timewave-computer/valence-protocol
- Compile solidity contracts
We only are interested in
OneWayVault.sol
, but the repo is set up in a way where everything will compile for the time being
git checkout keyne/one-way-vault-deployment
cd valence-protocol/solidity
forge soldeer install && forge build
- Compile & run the deploy script
Same as above, this is couple to the rest of the repo for the time being, so there will be alot to compile. It will take a few minutes.
This script starts an anvil instance, and deploys
OneWayVault.sol
and a mock ERC20
## from valence-protocol/ (cd ..)
cargo run --package valence-e2e --example one_way_vault
- Get environment variables Once the script finished, you should have
- rpc endpoint running on
http://localhost:8545
- vault address
- erc20 address
- Fund EVM address
# sets your account balance to 10000 ETH
cast rpc anvil_setBalance <EVM_ADDRESS> 0x56BC75E2D63100000 \
--rpc-url "http://localhost:8545"
# set ERC20 balance
# the private key is derived from the neumonic commited in the deploy script
cast send \
--rpc-url "http://localhost:8545" \
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
<ERC20_ADDRESS> \
"mint(address,uint256)(address,uint256)" \
<EVM_ADDRESS> \
100000000000
- Set up environment variables.
Please also verify the anvil endpoint from the step above.
cp .env.example .env
- Customize configuration files.
vaults.config.json
: add the vault address and ERC20 address. More docs on this file belowwagmi.config.ts
: specifies which EVM chains + RPCs are used when connecting a walletgraz.config.ts
: specifies which cosmos chains + RPCs are used when connecting a wallet
- start server
npm install
npm run start
- Add testnet to your browser wallet as a custom network:
- Network Name: Vaults Test Env (or any name)
- RPC URL: http://localhost:8545 (or any anvil rpc)
- Chain ID: 31337
- Currency Symbol: ETH
Linting should run on commit, but you can also run the below:
git add .
npm exec lint-staged
To build:
npm run build
Deploy with your preferred method to host NextJS apps. Vercel is the easiest.
The vaults.config.json
file contains an array of vault configurations. Each vault object has the following fields:
vaultId
: A unique identifier for the vault used internally by the applicationsymbol
: The symbol of the token accepted by the vault (e.g., "USDC", "ETH")
evm
: Configuration for the Ethereum side of the vaultchainId
: The ID of the blockchain network where the vault is deployed (e.g., 1 for Ethereum mainnet)vaultAddress
: The Ethereum proxy address of the vault contracttokenAddress
: The address of the ERC-20 token that the vault accepts as depositstransactionConfirmationTimeout
: Maximum time (in milliseconds) to wait for transaction confirmationsstartBlock
: The block number from which to start scanning for vault eventsexplorerUrl
: URL for the blockchain explorer (e.g., "https://etherscan.io")
cosmos
: Configuration for the Cosmos side of the vaultchainId
: The ID of the Cosmos chain (e.g., "neutron-1")explorerUrl
: URL for the Cosmos chain explorertoken
: Token configurationdenom
: The denomination of the token on the Cosmos chaindecimals
: Number of decimal places for the token
startBlock
: The block number from which to start scanning for vault events
copy
: Text content for the UIname
: Human-readable name of the vaultdescription
: A brief description of the vault's purposedeposit
: Deposit-related texttitle
: Title for the deposit sectiondescription
: Description of the deposit processcta
: Call-to-action text for deposit button
depositInProgress
: Text for deposit in progress statetitle
: Title for the progress sectionsteps
: Array of step descriptionsdescription
: Description of the ongoing process
withdraw
: Withdrawal-related texttitle
: Title for the withdrawal sectiondescription
: Description of the withdrawal processcta
: Call-to-action text for withdrawal button
withdrawInProgress
: Text for withdrawal in progress statetitle
: Title for the progress sectionsteps
: Array of step descriptionsdescription
: Description of the ongoing process
withdrawCompleted
: Text for completed withdrawal statetitle
: Title for the completion sectiondescription
: Description of the completed process
aprRequest
: Configuration for fetching the vault's APR (Annual Percentage Rate)type
: The source type for APR data ("api" or "contract")- For API requests:
url
: The endpoint URLmethod
: HTTP method (GET, POST, etc.)headers
: Optional HTTP headersbody
: Optional request body
- For contract requests:
address
: The contract addressabi
: Contract ABI arrayfunctionName
: Name of the function to callargs
: Optional arguments for the function call