feat(nextjs-defi-lending-moonwell): Moonwell USDC lending recipe (Base) - #73
Open
bprofiro wants to merge 1 commit into
Open
feat(nextjs-defi-lending-moonwell): Moonwell USDC lending recipe (Base)#73bprofiro wants to merge 1 commit into
bprofiro wants to merge 1 commit into
Conversation
Supply and withdraw USDC on Moonwell (Base) with a Dynamic embedded wallet, structured after nextjs-defi-lending-morpho: JS SDK + react hooks, raw viem + minimal ABIs, headless email OTP, WaaS bootstrap via getChainsMissingWaasWalletAccounts(). Market list and live APYs come from api.moonwell.fi/v1/markets with deprecated markets filtered out; markets are keyed by mToken address because native USDC and legacy USDbC both report the mUSDC symbol. Supplying is approve -> mint; withdrawals use redeemUnderlying, or redeem of the full mToken balance for Max so no dust is stranded. Balances derive from exchangeRateStored. Every write simulates first and asserts the Compound v2 return code is zero, since these markets answer some failures with a code instead of a revert. RECIPE.mdx is the companion recipe doc for the docs site, mirroring the Morpho recipe's structure; every code block is a verbatim excerpt of this example.
|
@bprofiro is attempting to deploy a commit to the Dynamic-xyz Team on Vercel. A member of the Team first needs to authorize it. |
|
Deployment failed for project dynamic-morpho with the following error: |
|
Deployment failed for project lifi with the following error: |
|
Deployment failed for project dynamic-gasless-starter with the following error: |
|
Deployment failed for project dynamic-aave with the following error: |
|
Deployment failed for project sidebar-example with the following error: |
|
Deployment failed for project circle-gateway with the following error: |
|
Deployment failed for project blindpay with the following error: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
examples/nextjs-defi-lending-moonwell— supply and withdraw USDC on Moonwell (Base) with a Dynamic embedded wallet. Structured afternextjs-defi-lending-morpho: JS SDK + react hooks, raw viem + minimal hand-rolled ABIs, headless email-OTP sign-in, WaaS bootstrap onuserChangedviagetChainsMissingWaasWalletAccounts().api.moonwell.fi/v1/markets, deprecated markets filtered out. Markets are keyed by mToken address: native USDC and the legacy USDbC market both report themUSDCsymbol.mint; withdraw isredeemUnderlying, orredeemof the full mToken balance when the user picks Max, so no dust is stranded by an exchange-rate tick.exchangeRateStored(mTokenBalance * rate / 1e18) — the mToken balance never changes; the rate carries the interest.0.Demo
a.mov
Implementation notes reviewers may care about
Each of these bit us during real-wallet testing and is documented inline:
networksDatatransformer pins Base as the embedded wallet's default network — a fresh wallet otherwise opens on the first EVM network in the environment.simulateContractis passedwalletClient.account(the account object). An address string parses into ajson-rpcaccount, andwriteContractprefers the request's account — the transaction then goes to the RPC aseth_sendTransaction, which fails.Recipe doc
RECIPE.mdxin the example directory is the companion doc for your recipes directory, mirroring the Morpho recipe's structure. Every code block is a verbatim excerpt of this example. Happy to move or reformat it to wherever your Mintlify source lives.Running it
Dashboard prerequisites: Base under Chains & Networks, Embedded Wallets, Email sign-in, and
http://localhost:3000in Allowed Origins. Reads and broadcasts default to Moonwell's public Base RPC (rpc.moonwell.fi), sincemainnet.base.orgrate-limits browser traffic.Tested end-to-end on Base mainnet with real funds: approve, mint, partial
redeemUnderlying, and fullredeem.