Lend against legs
fact LegWrap, LegOracle and LegWrapFactory are deployed on Robinhood Chain testnet (deployment 11). The mechanics are described in full under Protocol: Credit; this page is the integrator’s view.
Why wrap
Section titled “Why wrap”COUPON legs are ERC-1155 units. Lending markets take ERC-20 collateral with an oracle. LegWrap gives each struck series an ERC-20 share token that holds the COUPON units and the coupons they earn, and LegOracle prices one share in USDG. The factory opens a Morpho Blue market per series with USDG as the loan token.
| Contract | Your call |
|---|---|
LegWrapFactory | create(seriesId) if no market exists; wrapOf, oracleOf, marketOf, marketParams(seriesId) to read one |
LegWrap | wrap(units, to), unwrap(shares, to), harvest(), exit(shares, to), previewWrap, previewUnwrap, pool |
LegOracle | price() in the convention Morpho expects |
Nothing here has an owner, a pause or a parameter.
legs.setApprovalForAll(address(wrap), true);// USDG owed so the new shares carry the same pool share as existing onesuint256 buyIn = wrap.previewWrap(units);usdg.approve(address(wrap), buyIn);// pulls the units and the buy-in, mints `units` shares to `to`wrap.wrap(units, to);Share supply always equals the units held. The buy-in is zero while the pool is empty, which is the case for a freshly struck series.
Borrow
Section titled “Borrow”Post the shares to the series market through Morpho’s own interface with marketParams(seriesId). Coupons keep accruing to the wrapper while the shares are collateral; harvest() (permissionless) pulls them into the pool and the oracle counts them, so the collateral value rises with every paid observation.
Unwind
Section titled “Unwind”// collects accrued coupons, burns the shares, releases the units and pays the pool sharewrap.unwrap(shares, to);exit(shares, to) releases the units without a pool payout, the fallback when a coupon claim cannot go through. At autocall or maturity the released units are redeemed on NoteCore by whoever holds them.
What to show a borrower
Section titled “What to show a borrower”| Number | Source |
|---|---|
| Collateral value | oracle.price() × shares |
| Coupons in the pool | wrap.pool(), wrap.poolPerShareWad() |
| Barrier distance | core.getSeries(seriesId) and the series feed |
| Market state | Morpho market(id) for supply, borrow and utilisation |
A breach changes the collateral from a par claim to stock delivered at s0. Market parameters (loan-to-value, rate model) are chosen with that in mind; read them from marketParams rather than assuming.