How the calls work
Every write returns unsigned transactions, never a signed one. Your app hands them to the client’s wallet, the client signs and broadcasts them in order, and your backend sends the mined hash back to confirm.confirmStepIndex names, which is not always the last one. Positions and the transaction ledger are written on the confirm call. A loan broadcast without one is still live on chain, but your instance does not see it until the market is next read. See Write operations.
1. Onboard each client
A client can deposit or borrow only once its wallet passes the gate the bank chose for the vault or market. Read that gate first: Get Identity Gates for a market,depositorGate on Get Vault for a vault. Then onboard through the path that fills it:
The first four put the wallet on your identity register. A wallet on the shared Trusset ID Register passes every gate built on that register, whichever instance verified it. A gate built on an eligibility register or a whitelist needs the admission or listing on top. Onboarding and access maps every path to every gate.
2. Offer earn
List Vaults returns your own vaults, then every vault published on your network. Each record names its operating bank inoperatedBy. Show the operator wherever you show the vault: the client deposits with that bank, not with you.
Deposit builds the steps a deposit needs: the approval of the settlement token (stablecoin), then the deposit itself. The deposit names your instance as the client’s distributor. After the client signs both, record it with Confirm Transaction.
A deposit can be refused for three reasons your app should explain to the client:
Redeem builds the client’s withdrawal. Redemptions cannot be paused. What bounds them is liquidity: idle funds pay first, then the vault draws on its markets as far as their free liquidity allows.
3. Collect the distributor share
The market sets aside a distributor share of every interest payment: 5 percent of the interest left after Trusset’s 20 percent fee, which is 4 percent of the gross. A vault passes its slice to the distributors behind its depositors. The bank that operates the vault approves each distributor with Set Distributor Approval. Before it approves your instance, deposits you bring still go through, and their share goes to the vault operator. Clients bound to you before an approval is withdrawn stay bound. Get Earnings shows what is waiting per market. Collect Distributor Fees pulls it into the vault and Pay Distributor pays it to your payout wallet. Any wallet can sign both: the vault pays you, never the signer.4. Offer borrow
Quote first. Get Max Borrow returns what a given amount of collateral supports at the current price. Then Open Loan builds the loan for the client’s wallet to sign. Show theoffering block before the client signs. When the market runs loan terms or a fixed rate, it is the only place the due date and the stamped rate appear ahead of the loan. On a market that charges an opening fee, the client receives the amount less the fee and owes the full amount.
On a FREEZE market the collateral stays in the client’s wallet, frozen, and no approval is needed. On a CUSTODY market the first step approves the market’s adapter to take the tokens.
Opening a loan is refused, with a code your app can map to a message, when:
5. Keep clients out of liquidation
Interest accrues every second, and the collateral price moves. Read the health factor with Get Position and show it next to the debt. A health factor below1.0 means the position can be liquidated.
Two calls move a client away from that line. Add Collateral raises the health factor without repaying, and only the borrower can sign it. Repay Loan lowers the debt, and any wallet can sign it, so an omnibus wallet can repay for its client. Repayment never waits on a price: it works while the price is stale, the market is paused or prices are halted.
When a liquidation does happen, the market keeps at most the debt it discharged plus the penalty. Proceeds above that go back to the borrower. If that transfer fails, the surplus waits for the client to claim with Claim Surplus.
6. Show positions and statements
Get Lending Positions lists every loan behind one client, with its debt. Get Position Statement returns a PDF statement of one loan with its verified transaction trail.Next
Launch a credit line shows what the bank decides on the other side of your vault and market. The SDK offers typed methods for these calls. Itslending module ships with 0.4.0, not yet released.