borrowAsset. Each market has two identifiers: marketId, the record ID your instance keeps, and marketAddress, the contract. Every method on trusset.lending.markets that names a market takes the marketId, and sending a contract address in its place throws a ValidationError before any request.
Every write on this page takes the three call shapes of the signing model: no options to prepare, { signer } to sign and confirm, { txHash } to confirm a transaction you broadcast yourself.
Read a market
list returns every market your instance records, from the stored record. Pass includeOnChain: true to add the live pool figures to each row. That runs a chain read per market, so for one market prefer get or metrics.
get returns one market with its record, its on-chain state, its oracle status and its wiring. A section the API could not read is listed in errors and left null, so a missing section means unknown, not empty. When the chain read fails, onChain.isOnChain is false, the figures are zero and readFailed is true. Treat those zeros as an outage.
maxBorrow takes a collateral amount as a decimal string, parsed at the collateral token’s decimals, and returns the most the market lends against it in the borrow asset. The quote is the collateral bound alone: it does not check pool liquidity, supply caps or the minimum borrow. isStale: true means the oracle price is older than its maxPriceAge. A stale price blocks opening loans, drawing more, withdrawing collateral against open debt and liquidating. Repayment never waits on a price.
Further reads cover the pool over time:
history answers available: false with a reason when the index cannot be reached, and indexed: false for a market the index does not cover yet. Neither is an empty market.
Download the lifecycle statement
lifecycleStatement returns a PDF assembled from indexed events: configuration, roles, encumbrances, loans, liquidations and auctions. It resolves to { bytes, contentType, filename }. The API refuses with INDEX_STALE when the index trails the chain by more than 300 seconds, because the statement would omit everything since. Pass allowStale: true only when that gap is acceptable.
from and to are dates written as YYYY-MM-DD, and loanId narrows the statement to one loan.
Prepare a deployment
Three reads come before a deployment.deploymentOptions returns what the factory accepts today: price sources, rate and term ranges, the fixed fee shares, the identity gate rules and your whitelists. borrowAssets returns the settlement tokens Trusset curates for your network. Any ERC-20 with 6 to 18 decimals is accepted as well, and a custom one you deploy with is saved to your instance.
forgetStablecoin removes a saved custom asset from that list. It changes nothing on chain.
Deploy a market
deploy builds one factory transaction that creates the market, its oracle, interest model, insurance fund, collateral adapter and liquidation router. The same signature attests the market’s asset data. Sign with your instance’s registered wallet, which the prepared response names in signer. The factory records that wallet as the market’s deployer.
walletAddress is the wallet nominated as lender of record. The market is born seeking a lender of record: it names no admin, no issuer and no collateral agent until a candidate adopts it. openToAnyCurator: true also offers it to approved lenders of record beyond the candidates.
mode decides how collateral is held. FREEZE, the reference model, locks tokens in the borrower’s own wallet through the ERC-3643 agent surface. CUSTODY escrows them in the adapter, which is structurally a fiduciary transfer rather than a pledge. It is outside the reference configuration, and the factory refuses it for some tokens with CUSTODY_MODE_EXCLUDED. Neither mode, priceSource nor borrowAssetAddress can change after deployment.
The SDK checks the request before sending it:
initialPriceis a decimal string with at most 18 decimal places, required forNAV,MARKETandFIXED.ORACLEtakesoracleAddressinstead and refuses a price.rateModedecides the rate bounds:CLAMPEDneedsrateCapBps,FIXEDneedsfixedRateBpsandmaxLoanDurationDays, andCURVEtakes no bounds.candidatesholds at most 20 addresses, andtermGracePeriodDaysneedsmaxLoanDurationDaysorterminalDueDate.operatorShareBpsis refused. Every market pays the fixed operator and distributor shares the factory sets.
assetData.canonicalJson, the fee shares and, on a FIXED market, warnings to show the signer. Confirm with the hash once it mines.
MARKET_EXISTS, and a token without a published profile with TOKEN_PROFILE_REQUIRED. The Deploy Market reference lists every refusal.
Run the setup steps
setupSteps returns the ordered checklist a market still needs before it can lend. configurationStatus returns the readiness verdict, fullyConfigured, with ready-to-sign calldata for every outstanding step and the authority that signs it.
configure with an action and a signer runs that one step and confirms it. Without an action the SDK refuses a signer, because the outstanding steps belong to different wallets.
signer is the token’s agent administrator.
transactions. The three verify*AsHolder actions can answer with a holder onboarding plan instead: an identity deployment, claim signatures and registrations on the token’s registry. The SDK refuses to run that plan with a signer. Prepare it without one, run it from the onboarding wallet, and confirm the registration with { txHash }. A SIGN_CLAIMS message names its scheme: eip191 signs the personal message over messageHash; eip712 (the newest T-REX registries) signs the message’s typedData and carries an issuedAt, which each claimSignatures entry sends back, because the claim is rebuilt from it. See Registering a holder from your own wallet.
Change the risk configuration
updateConfig writes the whole risk configuration. Every field is required on every call, so read the current values, change what you need and send all twelve back. The wallet holding ISSUER_ROLE signs, which is the issuer the lender of record named at adoption.
Set the identity gates
The borrower register gates opening a loan and drawing more. The provider register is read by every vault on the market before it admits a depositor.identityGates reads both, and setIdentityGates changes them in one transaction signed by the market admin.
null to clear it. A side can also name one of your whitelists by ID. A change applies from the next open, draw or vault deposit, and existing loans are not examined again.
MARKET-priced market lends to professional borrowers only, so its borrower register must stay a qualifying professional gate. A whitelist installed as the provider register needs attestIdentifiedMembers: true, and the SDK sends it again on the confirm leg. The rules are on Set Identity Gates.
Upgrade a market
upgradeStatus shows each proxy’s current and target implementation before anything is built. upgrade moves one proxy onto the implementation the factory serves: market and router are signed by their admins, rateModel and insuranceFund by their owners. The target implementation is always read from the factory and cannot be named.
upgrade signs and confirms the upgrade only. A market upgrade can return pokeSnapshot, a transaction that seeds the history series, and followUps, which re-register the market’s vaults. Send pokeSnapshot, then each followUps.steps entry in order, from the market admin. They have no confirm leg.
