# API

## Get all pools

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/pools`

This endpoint allows you to get all pools.

#### Path Parameters

| Name    | Type   | Description                                                                                                                                                                                       |
| ------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| network | string | <p><strong>network name</strong><br>"main" - Ethereum mainnet<br>"rinkeby" - Ethereum Rinkeby testnet<br>"bsc-main" - Binance Smart Chain mainnet<br>"bsc-test"  -Binance Smart Chain testnet</p> |

{% tabs %}
{% tab title="200 " %}

```
{
	"total": 16,
	"items": [
		{
			"address": "0x24B6F00a2b5652cB81ea5B9fb5358cd759107145",
			"decimals": 18,
			"totalBorrows": "2037607438259529965606683",
			"totalBorrowsUSD": "180787.041676482",
			"totalSupply": "299244028086948488135433248",
			"totalSupplyUSD": "541808.546311476",
			"exchangeRate": "20405754202561353",
			"depositApy": "10.045329",
			"borrowApy": "36.381577",
			"totalReserves": "9312295796471308574953",
			"totalReservesUSD": "826.2349148287433737379172396510455474481",
			"availableLiquidity": "4078004941263578081935774",
			"availableLiquidityUSD": "361821.6322759919151421248277653098754784398",
			"reserveFactor": "100000000000000000",
			"collateralFactor": "50",
			"utilizationRate": "0.34267243319999685662",
			"baseRatePerBlock": "9512937595",
			"multiplierPerBlock": "404299847792",
			"lastUpdate": "2021-04-08T12:02:50.759Z",
			"token": {
				"address": "0x607C794cDa77efB21F8848B7910ecf27451Ae842",
				"name": "DeFiPIE Token",
				"symbol": "PIE",
				"decimal": 18,
				"imageUrl": null,
				"price": 0.000042818955594137,
				"priceUsd": 0.08872515788661128
			}
		}
	]
}
```

{% endtab %}
{% endtabs %}

## Get token list

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/tokens`

Whitelist of approved tokens

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |

{% tabs %}
{% tab title="200 " %}

```
{
	"total": 19,
	"items": [
		{
			"address": "0x607C794cDa77efB21F8848B7910ecf27451Ae842",
			"name": "DeFiPIE Token",
			"symbol": "PIE",
			"decimal": 18,
			"imageUrl": null,
			"price": 0.000042818955594137,
			"priceUsd": 0.08872515788661128
		}
	]
}
```

{% endtab %}
{% endtabs %}

## Get account balances

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/user-balance/:address`

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |
| address | string | user address |

{% tabs %}
{% tab title="200 User balance for each pool" %}

```
{
	"0x82aa580e4dDE8e750363962d057feA6FFb138b57": {
		"borrow": "0",
		"borrowUsd": "0",
		"supply": "80960396240176966434491",
		"supplyUsd": "289357.9910293859810594",
		"supplyCollateralUsd": "143084.3605688388897536",
		"supplyPToken": "4041415119023511235139946",
		"isCollateral": true,
		"lastUpdate": "2021-04-08T16:44:45.004Z",
		"exchangeRate": "20032685051106222",
		"exchangeRateCalc": "0.020032685051106222"
	},
	"0xb91B6e944F7d0c8FC96F57D4d44bc9aa818b4571": {
		"borrow": "602427793471258409940",
		"borrowUsd": "388736.1602275576127511",
		"supply": "826859509950256977664",
		"supplyUsd": "543253.9320154421822597",
		"supplyCollateralUsd": "268633.1253871655601664",
		"supplyPToken": "36052860343814206996919",
		"isCollateral": true,
		"lastUpdate": "2021-04-08T16:44:45.004Z",
		"exchangeRate": "22934643799826161",
		"exchangeRateCalc": "0.022934643799826161"
	},
}
```

{% endtab %}
{% endtabs %}

## Get user history

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/history?address=:address`

Get all user transactions

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |

#### Query Parameters

| Name    | Type   | Description    |
| ------- | ------ | -------------- |
| address | string | user address   |
| limit   | number | limit for list |
| offset  | number | offset in list |

{% tabs %}
{% tab title="200 " %}

```
{
	"total": 382,
	"data": [
		{
			"blockNumber": 8355665,
			"address": "0x82aa580e4dde8e750363962d057fea6ffb138b57",
			"userAddress": "0x3d6fdba796859f04cf5446ae25b243b35a2e775b",
			"eventName": "Mint",
			"txHash": "0x8b46943e379c108c88e7c988da5172b134cefb6cfe0ccd29d3fac040406ed1eb",
			"returnValues": {
				"0": "0x3d6FDba796859f04CF5446Ae25b243b35a2e775b",
				"1": "100000000000000000000",
				"2": "4991842067411937975839",
				"minter": "0x3d6FDba796859f04CF5446Ae25b243b35a2e775b",
				"mintAmount": "100000000000000000000",
				"mintTokens": "4991842067411937975839"
			},
			"blockTimestamp": "2021-04-04T20:36:41.000Z",
			"assetSymbol": "PIE",
			"assetName": "DeFiPIE Token",
			"assetDecimal": 18
		},
	]
}
```

{% endtab %}
{% endtabs %}

## Pool statistic

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/statistic?address=:address`

Get pool statistics for the previous 30 days

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |

#### Query Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| address | string | user address |

{% tabs %}
{% tab title="200 " %}

```
[
	{
		"borrowApy": "26.4737597777009377",
		"supplyApy": "5.5089582891273637",
		"utilizationRate": "25.36302313",
		"date": "2021-03-09"
	},
	{
		"borrowApy": "26.6462295725894405",
		"supplyApy": "5.5781096129651988",
		"utilizationRate": "25.52377269",
		"date": "2021-03-10"
	},
	{
		"borrowApy": "26.6102001139841173",
		"supplyApy": "5.5638203632713323",
		"utilizationRate": "25.49009850",
		"date": "2021-03-11"
	},
	{
		"borrowApy": "26.0076370578130007",
		"supplyApy": "5.3246193587260127",
		"utilizationRate": "24.92705876",
		"date": "2021-03-12"
	}
]
```

{% endtab %}
{% endtabs %}

## Get user distribution rewards

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/distribution`

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |

{% tabs %}
{% tab title="200 " %}

```
{
	"calculateTimestamp": "2021-04-08T17:25:37.341Z",
	"pieSpeed": "700000000000000000",
	"distributionSize": "9198.47908745247148288973",
	"totalDistributed": "523549439204328237475616",
	"items": [
		{
			"assetName": "DeFiPIE Token",
			"assetSymbol": "PIE",
			"assetPrice": "0.000042818955594137",
			"calcAssetPrice": "0.000042818955594137",
			"assetPriceUSD": "0.08852592878340269321644733",
			"address": "0x24B6F00a2b5652cB81ea5B9fb5358cd759107145",
			"underlyingAddress": "0x607C794cDa77efB21F8848B7910ecf27451Ae842",
			"underlyingDecimal": 18,
			"utility": "12917566122572762027377232253706.1533000546654680520008429556413254944",
			"pieSpeed": "440987180950584240",
			"exchangeRate": "20405754202561353",
			"totalBorrows": "2037607438259530130844460",
			"totalSupply": "291399430004861028043191863",
			"piePerDay": "2897.43668700612002555133",
			"pieBorrowApy": "67.98",
			"pieSupplyApy": "19.46",
			"piePriceCalc": "1",
			"distributedSupplierPie": "347442791638687481613428",
			"distributedBorrowerPie": "97260271645636299251213",
			"borrowRatePerBlock": "148055350180.27301662680006885872"
		},
	]
}
```

{% endtab %}
{% endtabs %}

## Get underwater account

<mark style="color:blue;">`GET`</mark> `https://api.defipie.com/:network/underwater`

Get accounts to be liquidated

#### Path Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| network | string | network name |

{% tabs %}
{% tab title="200 " %}

```
[
	{
		"borrowerAddress": "0x9029b8907dea021414eda6325e3b9ed9ba7fe1ec",
		"totalBorrowUsd": 1333.0038913466049,
		"totalCollateralUsd": 1271.6930384329,
		"healthFactor": 0.9540054959241204,
		"borrows": [
			{
				"address": "0xd8bf76686f818d5cb0ffcfa67f68aff8b69dc2dc",
				"symbol": "DAI",
				"tokenName": "DeFiPie Dai Stablecoin",
				"decimal": 18,
				"price": "0.000502114877857198",
				"usdPrice": "1.03809598579652439752279782",
				"usd": "1333.0038913466047542",
				"amount": "1284085389897967780738",
				"currentBorrow": "1284085389897967780738",
				"collaterals": [
					{
						"address": "0x24b6f00a2b5652cb81ea5b9fb5358cd759107145",
						"symbol": "pPIE",
						"tokenName": "DeFiPie PIE",
						"decimal": 18,
						"usd": "1271.6930384329",
						"amount": "1456245763992188540477438",
						"price": "0.000042818955594137",
						"usdPrice": "0.08852592878340269321644733",
						"exchangeRate": "0.020405754202561353"
					}
				]
			}
		]
	}
]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.defipie.com/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
