Simple repay loan
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/repay_simple \
--header 'Content-Type: application/json' \
--data '
{
"loan": "<string>",
"repayParams": {
"amount": 1,
"ledgerIndex": 1,
"repayAll": true
},
"strategy": "<string>",
"isLoop": true,
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [
1
]
}
]
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/repay_simple"
payload = {
"loan": "<string>",
"repayParams": {
"amount": 1,
"ledgerIndex": 1,
"repayAll": True
},
"strategy": "<string>",
"isLoop": True,
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [1]
}
]
}
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>',
repayParams: {amount: 1, ledgerIndex: 1, repayAll: true},
strategy: '<string>',
isLoop: true,
weightMatrixUpdates: [{collateralIndex: 1, weightMatrixUpdate: [1]}]
})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/repay_simple', 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/repay_simple",
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>',
'repayParams' => [
'amount' => 1,
'ledgerIndex' => 1,
'repayAll' => true
],
'strategy' => '<string>',
'isLoop' => true,
'weightMatrixUpdates' => [
[
'collateralIndex' => 1,
'weightMatrixUpdate' => [
1
]
]
]
]),
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/repay_simple"
payload := strings.NewReader("{\n \"loan\": \"<string>\",\n \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\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/repay_simple")
.header("Content-Type", "application/json")
.body("{\n \"loan\": \"<string>\",\n \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tars.loopscale.com/v1/markets/creditbook/repay_simple")
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 \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\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
Simple repay loan
A simplified repay endpoint that handles a single strategy at a time. Unlike the full repay endpoint, it does not support CPI instructions, collateral withdrawals, or setup instructions. If a ledger is fully repaid on a multi-ledger loan, weight matrix updates are automatically generated to redistribute collateral away from the emptied ledger.
POST
/
markets
/
creditbook
/
repay_simple
Simple repay loan
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/repay_simple \
--header 'Content-Type: application/json' \
--data '
{
"loan": "<string>",
"repayParams": {
"amount": 1,
"ledgerIndex": 1,
"repayAll": true
},
"strategy": "<string>",
"isLoop": true,
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [
1
]
}
]
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/repay_simple"
payload = {
"loan": "<string>",
"repayParams": {
"amount": 1,
"ledgerIndex": 1,
"repayAll": True
},
"strategy": "<string>",
"isLoop": True,
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [1]
}
]
}
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>',
repayParams: {amount: 1, ledgerIndex: 1, repayAll: true},
strategy: '<string>',
isLoop: true,
weightMatrixUpdates: [{collateralIndex: 1, weightMatrixUpdate: [1]}]
})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/repay_simple', 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/repay_simple",
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>',
'repayParams' => [
'amount' => 1,
'ledgerIndex' => 1,
'repayAll' => true
],
'strategy' => '<string>',
'isLoop' => true,
'weightMatrixUpdates' => [
[
'collateralIndex' => 1,
'weightMatrixUpdate' => [
1
]
]
]
]),
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/repay_simple"
payload := strings.NewReader("{\n \"loan\": \"<string>\",\n \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\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/repay_simple")
.header("Content-Type", "application/json")
.body("{\n \"loan\": \"<string>\",\n \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tars.loopscale.com/v1/markets/creditbook/repay_simple")
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 \"repayParams\": {\n \"amount\": 1,\n \"ledgerIndex\": 1,\n \"repayAll\": true\n },\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"weightMatrixUpdates\": [\n {\n \"collateralIndex\": 1,\n \"weightMatrixUpdate\": [\n 1\n ]\n }\n ]\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