🇺🇲
Protocolink
  • 🔮Overview
  • 🌟Why Protocolink?
  • 💡Use Cases
    • Flash Loans
    • Permit2 Amplifier
    • Zap-in & Zap-out
    • Position Management
    • Multi-Action Bundling
  • 📋Networks & Protocols
  • 🛡️Security & Audits
  • 💎Fees
  • ❓FAQ
  • Protocolink API
    • 🔮Overview
      • Swap & Supply (Example)
    • 📗Swagger
      • Request Protocols
      • Request Tokens
      • Request Quote
      • Estimate Logics Result
      • Request Transaction Data
  • Protocolink SDK
    • 🔮Overview
    • 1️⃣Install SDK
    • 2️⃣Build Logics
    • 3️⃣Estimate Router Data
    • 4️⃣Send Router Transaction
    • ⚒️API SDK Interfaces
      • Global Types
      • FlashLoan Logic
      • Aave V2
      • Aave V3
      • Balancer V2
      • Compound V3
      • Iolend
      • Magicsea
      • Morphoblue
      • OpenOcean V2
      • ParaSwap V5
      • Permit2
      • Spark
      • Stargate
      • Stargate V2
      • SyncSwap
      • Uniswap V3
      • Utility
      • Wagmi
      • ZeroEx V4
    • ⚒️Common SDK Interfaces
      • Constants
      • Network
      • Token
      • Web3Toolkit
      • Utility Functions
  • Lending SDK
    • 🔮Overview
    • ✳️SDK
      • Open By Collateral
      • Open By Debt
      • Close
      • Leverage By Collateral
      • Leverage By Debt
      • Deleverage
      • Collateral swap
      • Debt swap
      • Zap supply
      • Zap withdraw
      • Zap repay
      • Zap borrow
  • Smart Contract
    • 🔮Overview
      • Router
      • Agent
      • Callback
      • Fees
      • Utility
      • Data Type
      • ERC721/ERC1155 Support
    • 📑Deployment Addresses
    • 🧑‍💻Security Review Details
  • COMPOUND KIT
    • 🔮Overview
    • ✳️SDK
      • Leverage
      • Deleverage
      • Collateral Swap
      • Zap Supply
      • Zap Withdraw
      • Zap Repay
      • Zap Borrow
    • 📗API
  • Video Tutorials
    • 1. Introducing Protocolink
    • 2. Lending SDK
    • 3. Protocolink Q&A
  • Social medias
    • Twitter
  • Support
Powered by GitBook
On this page
  1. COMPOUND KIT

API

PreviousZap BorrowNextSupport

Last updated 4 months ago

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

GitHub

API Server

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

Swagger Docs

📗
https://github.com/dinngo/compound-kit-api
https://compound-kit-api.protocolink.com/docs

Returns the current version of the API

get
Responses
200
OK
application/json
get
GET /status HTTP/1.1
Host: compound-kit-api.protocolink.com
Accept: */*
200

OK

{
  "version": "0.1.3"
}

List multi-chain markets

get
Responses
200
OK
application/json
get
GET /v1/markets HTTP/1.1
Host: compound-kit-api.protocolink.com
Accept: */*
200

OK

{
  "marketGroups": [
    {
      "chainId": 137,
      "markets": [
        {
          "id": "USDC",
          "label": "USDC"
        }
      ]
    }
  ]
}

Get market information and position for an optional account

get
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Query parameters
accountstringOptional

Example: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF

Example: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
Responses
200
OK
get
GET /v1/markets/{chainId}/{marketId} HTTP/1.1
Host: compound-kit-api.protocolink.com
Accept: */*
200

OK

No content

List supported tokens for zaps

get
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
Responses
200
OK
application/json
get
GET /v1/{chainId}/zap-tokens HTTP/1.1
Host: compound-kit-api.protocolink.com
Accept: */*
200

OK

{
  "tokens": [
    {
      "chainId": 137,
      "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
      "decimals": 6,
      "symbol": "USDC",
      "name": "USD Coin"
    }
  ]
}
  • GitHub
  • API Server
  • Swagger Docs
  • GETReturns the current version of the API
  • GETList multi-chain markets
  • GETGet market information and position for an optional account
  • POSTGet the estimated post-leverage position
  • POSTGet the estimated post-deleverage position
  • POSTGet the estimated post-collateral-swap position
  • GETList supported tokens for zaps
  • POSTGet the estimated post-zap-supply
  • POSTGet the estimated post-zap-withdraw
  • POSTGet the estimated post-zap-repay
  • POSTGet the estimated post-zap-borrow
  • POSTGet transaction data

Get the estimated post-leverage position

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
collateralAmountstringOptionalExample: 1
slippageintegerOptionalExample: 100
Responses
200
OK
application/json
post
POST /v1/markets/{chainId}/{marketId}/leverage HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 236

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "collateralToken": {
    "chainId": 137,
    "address": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "decimals": 18,
    "symbol": "WETH",
    "name": "Wrapped Ether"
  },
  "collateralAmount": "1",
  "slippage": 100
}
200

OK

{
  "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

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
baseAmountstringOptionalExample: 1000
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/deleverage HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 233

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "collateralToken": {
    "chainId": 137,
    "address": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "decimals": 18,
    "symbol": "WETH",
    "name": "Wrapped Ether"
  },
  "baseAmount": "1000",
  "slippage": 100
}
200

OK

No content

Get the estimated post-collateral-swap position

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
srcAmountstringOptionalExample: 1
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/collateral-swap HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 357

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "srcToken": {
    "chainId": 137,
    "address": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "decimals": 18,
    "symbol": "WETH",
    "name": "Wrapped Ether"
  },
  "srcAmount": "1",
  "destToken": {
    "chainId": 137,
    "address": "0x0000000000000000000000000000000000001010",
    "decimals": 18,
    "symbol": "MATIC",
    "name": "Matic Token"
  },
  "slippage": 100
}
200

OK

No content

Get the estimated post-zap-supply

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Query parameters
permit2TypestringOptional

Example: permit, approve

Example: permit
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
srcAmountstringOptionalExample: 10
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/zap-supply HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 358

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "srcToken": {
    "chainId": 137,
    "address": "0x0000000000000000000000000000000000001010",
    "decimals": 18,
    "symbol": "MATIC",
    "name": "Matic Token"
  },
  "srcAmount": "10",
  "destToken": {
    "chainId": 137,
    "address": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "decimals": 18,
    "symbol": "WETH",
    "name": "Wrapped Ether"
  },
  "slippage": 100
}
200

OK

No content

Get the estimated post-zap-withdraw

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Query parameters
permit2TypestringOptional

Example: permit, approve

Example: permit
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
srcAmountstringOptionalExample: 1
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/zap-withdraw HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 357

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "srcToken": {
    "chainId": 137,
    "address": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
    "decimals": 18,
    "symbol": "WETH",
    "name": "Wrapped Ether"
  },
  "srcAmount": "1",
  "destToken": {
    "chainId": 137,
    "address": "0x0000000000000000000000000000000000001010",
    "decimals": 18,
    "symbol": "MATIC",
    "name": "Matic Token"
  },
  "slippage": 100
}
200

OK

No content

Get the estimated post-zap-repay

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Query parameters
permit2TypestringOptional

Example: permit, approve

Example: permit
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
srcAmountstringOptionalExample: 10
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/zap-repay HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 222

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "srcToken": {
    "chainId": 137,
    "address": "0x0000000000000000000000000000000000001010",
    "decimals": 18,
    "symbol": "MATIC",
    "name": "Matic Token"
  },
  "srcAmount": "10",
  "slippage": 100
}
200

OK

No content

Get the estimated post-zap-borrow

post
Path parameters
chainIdintegerRequired

Example: 137

Example: 137
marketIdstringRequired

Example: usdc

Example: usdc
Body
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
srcAmountstringOptionalExample: 100
slippageintegerOptionalExample: 100
Responses
200
OK
post
POST /v1/markets/{chainId}/{marketId}/zap-borrow HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 224

{
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "srcAmount": "100",
  "destToken": {
    "chainId": 137,
    "address": "0x0000000000000000000000000000000000001010",
    "decimals": 18,
    "symbol": "MATIC",
    "name": "Matic Token"
  },
  "slippage": 100
}
200

OK

No content

Get transaction data

post
Body
chainIdintegerRequiredExample: 137
accountstringRequiredExample: 0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF
permitSigstringOptionalExample: 0x00
Responses
200
OK
application/json
post
POST /v1/transactions/build HTTP/1.1
Host: compound-kit-api.protocolink.com
Content-Type: application/json
Accept: */*
Content-Length: 1124

{
  "chainId": 137,
  "account": "0x0FBeABcaFCf817d47E10a7bCFC15ba194dbD4EEF",
  "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
      }
    }
  ],
  "permitData": {
    "domain": {
      "name": "Permit2",
      "chainId": 42161,
      "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3"
    },
    "types": {
      "PermitSingle": [
        {
          "name": "details",
          "type": "PermitDetails"
        },
        {
          "name": "spender",
          "type": "address"
        },
        {
          "name": "sigDeadline",
          "type": "uint256"
        }
      ],
      "PermitDetails": [
        {
          "name": "token",
          "type": "address"
        },
        {
          "name": "amount",
          "type": "uint160"
        },
        {
          "name": "expiration",
          "type": "uint48"
        },
        {
          "name": "nonce",
          "type": "uint48"
        }
      ]
    },
    "values": {
      "details": {
        "token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "amount": "0xffffffffffffffffffffffffffffffffffffffff",
        "expiration": 1691892575,
        "nonce": 0
      },
      "spender": "0x2C0e22b8d5070cb2500628E0bf43925a5c7b1559",
      "sigDeadline": 1689302375
    }
  },
  "permitSig": "0x00",
  "referral": "0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB"
}
200

OK

{
  "to": "0xf4dEf6B4389eAb49dF2a7D67890810e5249B5E70",
  "data": "0x...",
  "value": "0"
}