npm i --force
forge testWe need to be able to mint USDLR on Edgeless with USDC on any chain. The user deposit flow is as follows:
On Base
- User onboards USDC via ZKP2P
- User receives USDC in a 4337 wallet
- 4337 wallet approves USDC to BaseReceiver
- 4337 wallet calls BaseReceiver.forward()
- BaseReceiver first receives USDC, then sends it to Stable.
- BaseReceiver emits Forward(...) event
- Off-chain, Stable listens for Forward and records the address and amount
On Edgeless
- Stable's minter wallet mints amount to itself
- Stable's minter wallet approves EdgelessMinter to spend amount
- Stable's minter wallet calls EdgelessMinter.mint(to, amount) where metadata is from the Forward event
- EdgelessMinter transfers USDLR from Stable's minter wallet to EdgelessMinter
- EdgelessMinter sends USDLR from itself to the address
On Edgeless:
- User approves usdlr to EdgelessReceiver
- User calls EdgelessReceiver.forward()
- EdgelessReceiver receives USDLR, then sends it to Stable.
- EdgelessReceiver emits Forward(...) event
- Off-chain, Stable listens for Forward and records the address and amount
On Ethereum:
- Stable's USDC custodian wallet approves EthereumMinter to spend amount
- Stable's USDC custodian wallet calls EthereumMinter.mint(to, amount) where to and amount are from the Forward event.
- EthereumMinter transfers USDC from Stable's USDC custodian wallet to EthereumMinter
- EthereumMinter sends USDC from itself to
to
The following invariants should always be maintained within the contract:
- The amount of USDC received MUST EQUAL the amount of USDC sent in a single contract interaction
- The amount of USDLR received MUST EQUAL the amount of USDC sent in a single contract interaction
- The BaseReceiver and EdgelessMinter contracts SHOULD NOT HAVE ANY USDC or USDLR between transactions
This is a list of the most frequently needed commands.
Compile the contracts:
$ forge buildRun the tests:
$ forge test- Create a
.envfile according to.env.example - Modify the
namedAccountsinhardhat.config.ts - Deploy to baseSepolia
npx hardhat deploy --network baseSepolia - Deploy to edgelessSepoliaTestnet
npx hardhat deploy --network edgelessSepoliaTestnet