Skip to main content
Not yet released. The lending module described here ships with @trusset/sdk 0.4.0, which is not on npm yet: npm install @trusset/sdk installs 0.1.0, which carries the customers module only. Until 0.4.0 is published, call the Lending API directly.
This page is for the engineer at a deploying issuer or at a lender of record who handles a market’s asset data from a backend. After reading it, both know how to preview the data a deployment attests, read and verify it, re-attest it after the token’s records change, and acknowledge a version. A lender of record adopting a market underwrites an asset it did not issue, described by data no contract can read. The asset data makes that description attributable and tamper-evident: the issuer side attests the hash of a canonical bundle, and the lender of record acknowledges the hash it reviewed. The lending factory stores only the two hashes, and the bundle stays off chain. The factory does not verify the description. It only records who stated which version. trusset.lending.assetData takes the market’s contract address, marketAddress, not its marketId. The writes take the three call shapes of the signing model.

Preview the asset data

preview returns the bundle a deployment would attest for a collateral token, and its hash, before anything is built. It stores nothing. Pass the same mode, priceSource and borrowAssetAddress the deployment will use, because each is part of the bundle. On a FIXED deployment pass the same initialPrice too, because the bundle commits to the fixed price itself.
The token must be imported into your instance with a published profile, or the preview is refused with TOKEN_PROFILE_REQUIRED, exactly as a deployment would be. The first attestation needs no call of its own: it travels inside the deployment signature, and the prepared deployment carries the same assetData.contentHash to compare with the preview.

Read the asset data

get returns the record: the attested and the acknowledged hash, who may write each next, and whether one of your wallets can.
status is null when the factory record could not be read, which is not the same as NONE. DIVERGED is the signal a lender of record watches. Neither the market contracts nor the API act on a divergence: whether the new version still supports the credit already extended is the lender of record’s decision. bundle returns the stored bytes behind a hash, the standing attestation by default. The API re-hashes them before they leave, and a lender of record can recompute the hash itself without trusting the response. The hash is keccak256 over the UTF-8 bytes of canonicalJson.
Only bundles prepared through Trusset are stored. A hash attested with bytes built elsewhere answers SNAPSHOT_NOT_FOUND, and get says ahead of time whether bytes exist in bundleAvailable. Pass { hash } to read an earlier version.

Re-attest after the records change

Re-attesting never removes an acknowledgement. When the lender of record approved an earlier version, the market reads DIVERGED from the moment the new attestation mines until the lender of record acknowledges again. divergesAfter on the prepared response says so before anything is signed.
attest replaces the standing attestation with the bundle the token’s profile and instrument record produce now. Use it after either changed, or to move a version attested under schema 1.0.0 onto the current schema. profile.changedSinceAttestation on get reports both cases. The attestor signs. While the market seeks a lender of record that is the wallet that deployed it. After adoption it is the issuer wallet the lender of record named. The SDK compares the signer with the attestor the build names and refuses a mismatch before anything is signed.
The attestor is read when the transaction is built. If the market is adopted before it mines, authority passes to the named issuer, and a transaction the deployer signed reverts. Any other instance is refused with NOT_ATTESTOR.

Acknowledge a version

acknowledge records the lender of record’s approval of the version it reviewed. The lender of record or the admin it named signs. Name the hash that was actually read. The build refuses a hash that is not the standing attestation with ASSET_DATA_STALE. The factory also reverts the acknowledgement if the issuer re-attests before it mines. The SDK refuses the zero hash before any request.
An acknowledgement records a review, and the chain stores only the hash. No loan, liquidity or liquidation operation depends on it. Before a market is adopted there is nobody to acknowledge, and the call is refused with NOT_ADOPTED. The adoption itself can carry the first acknowledgement through assetDataHash in the adoption terms. To confirm an acknowledgement broadcast from your own infrastructure, pass null as the hash with { txHash }. The API records the hash, version and wallet from the event the mined transaction emitted, never from the request.

Methods and endpoints