Markets
Set Liquidator Role
Grant or revoke LIQUIDATOR_ROLE on a market
POST
/
lending-external-securities
/
api
/
markets
/
{marketId}
/
liquidator-role
curl -X POST "https://api.trusset.org/lending-external-securities/api/markets/{marketId}/liquidator-role" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{"address": "0x123...456", "action": "grant"}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/markets/${marketId}/liquidator-role`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ address: issuerWalletAddress, action: 'grant' })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": "0xabc...def",
"unchanged": false
}
}
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": null,
"unchanged": true
}
}
{
"success": true,
"data": {
"requiresUserAction": true,
"action": "grant",
"address": "0x123...456",
"configurationCalldata": {
"liquidatorRole": {
"to": "0x70a0e25c7b768b87e658348b3b577678a173e038",
"data": "0x...",
"description": "Grant LIQUIDATOR_ROLE to 0x123...456 (requires market DEFAULT_ADMIN_ROLE)"
}
}
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "address", "message": "Invalid" }
]
}
}
{
"success": false,
"error": {
"code": "MARKET_PENDING_CURATOR",
"message": "This market has no lender of record yet, so changing who may liquidate on it is not possible. A nominated candidate must take the role before the market has an admin that can sign this."
}
}
Grants or revokes
LIQUIDATOR_ROLE for any address on the market contract. Holding this role is a prerequisite for Liquidate Loan and Settle Expired Auction.
The role change has to be executed from the wallet holding DEFAULT_ADMIN_ROLE on the market. The endpoint returns requiresUserAction with the calldata for that wallet to sign.
When the address already holds the role you asked for, the response returns
unchanged: true and no calldata. Nothing needs to be signed.Path Parameters
string
required
Market ID.
Body Parameters
string
required
Address to grant or revoke. Must be a 0x-prefixed 40-character hex address.
string
required
grant or revoke.string
Hash of the transaction you broadcast for this operation. Send it to confirm the transaction and record the result. Omit it to receive the calldata.
Response Fields
object
Show child attributes
Show child attributes
string
The action performed, echoed back.
string
The address affected, echoed back.
string
Transaction hash.
null when the address was already in the requested state.boolean
true when no transaction was needed because the role already matched the requested state.boolean
Present and
true whenever the role actually needs changing. Pair with configurationCalldata.object
Present only alongside
requiresUserAction. Contains liquidatorRole as { to, data, description } for the market admin to sign.Revoking the role from every address you control leaves the market with no liquidator. Loans will still become liquidatable, but nothing will act on them until the role is restored or another liquidator is authorized.
curl -X POST "https://api.trusset.org/lending-external-securities/api/markets/{marketId}/liquidator-role" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{"address": "0x123...456", "action": "grant"}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/markets/${marketId}/liquidator-role`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ address: issuerWalletAddress, action: 'grant' })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": "0xabc...def",
"unchanged": false
}
}
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": null,
"unchanged": true
}
}
{
"success": true,
"data": {
"requiresUserAction": true,
"action": "grant",
"address": "0x123...456",
"configurationCalldata": {
"liquidatorRole": {
"to": "0x70a0e25c7b768b87e658348b3b577678a173e038",
"data": "0x...",
"description": "Grant LIQUIDATOR_ROLE to 0x123...456 (requires market DEFAULT_ADMIN_ROLE)"
}
}
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "address", "message": "Invalid" }
]
}
}
{
"success": false,
"error": {
"code": "MARKET_PENDING_CURATOR",
"message": "This market has no lender of record yet, so changing who may liquidate on it is not possible. A nominated candidate must take the role before the market has an admin that can sign this."
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
NO_MARKET_ADDRESS | 400 | The market has no on-chain address recorded |
VALIDATION_ERROR | 400 | address is not a valid address, or action is not grant or revoke |
LIQUIDATOR_ROLE_UPDATE_FAILED | 400 | The role change could not be prepared and no more specific code applied |
MARKET_NOT_FOUND | 404 | No market with this ID on your instance |
MARKET_PENDING_CURATOR | 409 | The market has no lender of record yet, so nobody holds the admin role this change requires. Skipped when confirming with txHash |
⌘I
curl -X POST "https://api.trusset.org/lending-external-securities/api/markets/{marketId}/liquidator-role" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{"address": "0x123...456", "action": "grant"}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities/api/markets/${marketId}/liquidator-role`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ address: issuerWalletAddress, action: 'grant' })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": "0xabc...def",
"unchanged": false
}
}
{
"success": true,
"data": {
"action": "grant",
"address": "0x123...456",
"txHash": null,
"unchanged": true
}
}
{
"success": true,
"data": {
"requiresUserAction": true,
"action": "grant",
"address": "0x123...456",
"configurationCalldata": {
"liquidatorRole": {
"to": "0x70a0e25c7b768b87e658348b3b577678a173e038",
"data": "0x...",
"description": "Grant LIQUIDATOR_ROLE to 0x123...456 (requires market DEFAULT_ADMIN_ROLE)"
}
}
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{ "field": "address", "message": "Invalid" }
]
}
}
{
"success": false,
"error": {
"code": "MARKET_PENDING_CURATOR",
"message": "This market has no lender of record yet, so changing who may liquidate on it is not possible. A nominated candidate must take the role before the market has an admin that can sign this."
}
}
