Loan Approvals
Set Loan Approvals
Switch approve-only loans on or off for a market
POST
/
lending-external-securities-v2
/
api
/
markets
/
{marketId}
/
loan-approvals
Set Loan Approvals
curl --request POST \
--url https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"enabled": true,
"signerAddress": "<string>",
"txHash": "<string>"
}
'import requests
url = "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals"
payload = {
"enabled": True,
"signerAddress": "<string>",
"txHash": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true, signerAddress: '<string>', txHash: '<string>'})
};
fetch('https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true,
'signerAddress' => '<string>',
'txHash' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals"
payload := strings.NewReader("{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "CREATE_APPROVALS",
"transaction": {
"to": "0x3a9f1c7e5b2d8046f1e3c5a7b9d0e2f4a6c8b1d3",
"data": "0x..."
},
"functionName": "createLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": null,
"remaining": 1,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "SWITCH_ON",
"transaction": {
"to": "0x41b9c4d5dee70a5e3682094462e5065275e728a9",
"data": "0x..."
},
"functionName": "setLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": "DEFAULT_ADMIN_ROLE",
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"remaining": 0,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"txHash": "0x9f2c41d8b7e05a3164c2870fbd935e1a4c7802db6135ea9048f7c21b5d3ea41b",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"blockNumber": 6789012,
"step": "SWITCH_ON",
"remaining": 0,
"mode": {
"supported": true,
"available": true,
"enabled": true,
"requested": false,
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"canonical": true,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "NONE",
"cleared": true,
"mode": {
"supported": true,
"available": true,
"enabled": false,
"requested": false,
"approvals": null,
"canonical": null,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
Builds the next transaction that switches approve-only loans on or off, and confirms it on a second call. Trusset never signs: the market admin signs the calldata this route returns.
Switching on takes up to two signatures:
CREATE_APPROVALSbuilds the market’s approvals contract. The answer carriesremaining: 1.- Call again with
enabled: trueforSWITCH_ON, which names the approvals contract on the market.
SWITCH_OFF.
If approve-only loans were only requested at deployment and never switched on, enabled: false clears the request without a transaction. The answer is then action: NONE with cleared: true.
Who can call
The market admin, the holder ofDEFAULT_ADMIN_ROLE.
Path Parameters
Body Parameters
Send exactly one ofenabled or txHash.
Hash of the transaction you broadcast for the step this route built. Send it to confirm the step.
Response Fields
Show child attributes
Show child attributes
SIGN_TRANSACTION, or NONE when a request was cleared without a transaction. Returned when txHash is omitted.{ endpoint, field }: the call that confirms this transaction, and txHash as the body field that carries the hash. Returned when txHash is omitted.The mode after the change. See Get Loan Approvals. Returned when confirming, and when a request was cleared.
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "CREATE_APPROVALS",
"transaction": {
"to": "0x3a9f1c7e5b2d8046f1e3c5a7b9d0e2f4a6c8b1d3",
"data": "0x..."
},
"functionName": "createLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": null,
"remaining": 1,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "SWITCH_ON",
"transaction": {
"to": "0x41b9c4d5dee70a5e3682094462e5065275e728a9",
"data": "0x..."
},
"functionName": "setLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": "DEFAULT_ADMIN_ROLE",
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"remaining": 0,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"txHash": "0x9f2c41d8b7e05a3164c2870fbd935e1a4c7802db6135ea9048f7c21b5d3ea41b",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"blockNumber": 6789012,
"step": "SWITCH_ON",
"remaining": 0,
"mode": {
"supported": true,
"available": true,
"enabled": true,
"requested": false,
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"canonical": true,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "NONE",
"cleared": true,
"mode": {
"supported": true,
"available": true,
"enabled": false,
"requested": false,
"approvals": null,
"canonical": null,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
NOT_MARKET_ADMIN | 403 | No verified wallet of your instance holds DEFAULT_ADMIN_ROLE on the market |
SIGNER_NOT_AUTHORIZED | 403 | signerAddress is not a wallet that may sign this step |
MODE_CHANGE_NOT_INSTANCE_BOUND | 403 | The transaction was signed by a wallet that is not verified for your instance |
MARKET_PENDING_CURATOR | 409 | The market has no lender of record yet |
MARKET_UPGRADE_REQUIRED | 409 | The market runs an implementation from before this feature. Its admin upgrades it through the seven-day notice first |
LOAN_APPROVALS_CURRENT | 409 | Approve-only loans are already in the state you asked for. Nothing to sign |
LOAN_APPROVALS_NOT_AVAILABLE | 409 | The network does not carry the approvals factory yet |
MODE_CHANGE_WOULD_REVERT | 409 | The transaction would revert as it stands, so nothing was built |
CHAIN_UNAVAILABLE | 503 | The chain could not be read just now |
⌘I
Set Loan Approvals
curl --request POST \
--url https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"enabled": true,
"signerAddress": "<string>",
"txHash": "<string>"
}
'import requests
url = "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals"
payload = {
"enabled": True,
"signerAddress": "<string>",
"txHash": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true, signerAddress: '<string>', txHash: '<string>'})
};
fetch('https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true,
'signerAddress' => '<string>',
'txHash' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals"
payload := strings.NewReader("{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/loan-approvals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true,\n \"signerAddress\": \"<string>\",\n \"txHash\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "CREATE_APPROVALS",
"transaction": {
"to": "0x3a9f1c7e5b2d8046f1e3c5a7b9d0e2f4a6c8b1d3",
"data": "0x..."
},
"functionName": "createLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": null,
"remaining": 1,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "SIGN_TRANSACTION",
"step": "SWITCH_ON",
"transaction": {
"to": "0x41b9c4d5dee70a5e3682094462e5065275e728a9",
"data": "0x..."
},
"functionName": "setLoanApprovals",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"requiredRole": "DEFAULT_ADMIN_ROLE",
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"remaining": 0,
"confirmWith": {
"endpoint": "POST /lending-external-securities-v2/api/markets/cmwfk2h7x0003jw9w4q8b2n1c/loan-approvals",
"field": "txHash"
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"txHash": "0x9f2c41d8b7e05a3164c2870fbd935e1a4c7802db6135ea9048f7c21b5d3ea41b",
"signer": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"blockNumber": 6789012,
"step": "SWITCH_ON",
"remaining": 0,
"mode": {
"supported": true,
"available": true,
"enabled": true,
"requested": false,
"approvals": "0x5d2e8c1a7f4b3960e2d1c8a7b6f5e4d3c2b1a098",
"canonical": true,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
{
"success": true,
"data": {
"action": "NONE",
"cleared": true,
"mode": {
"supported": true,
"available": true,
"enabled": false,
"requested": false,
"approvals": null,
"canonical": null,
"upgradeRequired": false,
"approverRole": "0x46f54e51673dd785402ec1df75a85f2b1da1abc02695cc95d95578f830f58153",
"maxValidHours": 696,
"viewer": {
"isBank": true,
"isAdmin": true,
"approverWallets": [
"0x7712db30a7b4ffd9c445793089118b60e56d752a"
]
}
},
"marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
},
"error": null
}
