# API Reference

## API Reference

***

### Overview

The Bondify API provides programmatic access to all protocol data including CBR pools, SLF metrics, and Looper positions. All endpoints return JSON responses with consistent error handling.

**Base URL**: <https://bondify.cian.app/>

***

### CBR Pools List

**Endpoint:**

```
GET /cbr/list
```

**Description:** Retrieves information for all CBR pools. Data can be obtained from both API and smart contracts.

* **API**: `${BASE}/cbr/list` returns complete information
* **Smart Contracts**:
  * `CBR::collateralTokens()` - Get allowed deposit token types
  * `CBR::supplies()` - Get current pool information

**Example Request:**

```bash
curl -X GET "${BASE}/cbr/list"
```

**Response Fields:**

* **name**: Pool name
* **id**: Pool identifier
* **order\_weight**: Sorting weight (higher values appear first)
* **collateral**: Collateral asset information
  * **name**: Collateral asset name
  * **address**: Smart contract address
  * **oracle**: Oracle contract address
  * **price**: Current asset price
* **risk**: Risk thresholds
  * **low\_bar**: Risk low threshold (e.g., 0.5 = 50%)
  * **mid\_bar**: Risk medium threshold
  * **high\_bar**: Risk high threshold
* **yt**: Yield Token information
  * **presents**: Whether YT is available (if false, other fields return 0)
  * **earn**: Annual yield rate
  * **cost\_down**: Cost reduction rate
  * **extra\_earn**: Additional yield rate
  * **points\_mul**: Points multiplier
  * **leverage**: Leverage ratio
* **looper**: Looper strategy information
  * **presents**: Whether Looper is available (if false, other fields return 0)
  * **earn**: Annual yield rate
  * **earn\_target**: Target annual yield rate
  * **earn\_increase**: Yield rate increase
  * **stability\_fee**: Stability fee rate
  * **max\_leverage**: Maximum leverage ratio
* **ltv**: Loan-to-Value ratio
* **liq\_ltv**: Liquidation LTV
* **liq\_limit**: Liquidation ratio limit
* **liq\_penalty**: Liquidation penalty
* **apr**: Annual percentage rate
* **supplied**: Current supply amount (in collateral units, before decimal adjustment)
* **borrowed**: Current borrowed amount (in debt asset units, before decimal adjustment)
* **liquidity**: Remaining borrowable amount
* **protocol**: Associated protocols
* **tag**: Pool tags
* **display**: Whether to display pool
* **paused**: Whether pool is paused

**Example Response:**

```json
{
  "status": 0,
  "code": "ok",
  "msg": "ok",
  "data": [
    {
      "name": "SA/CCR",
      "id": 0,
      "order_weight": 0,
      "collateral": {
        "name": "SA",
        "address": "0x1234567890abcdef1234567890abcdef12345678",
        "oracle": "0x07ac1e01234567890abcdef1234567890abcdef1",
        "price": "1.0"
      },
      "risk": {
        "low_bar": 0.5,
        "mid_bar": 0.7,
        "high_bar": 0.8
      },
      "yt": {
        "presents": true,
        "earn": 0.11,
        "cost_down": 0.01,
        "extra_earn": 0.01,
        "points_mul": 11.0,
        "leverage": 11.0
      },
      "looper": {
        "presents": true,
        "earn": 0.05,
        "earn_target": 0.06,
        "earn_increase": 0.01,
        "stability_fee": 0.05,
        "max_leverage": 5
      },
      "ltv": 0.9,
      "liq_ltv": 0.95,
      "liq_limit": 0.5,
      "liq_penalty": 0.1,
      "apr": 0.05,
      "supplied": 400000000,
      "borrowed": 200000000,
      "liquidity": 100000000,
      "protocol": "a,b,c",
      "tag": "a,b,c",
      "display": true,
      "paused": false
    }
  ]
}
```

***

### SLF Overview

**Endpoint:**

```
GET /slf/overview
```

**Description:** Retrieves SLF overview including deposits, risk management, yield rates, allocation status, and operation history.

**Example Request:**

```bash
curl -X GET "${BASE}/slf/overview"
```

**Response Fields:**

* **total\_deposit**: Total deposits in USDC (before decimal adjustment)
* **total\_deposit\_history**: Historical deposit records
  * **time**: Timestamp
  * **amount**: Deposit amount in USDC (before decimal adjustment)
* **risk**: Risk management information
  * **rebalancer**: Risk rebalancer contract address
  * **owner**: Risk owner address
  * **deployed**: Deployment timestamp
  * **timelock**: Timelock period
  * **guardian**: Guardian address
* **apy**: Annual percentage yield
* **apy\_history**: Historical yield records
  * **time**: Timestamp
  * **apy**: Annual percentage yield
* **alloc\_peek**: Current allocation status
  * **market**: Market name
  * **market\_type**: Market type (YT or looper)
  * **market\_id**: Market identifier
  * **ccr\_amount**: CCR amount (before decimal adjustment)
  * **token\_amount**: Token amount in USDC (before decimal adjustment)
  * **deadline**: Expiration time (0 for looper)
* **alloc\_history**: Historical allocation records
  * **time**: Timestamp
  * **SA/SB/SC**: Allocation percentages for each market
* **operation\_history**: Operation history
  * **time**: Operation timestamp
  * **operation**: Operation type (deposit, withdraw)
  * **shares**: Operation shares
  * **amount**: Operation amount in USDC (before decimal adjustment)
  * **principal\_after**: Remaining principal after operation in USDC (before decimal adjustment)
  * **operator**: Operator address
* **repayment\_time**: Repayment information
  * **time**: Repayment timestamp
  * **amount**: Repayment amount

**Example Response:**

```json
{
  "status": 0,
  "code": "ok",
  "msg": "ok",
  "data": {
    "total_deposit": 1000000000,
    "total_deposit_history": [
      {
        "time": 17333333333,
        "amount": 1000000000
      }
    ],
    "risk": {
      "rebalancer": "0x1234567890abcdef1234567890abcdef12345678",
      "owner": "0xabcdef1234567890abcdef1234567890abcdef12",
      "deployed": 1752210685,
      "timelock": 86400,
      "guardian": "0xabcdef1234567890abcdef1234567890abcdef12"
    },
    "apy": 0.0812,
    "apy_history": [
      {
        "time": 17333333333,
        "apy": 0.0812
      }
    ],
    "alloc_peek": [
      {
        "market": "SA",
        "market_type": "YT",
        "market_id": 0,
        "ccr_amount": 1000000000,
        "token_amount": 1000000,
        "deadline": 1752210785
      }
    ],
    "alloc_history": [
      {
        "time": 1752210785,
        "SA": 0.31,
        "SB": 0.4,
        "SC": 0.29
      }
    ],
    "operation_history": [
      {
        "time": "17333333333",
        "operation": "deposit",
        "shares": 100000,
        "amount": 100010,
        "principal_after": 1000000,
        "operator": "0xabcdef1234567890abcdef1234567890abcdef12"
      }
    ],
    "repayment_time": [
      {
        "time": 1752210785,
        "amount": 100000000
      }
    ]
  }
}
```

***

### SLF User Information

**Endpoint:**

```
GET /slf/address/{address}
```

**Description:** Retrieves specific user's principal, shares, and operation records in SLF.

**Smart Contract Calls:**

* `SLF(SSF)::tokenProviderShares(address _liquidityToken, address _provider)`
  * First parameter: USDC address, Second parameter: User address
* `SLF(SSF)::tokenProviders(address)`
  * Get share to USDC conversion rate (parameter: USDC address)

**Example Request:**

```bash
curl -X GET "${BASE}/slf/address/0xabcdef1234567890abcdef1234567890abcdef12"
```

**Response Fields:**

* **user**: User address
* **current\_deposit**: Current remaining principal in USDC (before decimal adjustment)
* **current\_shares**: Current remaining shares
* **current\_value**: Current value in USDC (before decimal adjustment)
* **operations**: User operation records
  * **time**: Operation timestamp
  * **operation**: Operation type (deposit, withdraw)
  * **shares**: Operation shares
  * **amount**: Operation amount in USDC (before decimal adjustment)
  * **principal\_after**: Remaining principal after operation in USDC (before decimal adjustment)
  * **operator**: Operator address

**Example Response:**

```json
{
  "status": 0,
  "code": "ok",
  "msg": "ok",
  "data": {
    "user": "0xabcdef",
    "current_deposit": 1000000,
    "current_shares": 999987,
    "current_value": 1000100,
    "operations": [
      {
        "time": "17333333333",
        "operation": "deposit",
        "shares": 100000,
        "amount": 100010,
        "principal_after": 1000000,
        "operator": "0xabcdef1234567890abcdef1234567890abcdef12"
      }
    ]
  }
}
```

***

### Looper Overview

**Endpoint:**

```
GET /looper/overview
```

**Description:** Retrieves overview of all Looper pools including base tokens, leverage tokens, prices, yield rates, and leverage limits.

**Example Request:**

```bash
curl -X GET "${BASE}/looper/overview"
```

**Response Fields:**

* **id**: Pool identifier
* **order\_weight**: Sorting weight (higher values appear first)
* **name**: Pool name
* **tag**: Pool tags
* **protocol**: Protocol information
* **oracle**: Oracle contract address
* **helper**: Helper contract address
* **deposit\_token**: Deposit token address
* **leverage\_token**: Leverage token address
* **deposit\_price**: Deposit token price
* **withdraw\_price**: Withdrawal token price
* **earn\_apy**: Earning annual percentage yield
* **borrow\_apy**: Borrowing annual percentage yield
* **stability\_fee**: Stability fee rate
* **cost\_down**: Cost reduction rate
* **extra\_earn**: Additional earning rate
* **max\_leverage**: Maximum leverage ratio
* **max\_amount**: Maximum deposit amount
* **max\_points**: Maximum points reward multiplier

**Example Response:**

```json
{
  "status": 0,
  "code": "ok",
  "msg": "ok",
  "data": [
    {
      "id": 0,
      "order_weight": 0,
      "name": "SLA/ETH",
      "tag": "a,b,c",
      "protocol": "a,b,c",
      "oracle": "0x1234567890abcdef1234567890abcdef12345678",
      "helper": "0x77777",
      "deposit_token": "0xaaaaa",
      "leverage_token": "0xbbbbb",
      "deposit_price": 1.0,
      "withdraw_price": 2335.0,
      "earn_apy": 0.133,
      "borrow_apy": 0.15,
      "stability_fee": 0.01,
      "cost_down": 0.01,
      "extra_earn": 0.01,
      "max_leverage": 2,
      "max_amount": 11.11,
      "max_points": 11
    }
  ]
}
```

***

### Looper Pool Details

**Endpoint:**

```
GET /looper/detail/{id}
```

**Description:** Retrieves detailed information for a specific Looper pool including tokens, prices, leverage, risk parameters, historical operations, and yield records.

**Example Request:**

```bash
curl -X GET "${BASE}/looper/detail/0"
```

**Response Fields:**

* **id**: Pool identifier
* **order\_weight**: Sorting weight (higher values appear first)
* **name**: Pool name (e.g., SLA/ETH)
* **tag**: Pool tags
* **protocol**: Protocol information
* **oracle**: Oracle contract address
* **helper**: Helper contract address
* **deposit\_token**: Deposit token address
* **leverage\_token**: Leverage token address
* **deposit\_price**: Deposit token price
* **withdraw\_price**: Withdrawal token price
* **earn\_apy**: Earning annual percentage yield
* **borrow\_apy**: Borrowing annual percentage yield
* **stability\_fee**: Stability fee rate
* **cost\_down**: Cost reduction rate
* **extra\_earn**: Additional earning rate
* **max\_leverage**: Maximum leverage ratio
* **liquidation\_ltv**: Liquidation LTV threshold
* **max\_amount**: Maximum deposit amount
* **max\_points**: Maximum points reward multiplier
* **min\_deposit**: Minimum deposit amount (in token units)
* **utilization**: Utilization rate parameters
  * **current**: Current utilization rate
  * **min**: Minimum utilization rate
  * **target**: Target utilization rate
  * **max**: Maximum utilization rate
  * **fee\_at\_min**: Fee rate at minimum utilization
  * **fee\_at\_target**: Fee rate at target utilization
  * **fee\_at\_max**: Fee rate at maximum utilization
* **risk\_level**: Risk level parameters
  * **low\_bar**: Risk low threshold (50%)
  * **mid\_bar**: Risk medium threshold (70%)
  * **high\_bar**: Risk high threshold (80%)
* **history**: Historical operation records
  * **user**: User address
  * **deposit\_amount**: Deposit amount (with decimals; 0 for repay/prepare\_withdraw, negative for liquidate/withdraw)
  * **leverage\_amount**: Leverage amount (with decimals; 0 for prepare\_withdraw, negative for non-deposit operations indicating repayment/deleveraging)
  * **type**: Operation type (deposit, repay, withdraw, prepare\_withdraw, liquidate)
* **apy\_history**: Historical yield records
  * **time**: Timestamp
  * **max\_lev**: Maximum leverage ratio
  * **underlying\_apy**: Underlying asset annual percentage yield
  * **fee\_apy**: Fee annual percentage yield
