Distributor Fees
Pay Distributor
Calldata that pays a distributor’s credit in the vault to its payout wallet
POST
/
lending-external-securities-v2
/
api
/
vaults
/
{vaultId}
/
distributor-fees
/
pay
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{}'
const url = `https://api.trusset.org/lending-external-securities-v2/api/vaults/${vaultId}/distributor-fees/pay`;
const headers = { 'X-API-Key': 'trusset_your_key_here', 'Content-Type': 'application/json' };
const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify({}) });
const { data } = await res.json();
const transactions = data.steps ? data.steps.map((step) => step.transaction) : [data.transaction];
let tx;
for (const transaction of transactions) {
tx = await signer.sendTransaction(transaction);
await tx.wait();
}
await fetch(url, { method: 'POST', headers, body: JSON.stringify({ txHash: tx.hash }) });
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"transaction": {
"to": "0x4d0cfe39a3431b145d1a1393d901a36d459a1b13",
"data": "0x3d819b82...",
"value": "0",
"chainId": 11155111
},
"functionName": "payDistributor",
"permissionless": true,
"distributor": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"payoutWallet": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"description": "Pay 3.75 USDC of distributor fees to 0x83fd50068b2fc776bbf237f8163495b2247408c1",
"note": "Any wallet may sign this transaction. The vault pays the distributor's own payout wallet, never the signer.",
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay",
"field": "txHash"
}
}
}
{
"success": true,
"data": {
"txHash": "0xc81c17ec39fe6e79069a8e1d0d83b821e300aec67ed7912627cbc33cd3b36e05",
"action": "pay",
"signer": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"events": ["PAID"]
}
}
{
"success": false,
"data": null,
"error": {
"code": "NOTHING_ACCRUED",
"message": "Nothing is claimable for this distributor in the vault yet. Collect the vault's slice from its markets first."
}
}
Builds
The route validates every field of the schema it shares with the other distributor actions, even where this action ignores it.
The confirmation response, after the backend has verified the receipt:
Confirming with
payDistributor(distributor) on the vault. It pays everything the vault holds for one distributor to that distributor’s payout wallet. The payout wallet is the distributor’s own address until it is moved with Set Distributor Wallet.
Any wallet may sign. The vault pays the distributor’s payout wallet, never the signer. Only fees already collected into the vault are payable: run Collect Distributor Fees for each market first. claimable on Get Earnings shows the amount.
The API builds a payout for one of your instance’s own distributor wallets. The instance that operates the vault may also build one for any other distributor, which still pays that distributor’s own payout wallet.
Path Parameters
string
required
Vault ID.
Body Parameters
string
The distributor wallet to pay out, as a
0x address. Defaults to your instance’s distributor wallet: its primary verified wallet, or its earliest when none is primary. A distributor that is not a verified wallet of your instance answers DISTRIBUTOR_NOT_OWNED, unless your instance operates the vault.string
Hash of the mined payout,
0x and 64 hex characters. Send it to confirm and record the result; nothing else is needed then. Omit it to receive the calldata.Response Fields
The calldata response:object
Show child attributes
Show child attributes
string
SIGN_TRANSACTION.object
to (the vault), data, value ("0") and chainId.string
payDistributor.boolean
Always
true: any wallet may sign.string
The distributor being paid.
string
The wallet the vault pays.
string
What the vault holds for the distributor when the calldata was built, formatted at the vault’s asset decimals.
string
The same amount in base units.
string
The transaction in words.
string
States that the vault pays the payout wallet, never the signer.
object
endpoint, this route with the vault ID filled in, and field, always txHash.array
Present instead of
transaction, with action: "SIGN_TRANSACTIONS", when the vault must first record a market’s write-off: one recordMarketLoss step per such market, then the payout. Each step is { action, transaction, functionName, description }. confirmStepIndex points at the last step, recordsWriteOffs lists { marketAddress, amountRaw } per market, and writeOffNote explains them. Any wallet may sign every step. Confirm with the hash of the last one.object
The payout reaches
paid on Get Earnings once its block is final, because the earnings history is read only from settled blocks.curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{}'
const url = `https://api.trusset.org/lending-external-securities-v2/api/vaults/${vaultId}/distributor-fees/pay`;
const headers = { 'X-API-Key': 'trusset_your_key_here', 'Content-Type': 'application/json' };
const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify({}) });
const { data } = await res.json();
const transactions = data.steps ? data.steps.map((step) => step.transaction) : [data.transaction];
let tx;
for (const transaction of transactions) {
tx = await signer.sendTransaction(transaction);
await tx.wait();
}
await fetch(url, { method: 'POST', headers, body: JSON.stringify({ txHash: tx.hash }) });
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"transaction": {
"to": "0x4d0cfe39a3431b145d1a1393d901a36d459a1b13",
"data": "0x3d819b82...",
"value": "0",
"chainId": 11155111
},
"functionName": "payDistributor",
"permissionless": true,
"distributor": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"payoutWallet": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"description": "Pay 3.75 USDC of distributor fees to 0x83fd50068b2fc776bbf237f8163495b2247408c1",
"note": "Any wallet may sign this transaction. The vault pays the distributor's own payout wallet, never the signer.",
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay",
"field": "txHash"
}
}
}
{
"success": true,
"data": {
"txHash": "0xc81c17ec39fe6e79069a8e1d0d83b821e300aec67ed7912627cbc33cd3b36e05",
"action": "pay",
"signer": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"events": ["PAID"]
}
}
{
"success": false,
"data": null,
"error": {
"code": "NOTHING_ACCRUED",
"message": "Nothing is claimable for this distributor in the vault yet. Collect the vault's slice from its markets first."
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | A body field is malformed |
DISTRIBUTOR_NOT_OWNED | 403 | distributor is not a verified wallet of your instance, and your instance does not operate the vault |
VAULT_NOT_FOUND | 404 | No such vault, or it is not visible to your instance |
NO_DISTRIBUTOR_WALLET | 409 | Your instance has no verified wallet, so it has no distributor identity in any vault |
VAULT_NOT_DEPLOYED | 409 | The vault has no on-chain address on record |
VAULT_UPGRADE_REQUIRED | 409 | The vault runs an implementation from before distributor attribution |
NOTHING_ACCRUED | 409 | Nothing is payable to this distributor yet, so collect the vault’s slice from its markets first. Or nothing is left once the vault records what its markets wrote off with a defaulted loan |
VAULT_STATE_UNAVAILABLE | 503 | The vault implementation, the distributor’s balance or payout wallet, whether a market wrote off accrual the vault has not recorded, or your standing in an unpublished vault could not be read. Retry shortly |
CHAIN_UNAVAILABLE | 503 | The chain could not be read, so nothing was decided. Retry shortly |
SERVICE_UNAVAILABLE | 503 | The vault records or your instance’s verified wallets could not be read. Retry shortly |
VAULT_DISTRIBUTOR_ACTION_FAILED | 500 | Unexpected failure. Retry, or contact support with the request ID |
txHash can also return TX_NOT_FOUND (404), TX_REVERTED, TX_WRONG_TARGET or TX_WRONG_FUNCTION (400), and TX_NOT_VERIFIED (400) when the transaction carries no payout on this vault. See transaction verification errors.⌘I
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{}'
const url = `https://api.trusset.org/lending-external-securities-v2/api/vaults/${vaultId}/distributor-fees/pay`;
const headers = { 'X-API-Key': 'trusset_your_key_here', 'Content-Type': 'application/json' };
const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify({}) });
const { data } = await res.json();
const transactions = data.steps ? data.steps.map((step) => step.transaction) : [data.transaction];
let tx;
for (const transaction of transactions) {
tx = await signer.sendTransaction(transaction);
await tx.wait();
}
await fetch(url, { method: 'POST', headers, body: JSON.stringify({ txHash: tx.hash }) });
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"transaction": {
"to": "0x4d0cfe39a3431b145d1a1393d901a36d459a1b13",
"data": "0x3d819b82...",
"value": "0",
"chainId": 11155111
},
"functionName": "payDistributor",
"permissionless": true,
"distributor": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"payoutWallet": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"description": "Pay 3.75 USDC of distributor fees to 0x83fd50068b2fc776bbf237f8163495b2247408c1",
"note": "Any wallet may sign this transaction. The vault pays the distributor's own payout wallet, never the signer.",
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/distributor-fees/pay",
"field": "txHash"
}
}
}
{
"success": true,
"data": {
"txHash": "0xc81c17ec39fe6e79069a8e1d0d83b821e300aec67ed7912627cbc33cd3b36e05",
"action": "pay",
"signer": "0x83fd50068b2fc776bbf237f8163495b2247408c1",
"amount": "3.75",
"amountRaw": "3750000",
"events": ["PAID"]
}
}
{
"success": false,
"data": null,
"error": {
"code": "NOTHING_ACCRUED",
"message": "Nothing is claimable for this distributor in the vault yet. Collect the vault's slice from its markets first."
}
}
