📗API

For a more comprehensive protocol support and enhanced position and market information, we recommend using the Lending SDK.

GitHub

https://github.com/dinngo/compound-kit-api

API Server

https://compound-kit-api.protocolink.com

Swagger Docs

https://compound-kit-api.protocolink.com/docs

Returns the current version of the API

GEThttps://compound-kit-api.protocolink.com/status
Response

OK

Body
versionstring
Example: "0.1.3"
Request
const response = await fetch('https://compound-kit-api.protocolink.com/status', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "version": "0.1.3"
}

List multi-chain markets

GEThttps://compound-kit-api.protocolink.com/v1/markets
Response

OK

Body
marketGroupsarray of object
Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "marketGroups": [
    {
      "chainId": 137,
      "markets": [
        {
          "id": "USDC",
          "label": "USDC"
        }
      ]
    }
  ]
}

Get market information and position for an optional account

GEThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Query parameters
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}', {
    method: 'GET',
    headers: {},
});
const data = await response.json();

Get the estimated post-leverage position

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/leverage
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
collateralTokenTokenWETH (object)
collateralAmountstring
Example: "1"
slippageinteger
Example: 100
Response

OK

Body
quotationobject
approvalsarray of object
logicsLeverageLogicsResponse (array of one of)
Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/leverage', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();
Response
{
  "quotation": {
    "leverageTimes": "0.07",
    "currentPosition": {
      "utilization": "0.6662",
      "healthRate": "1.6",
      "liquidationThreshold": "0.7964",
      "supplyUSD": "0",
      "borrowUSD": "17547.09",
      "collateralUSD": "35288.32",
      "netAPR": "-0.0474"
    },
    "targetPosition": {
      "utilization": "0.6976",
      "healthRate": "1.53",
      "liquidationThreshold": "0.7978",
      "supplyUSD": "0",
      "borrowUSD": "19346.22",
      "collateralUSD": "37086.19",
      "netAPR": "-0.0522"
    }
  },
  "approvals": [
    {
      "to": "0xF25212E676D1F7F89Cd72fFEe66158f541246445",
      "data": "0x110496e500000000000000000000000081229cb3ab2a23a8532755ae2f7a95b01e83d6c50000000000000000000000000000000000000000000000000000000000000001"
    }
  ],
  "logics": [
    {
      "rid": "utility:flash-loan-aggregator",
      "fields": {
        "id": "2477f2c1-7c6a-47f9-8b46-b9faf2ff3bec",
        "protocolId": "balancer-v2",
        "loans": [
          {
            "token": {
              "chainId": 137,
              "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
              "decimals": 6,
              "symbol": "USDC",
              "name": "USD Coin"
            },
            "amount": "1799.454935"
          }
        ],
        "isLoan": true
      }
    }
  ]
}

Get the estimated post-deleverage position

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/deleverage
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
collateralTokenTokenWETH (object)
baseAmountstring
Example: "1000"
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/deleverage', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

Get the estimated post-collateral-swap position

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/collateral-swap
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
srcTokenTokenWETH (object)
srcAmountstring
Example: "1"
destTokenTokenMATIC (object)
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/collateral-swap', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

List supported tokens for zaps

GEThttps://compound-kit-api.protocolink.com/v1/{chainId}/zap-tokens
Path parameters
chainId*integer

Example: 137

Example: 137
Response

OK

Body
tokensarray of TokenUSDC (object)
Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/{chainId}/zap-tokens', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "tokens": [
    {
      "chainId": 137,
      "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
      "decimals": 6,
      "symbol": "USDC",
      "name": "USD Coin"
    }
  ]
}

Get the estimated post-zap-supply

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-supply
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Query parameters
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
srcTokenTokenMATIC (object)
srcAmountstring
Example: "10"
destTokenTokenWETH (object)
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-supply', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

Get the estimated post-zap-withdraw

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-withdraw
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Query parameters
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
srcTokenTokenWETH (object)
srcAmountstring
Example: "1"
destTokenTokenMATIC (object)
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-withdraw', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

Get the estimated post-zap-repay

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-repay
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Query parameters
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
srcTokenTokenMATIC (object)
srcAmountstring
Example: "10"
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-repay', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

Get the estimated post-zap-borrow

POSThttps://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-borrow
Path parameters
chainId*integer

Example: 137

Example: 137
marketId*string

Example: usdc

Example: "usdc"
Body
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
srcAmountstring
Example: "100"
destTokenTokenMATIC (object)
slippageinteger
Example: 100
Response

OK

Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/markets/{chainId}/{marketId}/zap-borrow', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
    }),
});
const data = await response.json();

Get transaction data

POSThttps://compound-kit-api.protocolink.com/v1/transactions/build
Body
chainId*integer
Example: 137
account*string
Example: "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF"
logics*LeverageLogicsResponse (array of one of)
permitDataPermitData (object)
permitSigstring
Example: "0x00"
Response

OK

Body
tostring
Example: "0xf4dEf6B4389eAb49dF2a7D67890810e5249B5E70"
datastring
Example: "0x..."
valuestring
Example: "0"
Request
const response = await fetch('https://compound-kit-api.protocolink.com/v1/transactions/build', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "chainId": 137,
      "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
      "logics": [
        {}
      ]
    }),
});
const data = await response.json();
Response
{
  "to": "0xf4dEf6B4389eAb49dF2a7D67890810e5249B5E70",
  "data": "0x...",
  "value": "0"
}

Last updated