from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_looped_positions(chain=models.V2CreditLoopedPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.credit.creditLoopedPositions({
chain: "base",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/credit/looped_positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/credit/looped_positions', 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.compasslabs.ai/v2/credit/looped_positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/credit/looped_positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/credit/looped_positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/looped_positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"credit_account_address": "<string>",
"positions": [
{
"collateral_symbol": "WETH",
"collateral_token": "0x4200000000000000000000000000000000000006",
"current": {
"borrow_apy": "3.8400000000",
"collateral_amount": "3.0000000000",
"collateral_lending_apy": "0.0000000000",
"collateral_usd": "9000.0000000000",
"debt_amount": "5000.0000000000",
"debt_usd": "5000.0000000000",
"health_factor": "1.5480000000",
"health_factor_scope": "market",
"leverage": "2.2500000000",
"net_usd_value": "4000.0000000000"
},
"debt_symbol": "USDC",
"debt_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"history": [
{
"block_number": 25000000,
"block_timestamp": "2025-01-15T10:30:00Z",
"classification": "loop_open",
"collateral_delta": "3.0000000000",
"debt_delta": "5000.0000000000",
"events": [],
"iterations": 2,
"swap": {
"bought_amount": "1.6600000000",
"bought_symbol": "WETH",
"bought_token": "0x4200000000000000000000000000000000000006",
"sold_amount": "5000.0000000000",
"sold_symbol": "USDC",
"sold_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"transaction_hash": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890"
}
],
"market_id": "0x8793cf302b8ffd655ab97bd1c695dbd967807e8367a65cb2f4edaf1380ba1bda",
"opened_at": "2025-01-15T10:30:00Z",
"protocol": "MORPHO",
"status": "OPEN",
"totals": {
"liquidation_count": 0,
"loop_tx_count": 1,
"total_collateral_added": "3.0000000000",
"total_collateral_removed": "0.0000000000",
"total_debt_added": "5000.0000000000",
"total_debt_removed": "0.0000000000",
"unwind_tx_count": 0
}
}
],
"aave_account_summary": {
"health_factor": "<string>",
"total_collateral_usd": "<string>",
"total_debt_usd": "<string>",
"available_borrows_usd": "<string>",
"ltv": "<string>",
"protocol": "AAVE",
"sub_account_id": 123,
"emode_category_id": 0,
"emode_label": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}List looped (leveraged) credit positions
List looped (leveraged) positions for a credit account owner.
Detects loops from the account’s on-chain history: a transaction containing lending + borrowing + swap legs is a loop transaction. Returns one position per Morpho market / Aave collateral+debt reserve pair, each with its complete per-transaction history, lifetime totals, and live on-chain state (health factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho Blue.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_looped_positions(chain=models.V2CreditLoopedPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.credit.creditLoopedPositions({
chain: "base",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/credit/looped_positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/credit/looped_positions', 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.compasslabs.ai/v2/credit/looped_positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/credit/looped_positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/credit/looped_positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/looped_positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"credit_account_address": "<string>",
"positions": [
{
"collateral_symbol": "WETH",
"collateral_token": "0x4200000000000000000000000000000000000006",
"current": {
"borrow_apy": "3.8400000000",
"collateral_amount": "3.0000000000",
"collateral_lending_apy": "0.0000000000",
"collateral_usd": "9000.0000000000",
"debt_amount": "5000.0000000000",
"debt_usd": "5000.0000000000",
"health_factor": "1.5480000000",
"health_factor_scope": "market",
"leverage": "2.2500000000",
"net_usd_value": "4000.0000000000"
},
"debt_symbol": "USDC",
"debt_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"history": [
{
"block_number": 25000000,
"block_timestamp": "2025-01-15T10:30:00Z",
"classification": "loop_open",
"collateral_delta": "3.0000000000",
"debt_delta": "5000.0000000000",
"events": [],
"iterations": 2,
"swap": {
"bought_amount": "1.6600000000",
"bought_symbol": "WETH",
"bought_token": "0x4200000000000000000000000000000000000006",
"sold_amount": "5000.0000000000",
"sold_symbol": "USDC",
"sold_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"transaction_hash": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890"
}
],
"market_id": "0x8793cf302b8ffd655ab97bd1c695dbd967807e8367a65cb2f4edaf1380ba1bda",
"opened_at": "2025-01-15T10:30:00Z",
"protocol": "MORPHO",
"status": "OPEN",
"totals": {
"liquidation_count": 0,
"loop_tx_count": 1,
"total_collateral_added": "3.0000000000",
"total_collateral_removed": "0.0000000000",
"total_debt_added": "5000.0000000000",
"total_debt_removed": "0.0000000000",
"unwind_tx_count": 0
}
}
],
"aave_account_summary": {
"health_factor": "<string>",
"total_collateral_usd": "<string>",
"total_debt_usd": "<string>",
"available_borrows_usd": "<string>",
"ltv": "<string>",
"protocol": "AAVE",
"sub_account_id": 123,
"emode_category_id": 0,
"emode_label": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
arbitrum, base, bsc, ethereum, hyperevm, tempo The address of the owner of the credit account to get looped positions for.
Response
Successful Response
Looped positions across Aave V3 and Morpho Blue for a credit account.
The credit product account address derived from the owner.
All looped positions, on both Aave and Morpho.
Show child attributes
Show child attributes
[
{
"collateral_symbol": "WETH",
"collateral_token": "0x4200000000000000000000000000000000000006",
"current": {
"borrow_apy": "3.8400000000",
"collateral_amount": "3.0000000000",
"collateral_lending_apy": "0.0000000000",
"collateral_usd": "9000.0000000000",
"debt_amount": "5000.0000000000",
"debt_usd": "5000.0000000000",
"health_factor": "1.5480000000",
"health_factor_scope": "market",
"leverage": "2.2500000000",
"net_usd_value": "4000.0000000000"
},
"debt_symbol": "USDC",
"debt_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"history": [
{
"block_number": 25000000,
"block_timestamp": "2025-01-15T10:30:00Z",
"classification": "loop_open",
"collateral_delta": "3.0000000000",
"debt_delta": "5000.0000000000",
"events": [],
"iterations": 2,
"swap": {
"bought_amount": "1.6600000000",
"bought_symbol": "WETH",
"bought_token": "0x4200000000000000000000000000000000000006",
"sold_amount": "5000.0000000000",
"sold_symbol": "USDC",
"sold_token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"transaction_hash": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890"
}
],
"market_id": "0x8793cf302b8ffd655ab97bd1c695dbd967807e8367a65cb2f4edaf1380ba1bda",
"opened_at": "2025-01-15T10:30:00Z",
"protocol": "MORPHO",
"status": "OPEN",
"totals": {
"liquidation_count": 0,
"loop_tx_count": 1,
"total_collateral_added": "3.0000000000",
"total_collateral_removed": "0.0000000000",
"total_debt_added": "5000.0000000000",
"total_debt_removed": "0.0000000000",
"unwind_tx_count": 0
}
}
]
Aave account-level summary (health factor, LTV, borrow capacity). Present when the account holds any open Aave looped position, since Aave collateral is pooled and health is account-level. Null for Morpho-only accounts.
Show child attributes
Show child attributes
Was this page helpful?