Borrow principal
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/borrow \
--header 'Content-Type: application/json' \
--data '
{
"borrowParams": {
"amount": 1,
"assetIndexGuidance": [
1
],
"duration": 1,
"expectedLoanValues": {
"expectedApy": 1,
"expectedLqt": [
1
]
},
"skipSolUnwrap": true
},
"loan": "<string>",
"strategy": "<string>",
"isLoop": true,
"refinanceParams": {
"assetIndexGuidance": [
1
],
"durationIndex": 1,
"ledgerIndex": 1
},
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [
1
]
}
]
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/borrow"
payload = {
"borrowParams": {
"amount": 1,
"assetIndexGuidance": [1],
"duration": 1,
"expectedLoanValues": {
"expectedApy": 1,
"expectedLqt": [1]
},
"skipSolUnwrap": True
},
"loan": "<string>",
"strategy": "<string>",
"isLoop": True,
"refinanceParams": {
"assetIndexGuidance": [1],
"durationIndex": 1,
"ledgerIndex": 1
},
"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({
borrowParams: {
amount: 1,
assetIndexGuidance: [1],
duration: 1,
expectedLoanValues: {expectedApy: 1, expectedLqt: [1]},
skipSolUnwrap: true
},
loan: '<string>',
strategy: '<string>',
isLoop: true,
refinanceParams: {assetIndexGuidance: [1], durationIndex: 1, ledgerIndex: 1},
weightMatrixUpdates: [{collateralIndex: 1, weightMatrixUpdate: [1]}]
})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/borrow', 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/borrow",
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([
'borrowParams' => [
'amount' => 1,
'assetIndexGuidance' => [
1
],
'duration' => 1,
'expectedLoanValues' => [
'expectedApy' => 1,
'expectedLqt' => [
1
]
],
'skipSolUnwrap' => true
],
'loan' => '<string>',
'strategy' => '<string>',
'isLoop' => true,
'refinanceParams' => [
'assetIndexGuidance' => [
1
],
'durationIndex' => 1,
'ledgerIndex' => 1
],
'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/borrow"
payload := strings.NewReader("{\n \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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/borrow")
.header("Content-Type", "application/json")
.body("{\n \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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/borrow")
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 \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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": [
{
"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
Borrow principal
Borrows additional principal against an existing loan and can optionally refinance the targeted ledger in the same transaction.
POST
/
markets
/
creditbook
/
borrow
Borrow principal
curl --request POST \
--url https://tars.loopscale.com/v1/markets/creditbook/borrow \
--header 'Content-Type: application/json' \
--data '
{
"borrowParams": {
"amount": 1,
"assetIndexGuidance": [
1
],
"duration": 1,
"expectedLoanValues": {
"expectedApy": 1,
"expectedLqt": [
1
]
},
"skipSolUnwrap": true
},
"loan": "<string>",
"strategy": "<string>",
"isLoop": true,
"refinanceParams": {
"assetIndexGuidance": [
1
],
"durationIndex": 1,
"ledgerIndex": 1
},
"weightMatrixUpdates": [
{
"collateralIndex": 1,
"weightMatrixUpdate": [
1
]
}
]
}
'import requests
url = "https://tars.loopscale.com/v1/markets/creditbook/borrow"
payload = {
"borrowParams": {
"amount": 1,
"assetIndexGuidance": [1],
"duration": 1,
"expectedLoanValues": {
"expectedApy": 1,
"expectedLqt": [1]
},
"skipSolUnwrap": True
},
"loan": "<string>",
"strategy": "<string>",
"isLoop": True,
"refinanceParams": {
"assetIndexGuidance": [1],
"durationIndex": 1,
"ledgerIndex": 1
},
"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({
borrowParams: {
amount: 1,
assetIndexGuidance: [1],
duration: 1,
expectedLoanValues: {expectedApy: 1, expectedLqt: [1]},
skipSolUnwrap: true
},
loan: '<string>',
strategy: '<string>',
isLoop: true,
refinanceParams: {assetIndexGuidance: [1], durationIndex: 1, ledgerIndex: 1},
weightMatrixUpdates: [{collateralIndex: 1, weightMatrixUpdate: [1]}]
})
};
fetch('https://tars.loopscale.com/v1/markets/creditbook/borrow', 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/borrow",
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([
'borrowParams' => [
'amount' => 1,
'assetIndexGuidance' => [
1
],
'duration' => 1,
'expectedLoanValues' => [
'expectedApy' => 1,
'expectedLqt' => [
1
]
],
'skipSolUnwrap' => true
],
'loan' => '<string>',
'strategy' => '<string>',
'isLoop' => true,
'refinanceParams' => [
'assetIndexGuidance' => [
1
],
'durationIndex' => 1,
'ledgerIndex' => 1
],
'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/borrow"
payload := strings.NewReader("{\n \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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/borrow")
.header("Content-Type", "application/json")
.body("{\n \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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/borrow")
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 \"borrowParams\": {\n \"amount\": 1,\n \"assetIndexGuidance\": [\n 1\n ],\n \"duration\": 1,\n \"expectedLoanValues\": {\n \"expectedApy\": 1,\n \"expectedLqt\": [\n 1\n ]\n },\n \"skipSolUnwrap\": true\n },\n \"loan\": \"<string>\",\n \"strategy\": \"<string>\",\n \"isLoop\": true,\n \"refinanceParams\": {\n \"assetIndexGuidance\": [\n 1\n ],\n \"durationIndex\": 1,\n \"ledgerIndex\": 1\n },\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": [
{
"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
On-chain borrow params.
Show child attributes
Show child attributes
Loan account address (base58).
Strategy account address (base58).
Optional on-chain refinance params.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I