Close loan
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/close_loan \
--header 'Content-Type: application/json' \
--data '
{
"loan": "<string>"
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/close_loan"
payload = { "loan": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({loan: '<string>'})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/close_loan', 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://tars.loopscale.com/v1/markets/creditbook/close_loan",
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([
'loan' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://tars.loopscale.com/v1/markets/creditbook/close_loan"
payload := strings.NewReader("{\n \"loan\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://tars.loopscale.com/v1/markets/creditbook/close_loan")
.header("Content-Type", "application/json")
.body("{\n \"loan\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tars.loopscale.com/v1/markets/creditbook/close_loan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"loan\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"expectedLoanInfo": {
"collateral": [
{
"amount": 1,
"assetIdentifier": "<string>",
"assetMint": "<string>",
"assetType": 1,
"index": 1,
"loan": "<string>",
"id": 1,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"writeVersion": 1
}
],
"collateralYieldPct": 123,
"ledgers": [
{
"apy": 1,
"duration": 1,
"durationType": 1,
"endTime": 1,
"interestOutstanding": 1,
"interestPerSecond": 123,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"lastInterestUpdatedTime": 1,
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"marketInformation": "<string>",
"principalDue": 1,
"principalMint": "<string>",
"principalRepaid": 1,
"startTime": 1,
"status": 1,
"strategy": "<string>",
"weights": [
1
],
"id": 1,
"isLoop": 123,
"writeVersion": 1
}
],
"loan": {
"address": "<string>",
"borrower": "<string>",
"bump": 1,
"closed": true,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"loanStatus": 1,
"nonce": 1,
"startTime": 1,
"writeVersion": 1,
"id": 1
},
"loanType": 1,
"principalYieldPct": 123,
"events": [
{
"action": "addCollateral",
"actionMetadata": {
"type": "addCollateral"
},
"amount": 1,
"assetIdentifier": "<string>",
"eventTime": 1,
"eventTxn": "<string>",
"id": 1,
"loan": "<string>",
"assetMint": "<string>",
"newLender": "<string>",
"originalLender": "<string>",
"usdPrice": 123
}
],
"matrixUpdates": [
{
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"timestamp": 1,
"txnSignature": "<string>",
"weights": [
1
],
"writeVersion": 1,
"id": 1
}
],
"pastLedgers": [
{
"apy": 1,
"duration": 1,
"durationType": 1,
"endTime": 1,
"interestOutstanding": 1,
"interestPerSecond": 123,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"lastInterestUpdatedTime": 1,
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"marketInformation": "<string>",
"principalDue": 1,
"principalMint": "<string>",
"principalRepaid": 1,
"startTime": 1,
"status": 1,
"strategy": "<string>",
"weights": [
1
],
"id": 1,
"isLoop": 123,
"writeVersion": 1
}
]
},
"transactions": [
{
"message": "<string>",
"signatures": [
{
"publicKey": "<string>",
"signature": "<string>"
}
]
}
]
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}Borrowing
Close loan
In the event a loan is fully repaid and all collateral is withdrawn, but wasn’t closed, this directly closes the loan account and refunds the user.
POST
/
markets
/
creditbook
/
close_loan
Close loan
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/close_loan \
--header 'Content-Type: application/json' \
--data '
{
"loan": "<string>"
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/close_loan"
payload = { "loan": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({loan: '<string>'})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/close_loan', 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://tars.loopscale.com/v1/markets/creditbook/close_loan",
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([
'loan' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://tars.loopscale.com/v1/markets/creditbook/close_loan"
payload := strings.NewReader("{\n \"loan\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://tars.loopscale.com/v1/markets/creditbook/close_loan")
.header("Content-Type", "application/json")
.body("{\n \"loan\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tars.loopscale.com/v1/markets/creditbook/close_loan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"loan\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"expectedLoanInfo": {
"collateral": [
{
"amount": 1,
"assetIdentifier": "<string>",
"assetMint": "<string>",
"assetType": 1,
"index": 1,
"loan": "<string>",
"id": 1,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"writeVersion": 1
}
],
"collateralYieldPct": 123,
"ledgers": [
{
"apy": 1,
"duration": 1,
"durationType": 1,
"endTime": 1,
"interestOutstanding": 1,
"interestPerSecond": 123,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"lastInterestUpdatedTime": 1,
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"marketInformation": "<string>",
"principalDue": 1,
"principalMint": "<string>",
"principalRepaid": 1,
"startTime": 1,
"status": 1,
"strategy": "<string>",
"weights": [
1
],
"id": 1,
"isLoop": 123,
"writeVersion": 1
}
],
"loan": {
"address": "<string>",
"borrower": "<string>",
"bump": 1,
"closed": true,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"loanStatus": 1,
"nonce": 1,
"startTime": 1,
"writeVersion": 1,
"id": 1
},
"loanType": 1,
"principalYieldPct": 123,
"events": [
{
"action": "addCollateral",
"actionMetadata": {
"type": "addCollateral"
},
"amount": 1,
"assetIdentifier": "<string>",
"eventTime": 1,
"eventTxn": "<string>",
"id": 1,
"loan": "<string>",
"assetMint": "<string>",
"newLender": "<string>",
"originalLender": "<string>",
"usdPrice": 123
}
],
"matrixUpdates": [
{
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"timestamp": 1,
"txnSignature": "<string>",
"weights": [
1
],
"writeVersion": 1,
"id": 1
}
],
"pastLedgers": [
{
"apy": 1,
"duration": 1,
"durationType": 1,
"endTime": 1,
"interestOutstanding": 1,
"interestPerSecond": 123,
"lastInteractedTime": 1,
"lastInteractedTxn": "<string>",
"lastInterestUpdatedTime": 1,
"ledgerIndex": 1,
"loan": "<string>",
"lqtRatios": [
1
],
"ltvRatios": [
1
],
"marketInformation": "<string>",
"principalDue": 1,
"principalMint": "<string>",
"principalRepaid": 1,
"startTime": 1,
"status": 1,
"strategy": "<string>",
"weights": [
1
],
"id": 1,
"isLoop": 123,
"writeVersion": 1
}
]
},
"transactions": [
{
"message": "<string>",
"signatures": [
{
"publicKey": "<string>",
"signature": "<string>"
}
]
}
]
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}{
"error": {
"code": 400,
"message": "Request could not be processed."
}
}Headers
Optional idempotency key; a retried write with the same key replays the original response
Body
application/json
⌘I