What you will build
A position flow that supplies collateral from Base, borrows against it with the borrowed asset delivered to another network, and reads the position back to render a health factor.The money market list on Base is separate from the swap list: a token can appear in one and not the other. See Networks & Assets.
Prerequisites
@sodax/sdkand a wallet provider from@sodax/wallet-sdk-coreor@sodax/wallet-sdk-react.- A Base wallet funded with ETH for gas, and a SODAX API key kept on your server. See API keys.
How it works
1
Supply collateral from Base
The action is keyed by
srcChainKey: ChainKeys.BASE_MAINNET and the token comes from the Base money market list. An ERC-20 needs an allowance first, so approve only when it is short, and wait for the approval to confirm before you supply.2
Borrow, delivered to another network
The cross-network part is one parameter. The user still acts from Base, but
dstChainKey and dstAddress decide where the borrowed liquidity lands, and the token comes from the destination network’s list. To borrow into Base against collateral held elsewhere, swap the roles. Borrow and withdraw need no approval; repaying an ERC-20 does.3
Read the position
sodax.moneyMarket.data returns USD-converted rates per reserve and the user’s totals and health factor.Code
A small helper finds a token by symbol in a network’s list and throws if it isn’t there:Failures
Each method returns a typedResult; the error codes are in Lend / Borrow (Money Market). Read the position before you borrow, so the amount stays within what the collateral covers.
Next steps
- Money Market on Base: supply, borrow, repay, and withdraw in depth.
- Networks & Assets: the live money market list on Base.