{"openapi":"3.0.3","info":{"title":"Delta-Neutral API","description":"API for aggregating delta-neutral arbitrage opportunities via Teller.","version":"1.0.1","contact":{"name":"Teller Protocol"}},"servers":[{"url":"https://delta-neutral-api.teller.org","description":"Production server"},{"url":"http://localhost:3000","description":"Local development server"}],"paths":{"/perps/delta-neutral":{"get":{"summary":"Get Delta-Neutral Arbitrage Opportunities","description":"Returns the best delta-neutral arbitrage opportunities per (chainId, coin) pair.\n\nThis endpoint analyzes borrowing costs from Teller markets and compares them with \nnegative funding rates from perpetual exchanges (ie. Hyperliquid, Binance) to identify \nprofitable arbitrage opportunities.\n\nThe strategy involves:\n1. Borrowing the asset at a low APR from Teller\n2. Shorting the same asset on a perpetual exchange with negative funding rates\n3. Earning the funding rate while holding a delta-neutral position\n\nResults are cached for 2 minutes.\n","operationId":"getDeltaNeutralOpportunities","tags":["Perpetuals"],"responses":{"200":{"description":"Successfully retrieved delta-neutral opportunities","content":{"application/json":{"schema":{"type":"object","required":["ok","asOf","count","opportunities"],"properties":{"ok":{"type":"boolean","example":true,"description":"Indicates if the request was successful"},"asOf":{"type":"string","format":"date-time","example":"2025-12-12T10:30:00.000Z","description":"Timestamp when the data was generated"},"count":{"type":"integer","example":15,"description":"Number of opportunities returned"},"opportunities":{"type":"array","description":"Array of delta-neutral arbitrage opportunities, sorted by net APR (highest to lowest)","items":{"$ref":"#/components/schemas/DeltaNeutralOpportunity"}}}},"examples":{"success":{"summary":"Example response with opportunities","value":{"ok":true,"asOf":"2025-12-12T10:30:00.000Z","count":2,"opportunities":[{"chainId":42161,"coin":"ETH","poolAddress":"0x1234567890abcdef1234567890abcdef12345678","platformUrl":"https://app.hyperliquid.xyz/trade/ETH","platformLogo":"https://api.coins-rating.com/img/projects/12_06_23/648674b19d2c7.webp","fundingAprYearlyPct":-15.5,"fundingAprAbsPct":15.5,"borrowAprPct":8.2,"borrowFeePct":{"marketplaceFeePct":0.5,"protocolFeePct":0.05,"totalBorrowFeePct":0.55},"netAprPct":7.3,"principalAvailable":"50000000000000000000","principalAvailableUsd":150000.5,"allPlatforms":[{"platformUrl":"https://app.hyperliquid.xyz/trade/ETH","platformLogo":"https://api.coins-rating.com/img/projects/12_06_23/648674b19d2c7.webp","fundingAprYearlyPct":-15.5,"fundingAprAbsPct":15.5,"fundingRate8h":-0.0005,"fundingRateHourly":-0.000062,"oraclePx":3000.25,"openInterest":12500000},{"platformUrl":"https://www.binance.com/en/futures/ETH","platformLogo":"https://images.seeklogo.com/logo-png/32/1/binance-coin-bnb-logo-png_seeklogo-325081.png","fundingAprYearlyPct":-12.3,"fundingAprAbsPct":12.3,"fundingRate8h":-0.0004,"fundingRateHourly":-0.00005,"oraclePx":3000.1,"openInterest":45000000}],"raw":{"row":{"pool_address":"0x1234567890abcdef1234567890abcdef12345678","borrow_token_symbol":"ETH","chainId":42161,"active":true,"enrichment":{"marketplaceFeePercent":0.5,"minInterestRateBps":820,"principalAvailable":"50000000000000000000","principalAvailableUsd":150000.5}},"funding":{"coin":"ETH","fundingRateYearlyApr":-0.155,"platformUrl":"https://app.hyperliquid.xyz/trade/ETH","fundingRate8h":-0.0005,"fundingRateHourly":-0.000062,"oraclePx":3000.25,"openInterest":12500000}}}]}}}}}},"500":{"description":"Server error while computing delta-neutral opportunities","content":{"application/json":{"schema":{"type":"object","required":["ok","error"],"properties":{"ok":{"type":"boolean","example":false},"error":{"type":"string","example":"Failed to compute delta-neutral opportunities"}}}}}}}}},"/borrow/general":{"get":{"summary":"Get All Borrow Pools","description":"Returns all available Teller lending pools with optional filtering by chain, collateral token, borrow token, or pool address.\n\nThis endpoint:\n1. Fetches the complete matrix of lending pools from the Teller protocol\n2. Enriches each pool with on-chain data (interest rates, available liquidity, fees)\n3. Filters results based on provided query parameters\n4. Returns detailed pool information including APRs, collateral ratios, and available principal\n\nResults are cached (default 30min TTL) to optimize performance.\nUseful for discovering all borrowing opportunities across supported chains and tokens.\n","operationId":"getBorrowGeneral","tags":["Borrow"],"parameters":[{"name":"chainId","in":"query","required":false,"description":"Filter by blockchain network ID","schema":{"type":"integer","example":42161}},{"name":"collateral_token_address","in":"query","required":false,"description":"Filter by collateral token address","schema":{"type":"string","example":"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}},{"name":"borrow_token_address","in":"query","required":false,"description":"Filter by borrow token address","schema":{"type":"string","example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"}},{"name":"pool_address","in":"query","required":false,"description":"Filter by specific pool address","schema":{"type":"string","example":"0x1234567890abcdef1234567890abcdef12345678"}},{"name":"ttl","in":"query","required":false,"description":"Cache TTL in seconds (default: 1800)","schema":{"type":"integer","default":1800,"example":1800}}],"responses":{"200":{"description":"Successfully retrieved borrow pools","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BorrowGeneralResponse"}}}},"500":{"description":"Server error while retrieving borrow pools","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"failed"}}}}}}}}},"/borrow-terms":{"get":{"summary":"Get Borrow Terms for a Wallet","description":"Returns the maximum borrow amount and related terms for a specific wallet, chain, collateral token, and lending pool.\n\nThis endpoint calculates:\n1. The wallet's collateral holdings (wallet balance + supplied tokens)\n2. The pool's LTV (Loan-to-Value) ratio and borrowing terms\n3. The maximum amount that can be borrowed based on available collateral and pool liquidity\n4. Interest rates, fees, and other loan parameters\n\nUseful for determining how much a user can borrow before initiating a loan.\n","operationId":"getBorrowTerms","tags":["Borrow"],"parameters":[{"name":"wallet","in":"query","required":true,"description":"The wallet address to check borrow terms for","schema":{"type":"string","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"}},{"name":"chainId","in":"query","required":true,"description":"The blockchain network ID","schema":{"type":"integer","example":42161}},{"name":"collateralToken","in":"query","required":true,"description":"The collateral token address","schema":{"type":"string","example":"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}},{"name":"poolAddress","in":"query","required":true,"description":"The Teller lending pool address","schema":{"type":"string","example":"0x1234567890abcdef1234567890abcdef12345678"}}],"responses":{"200":{"description":"Successfully retrieved borrow terms","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BorrowTerms"}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Missing required query parameters: wallet, chainId, collateralToken, poolAddress"}}}}}},"500":{"description":"Server error while retrieving borrow terms","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Failed to get borrow terms"}}}}}}}}},"/borrow-tx":{"get":{"summary":"Get Borrow Transactions","description":"Returns the list of transactions needed for a wallet to borrow from a Teller lending pool.\n\nThis endpoint analyzes the current state of the wallet and pool to determine which transactions are required:\n1. Token approval for the collateral manager (if current allowance is insufficient)\n2. Reset allowance to 0 for certain tokens (USDT, etc.) that require zero allowance before increasing\n3. Approve the market forwarder if not already approved\n4. Final borrow transaction to accept the smart commitment and receive the loan\n\nThe endpoint returns executable transaction data that can be sent directly to the blockchain.\n","operationId":"getBorrowTransactions","tags":["Borrow"],"parameters":[{"name":"walletAddress","in":"query","required":true,"description":"The wallet address that wants to borrow","schema":{"type":"string","example":"0x7A22449F42A4FeD13774f8aBC17f45eFA990574d"}},{"name":"collateralTokenAddress","in":"query","required":true,"description":"The collateral token address","schema":{"type":"string","example":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}},{"name":"chainId","in":"query","required":true,"description":"The blockchain network ID","schema":{"type":"integer","example":1}},{"name":"poolAddress","in":"query","required":true,"description":"The Teller lending pool/commitment address","schema":{"type":"string","example":"0x1112b72d0ab77ecadb016737e9ce452083f4a530"}},{"name":"collateralAmount","in":"query","required":true,"description":"Amount of collateral in wei or base token units","schema":{"type":"string","example":"1000000"}},{"name":"principalAmount","in":"query","required":true,"description":"Amount to borrow in wei or base token units","schema":{"type":"string","example":"1000000000000000000"}},{"name":"loanDuration","in":"query","required":false,"description":"Loan duration in seconds (default: 2592000 = 30 days)","schema":{"type":"integer","default":2592000,"example":2592000}}],"responses":{"200":{"description":"Successfully generated borrow transactions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BorrowTransactions"},"examples":{"success":{"summary":"Example response with multiple transactions","value":{"transactions":[{"to":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0x095ea7b30000000000000000000000003c45bf8dfbb3828f12056717084396ebc18bee7300000000000000000000000000000000000000000000000000000000000f4242","functionName":"approve","args":["0x3c45bf8dfbb3828f12056717084396ebc18bee73","1000002"],"description":"Approve collateral token","value":"0"},{"to":"0x00182fdb0b880ee24d428e3cc39383717677c37e","data":"0x5ca3eea80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e7428d68fadccf7500f4f0f3e86a4e0ff49d40c8","functionName":"approveMarketForwarder","args":["1","0xe7428d68fadccf7500f4f0f3e86a4e0ff49d40c8"],"description":"Approve Teller market forwarder","value":"0"},{"to":"0xe7428d68fadccf7500f4f0f3e86a4e0ff49d40c8","data":"0x1234abcd...","functionName":"acceptSmartCommitmentWithRecipient","args":["0x1112b72d0ab77ecadb016737e9ce452083f4a530","999999999999999900","1000000","0","0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x7A22449F42A4FeD13774f8aBC17f45eFA990574d","525","2592000"],"description":"Accept commitment and borrow","value":"0"}],"summary":{"totalTransactions":3,"needsApproval":true,"needsForwarderApproval":true,"needsZeroAllowance":false}}}}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"walletAddress is required"}}}}}},"500":{"description":"Server error while building borrow transactions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Failed to build borrow transactions"}}}}}}}}},"/loans/get-all":{"get":{"summary":"Get All Loans for a Wallet","description":"Returns all active and historical loans for a specific wallet address from the Teller subgraph.\n\nThis endpoint queries the Teller subgraph to retrieve:\n- All loans associated with the wallet\n- Loan status and terms\n- Repayment history\n- Principal and interest amounts\n- Timestamps and transaction details\n\nFor more details on loan data structure, see:\nhttps://docs.teller.org/teller-lite/dev-guide/repay/getting-repay-details\n","operationId":"getAllLoans","tags":["Loans"],"externalDocs":{"description":"Official implementation guide","url":"https://docs.teller.org/teller-lite/dev-guide/repay/getting-repay-details"},"parameters":[{"name":"walletAddress","in":"query","required":true,"description":"The wallet address to retrieve loans for","schema":{"type":"string","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"}},{"name":"chainId","in":"query","required":true,"description":"The blockchain network ID","schema":{"type":"integer","example":1}}],"responses":{"200":{"description":"Successfully retrieved loans","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoansResponse"}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"walletAddress is required"}}}}}},"500":{"description":"Server error while fetching loans","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Failed to fetch loans"},"message":{"type":"string"}}}}}}}}},"/loans/repay-tx":{"get":{"summary":"Get Loan Repayment Transactions","description":"Returns the transaction data needed to repay an existing loan (full or partial repayment).\n\nThis endpoint:\n1. Fetches loan details from the Teller subgraph\n2. Calculates the repayment amount (interest + principal)\n3. Builds the necessary transactions:\n   - Token approval for TellerV2 contract\n   - Repayment transaction (repayLoanFull or repayLoan)\n\nFor implementation details, see:\nhttps://docs.teller.org/teller-lite/dev-guide/repay/executing-a-repayment\n","operationId":"getRepayTransactions","tags":["Loans"],"externalDocs":{"description":"Official implementation guide","url":"https://docs.teller.org/teller-lite/dev-guide/repay/executing-a-repayment"},"parameters":[{"name":"bidId","in":"query","required":true,"description":"The loan bid ID to repay","schema":{"type":"integer","example":12345}},{"name":"chainId","in":"query","required":true,"description":"The blockchain network ID","schema":{"type":"integer","example":1}},{"name":"walletAddress","in":"query","required":true,"description":"The wallet address that owns the loan","schema":{"type":"string","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"}},{"name":"amount","in":"query","required":false,"description":"Optional: Specific amount to repay (in wei). If not provided, repays the full loan.","schema":{"type":"string","example":"1000000000000000000"}}],"responses":{"200":{"description":"Successfully generated repay transactions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RepayTransactions"}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"bidId is required"}}}}}},"500":{"description":"Server error while building repay transactions","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Failed to build repay transactions"},"message":{"type":"string"}}}}}}}}},"/loans/rollover-tx":{"get":{"summary":"Get Loan Rollover Transactions","description":"Returns information about rolling over an existing loan into a new loan with updated terms.\n\nNote: This endpoint currently returns loan details and documentation links. Full rollover transaction building requires integration with Teller rollover contracts.\n\nFor implementation details, see:\nhttps://docs.teller.org/teller-lite/dev-guide/rollover/getting-rollover-details\n","operationId":"getRolloverTransactions","tags":["Loans"],"externalDocs":{"description":"Official implementation guide","url":"https://docs.teller.org/teller-lite/dev-guide/rollover/getting-rollover-details"},"parameters":[{"name":"bidId","in":"query","required":true,"description":"The loan bid ID to rollover","schema":{"type":"integer","example":12345}},{"name":"chainId","in":"query","required":true,"description":"The blockchain network ID","schema":{"type":"integer","example":1}},{"name":"walletAddress","in":"query","required":true,"description":"The wallet address that owns the loan","schema":{"type":"string","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"}}],"responses":{"200":{"description":"Rollover information and loan details","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Rollover functionality requires integration with Teller rollover contracts"},"loanDetails":{"type":"object","description":"Current loan details from subgraph"},"documentation":{"type":"string","example":"https://docs.teller.org/teller-lite/dev-guide/rollover/getting-rollover-details"},"note":{"type":"string","example":"Please refer to the official Teller documentation for rollover implementation details"}}}}}},"400":{"description":"Missing required query parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"bidId is required"}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Failed to build rollover transactions"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"BorrowTerms":{"type":"object","required":["wallet","chainId","collateralToken","collateralTokenSymbol","poolAddress","borrowToken","borrowTokenSymbol","maxBorrowUsd"],"properties":{"wallet":{"type":"string","description":"The wallet address","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"},"chainId":{"type":"integer","description":"The blockchain network ID","example":42161},"collateralToken":{"type":"string","description":"The collateral token address (normalized to lowercase)","example":"0x82af49447d8a07e3bd95bd0d56f35241523fbab1"},"collateralTokenSymbol":{"type":"string","description":"The collateral token symbol","example":"WETH"},"poolAddress":{"type":"string","description":"The Teller lending pool address (normalized to lowercase)","example":"0x1234567890abcdef1234567890abcdef12345678"},"borrowToken":{"type":"string","description":"The borrow token address","example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},"borrowTokenSymbol":{"type":"string","description":"The borrow token symbol","example":"USDC"},"collateralWalletBalance":{"type":"number","description":"Collateral token balance in the wallet (in token units)","example":2.5},"collateralWalletBalanceUsd":{"type":"number","nullable":true,"description":"USD value of wallet collateral balance","example":7500},"collateralSuppliedTokens":{"type":"number","description":"Collateral tokens already supplied to Teller pools","example":1.5},"collateralSuppliedUsd":{"type":"number","description":"USD value of supplied collateral","example":4500},"collateralTotalUsd":{"type":"number","description":"Total USD value of all collateral (wallet + supplied)","example":12000},"ltvPct":{"type":"number","description":"Loan-to-Value ratio as a percentage","example":80},"collateralRatioPct":{"type":"number","description":"Collateral ratio as a percentage (inverse of LTV)","example":125},"collateralRatioBps":{"type":"integer","description":"Collateral ratio in basis points","example":12500},"minInterestRatePct":{"type":"number","description":"Minimum interest rate as a percentage","example":8.5},"minInterestRateBps":{"type":"integer","description":"Minimum interest rate in basis points","example":850},"marketplaceFeePercent":{"type":"number","description":"Marketplace fee percentage","example":0.5},"paymentCycleDuration":{"type":"number","description":"Payment cycle duration in seconds","example":31536000},"paymentCycleDurationYears":{"type":"number","description":"Payment cycle duration in years","example":1},"termInterestPct":{"type":"number","description":"Total interest percentage for the full term","example":8.5},"aprPct":{"type":"number","description":"Annual percentage rate","example":8.5},"principalAvailable":{"type":"string","description":"Principal available in the pool (in wei or smallest token unit)","example":"1000000000000"},"principalAvailableUsd":{"type":"number","description":"Principal available in USD","example":1000000},"maxBorrowByCollateral":{"type":"number","description":"Maximum borrow amount in USD based on user's collateral (before liquidity constraints)","example":9500},"maxBorrowUsd":{"type":"number","description":"Actual maximum borrow amount in USD (limited by min of collateral capacity or pool liquidity)","example":9500},"maxCollateralNeededUsd":{"type":"number","description":"USD value of collateral needed to borrow maxBorrowUsd","example":11875},"maxCollateralAmount":{"type":"number","nullable":true,"description":"Token amount of collateral needed to borrow maxBorrowUsd","example":3.958},"collateralPrice":{"type":"number","nullable":true,"description":"Price per token of collateral in USD","example":3000},"marketId":{"type":"string","description":"Teller market ID","example":"123"},"principalToken":{"type":"string","description":"Principal token address","example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},"principalTokenDecimals":{"type":"integer","description":"Decimals of the principal token","example":6},"isV2":{"type":"boolean","description":"Whether this is a V2 pool","example":false},"poolVersion":{"type":"string","description":"Pool version identifier","enum":["v1","v2"],"example":"v1"},"error":{"type":"string","description":"Error message if collateral or pool not found","example":"No collateral holdings found for this token"}}},"BorrowTransactions":{"type":"object","required":["transactions","summary"],"properties":{"transactions":{"type":"array","description":"Array of transactions to execute in order","items":{"type":"object","required":["to","data","functionName","args","description","value"],"properties":{"to":{"type":"string","description":"Contract address to send the transaction to","example":"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"},"data":{"type":"string","description":"Encoded transaction data","example":"0x095ea7b3000000000000000000000000..."},"functionName":{"type":"string","description":"Name of the function being called","example":"approve"},"args":{"type":"array","description":"Array of function arguments (for reference)","items":{"oneOf":[{"type":"string"},{"type":"number"}]},"example":["0xCollateralManagerAddress","1000000000000000002"]},"description":{"type":"string","description":"Human-readable description of the transaction","example":"Approve collateral token"},"value":{"type":"string","description":"ETH value to send with transaction (usually '0')","example":"0"}}}},"summary":{"type":"object","required":["totalTransactions","needsApproval","needsForwarderApproval","needsZeroAllowance"],"properties":{"totalTransactions":{"type":"integer","description":"Total number of transactions required","example":3},"needsApproval":{"type":"boolean","description":"Whether token approval is needed","example":true},"needsForwarderApproval":{"type":"boolean","description":"Whether market forwarder approval is needed","example":true},"needsZeroAllowance":{"type":"boolean","description":"Whether the token requires resetting allowance to 0 first (e.g., USDT)","example":false}}}}},"BorrowGeneralResponse":{"type":"object","required":["updated_at","ttl_ms","count","filters","results"],"properties":{"updated_at":{"type":"number","description":"Timestamp in milliseconds when the data was cached","example":1702468800000},"ttl_ms":{"type":"number","description":"Cache TTL in milliseconds","example":1800000},"count":{"type":"integer","description":"Number of pools returned","example":15},"filters":{"type":"object","description":"Applied filters","properties":{"chainId":{"type":"integer","nullable":true,"example":42161},"collateral_token_address":{"type":"string","nullable":true,"example":"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"},"borrow_token_address":{"type":"string","nullable":true,"example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},"pool_address":{"type":"string","nullable":true,"example":"0x1234567890abcdef1234567890abcdef12345678"}}},"results":{"type":"array","description":"Array of enriched borrow pools","items":{"$ref":"#/components/schemas/BorrowPoolEnriched"}}}},"BorrowPoolEnriched":{"type":"object","description":"A Teller lending pool with enriched on-chain data","properties":{"chainId":{"type":"integer","description":"Blockchain network ID","example":42161},"pool_address":{"type":"string","description":"Lending pool contract address","example":"0x1234567890abcdef1234567890abcdef12345678"},"collateral_token_address":{"type":"string","description":"Collateral token address","example":"0x82af49447d8a07e3bd95bd0d56f35241523fbab1"},"collateral_token_symbol":{"type":"string","description":"Collateral token symbol","example":"WETH"},"borrow_token_address":{"type":"string","description":"Borrow token address","example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},"borrow_token_symbol":{"type":"string","description":"Borrow token symbol","example":"USDC"},"isV2":{"type":"boolean","description":"Whether this is a V2 pool","example":false},"active":{"type":"boolean","description":"Whether the pool is active","example":true},"enrichment":{"type":"object","description":"On-chain enrichment data","properties":{"marketId":{"type":"integer","description":"Teller market ID","example":123},"marketplaceFeePercent":{"type":"number","nullable":true,"description":"Marketplace fee percentage","example":0.5},"paymentCycleDuration":{"type":"number","nullable":true,"description":"Payment cycle duration in seconds","example":31536000},"collateralRatioBps":{"type":"integer","description":"Collateral ratio in basis points","example":12500},"collateralRatioPct":{"type":"number","description":"Collateral ratio as percentage","example":125},"principalToken":{"type":"string","description":"Principal token address","example":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},"principalTokenDecimals":{"type":"integer","description":"Principal token decimals","example":6},"minInterestRateBps":{"type":"integer","description":"Minimum interest rate in basis points","example":850},"minInterestRatePct":{"type":"number","description":"Minimum interest rate as percentage","example":8.5},"principalAvailableRaw":{"type":"string","description":"Available principal in wei/smallest unit","example":"1000000000000"},"principalAvailable":{"type":"number","description":"Available principal in token units","example":1000000},"principalAvailableUsd":{"type":"number","nullable":true,"description":"Available principal in USD","example":1000000}}},"enrichmentError":{"type":"string","description":"Error message if on-chain enrichment failed","example":"onchain read failed"}}},"LoansResponse":{"type":"object","required":["walletAddress","chainId","count","loans"],"properties":{"walletAddress":{"type":"string","description":"The wallet address","example":"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"},"chainId":{"type":"integer","description":"The blockchain network ID","example":1},"count":{"type":"integer","description":"Number of loans returned","example":5},"loans":{"type":"array","description":"Array of loan objects from the subgraph","items":{"$ref":"#/components/schemas/Loan"}}}},"Loan":{"type":"object","properties":{"bidId":{"type":"string","description":"Loan bid ID","example":"4295"},"borrowerAddress":{"type":"string","description":"Borrower wallet address","example":"0x359e8a8ab1061ec972d9b8f807577563432b8994"},"lenderAddress":{"type":"string","description":"Lender wallet address","example":"0x0854d0c201fd3f9e0ae2341c92b28d289234549c"},"lendingTokenAddress":{"type":"string","description":"Lending token address","example":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174"},"principal":{"type":"string","description":"Principal amount in wei","example":"604395"},"totalRepaidPrincipal":{"type":"string","description":"Total principal repaid","example":"0"},"apr":{"type":"string","description":"APR in basis points","example":"2500"},"loanDuration":{"type":"string","description":"Total loan duration in seconds","example":"604800"},"paymentCycle":{"type":"string","description":"Payment cycle duration in seconds","example":"604800"},"paymentCycleAmount":{"type":"string","description":"Payment amount per cycle","example":"607360"},"acceptedTimestamp":{"type":"string","description":"Loan acceptance timestamp","example":"1729976725"},"lastRepaidTimestamp":{"type":"string","description":"Last repayment timestamp","example":"0"},"nextDueDate":{"type":"string","description":"Next payment due date timestamp","example":"1730581525"},"paymentDefaultDuration":{"type":"string","description":"Payment default duration in seconds","example":"0"},"status":{"type":"string","description":"Loan status","example":"Accepted"},"expiresAt":{"type":"string","description":"Loan expiration timestamp","example":"1730581525"},"metadataURI":{"type":"string","description":"Metadata URI","example":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"},"marketplaceId":{"type":"string","description":"Marketplace ID","example":"33"},"collateral":{"type":"array","description":"Collateral assets","items":{"type":"object","properties":{"type":{"type":"string","example":"ERC20"},"collateralAddress":{"type":"string","example":"0x692ac1e363ae34b6b489148152b12e2785a3d8d6"},"amount":{"type":"string","example":"5000000000000000000"},"tokenId":{"type":"string","example":"0"},"status":{"type":"string","example":"Deposited"},"token":{"type":"object","properties":{"name":{"type":"string","example":"Polytrade (PoS)"},"symbol":{"type":"string","example":"TRADE"},"decimals":{"type":"string","example":"18"}}}}}},"marketplace":{"type":"object","properties":{"paymentType":{"type":"string","example":"EMI"}}}}},"RepayTransactions":{"type":"object","required":["transactions","summary"],"properties":{"transactions":{"type":"array","description":"Array of transactions to execute in order","items":{"type":"object","required":["to","data","functionName","args","description","value"],"properties":{"to":{"type":"string","description":"Contract address to send the transaction to","example":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"},"data":{"type":"string","description":"Encoded transaction data","example":"0x095ea7b3..."},"functionName":{"type":"string","description":"Name of the function being called","example":"approve"},"args":{"type":"array","description":"Array of function arguments","items":{}},"description":{"type":"string","description":"Human-readable description","example":"Approve lending token for repayment"},"value":{"type":"string","description":"ETH value to send","example":"0"}}}},"summary":{"type":"object","required":["totalTransactions","loanId","repaymentAmount","isFullRepayment"],"properties":{"totalTransactions":{"type":"integer","description":"Total number of transactions","example":2},"loanId":{"type":"integer","description":"The loan bid ID","example":12345},"repaymentAmount":{"type":"string","description":"Amount being repaid in wei","example":"1050000000"},"isFullRepayment":{"type":"boolean","description":"Whether this is a full repayment","example":true},"lendingToken":{"type":"string","description":"Lending token address","example":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"},"repaymentDetails":{"type":"object","properties":{"totalOwed":{"type":"string","example":"1050000000"},"remainingPrincipal":{"type":"string","example":"1000000000"},"remainingInterest":{"type":"string","example":"50000000"},"totalRepaidPrincipal":{"type":"string","example":"0"},"lendingToken":{"type":"string","example":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}}}}}}},"DeltaNeutralOpportunity":{"type":"object","required":["chainId","coin","poolAddress","platformUrl","fundingAprYearlyPct","fundingAprAbsPct","borrowAprPct","borrowFeePct","netAprPct","principalAvailable","principalAvailableUsd","allPlatforms","raw"],"properties":{"chainId":{"type":"integer","description":"The blockchain network ID where the Teller pool is located","example":42161},"coin":{"type":"string","description":"The token symbol","example":"ETH"},"poolAddress":{"type":"string","description":"The Ethereum address of the Teller lending pool","example":"0x1234567890abcdef1234567890abcdef12345678"},"platformUrl":{"type":"string","description":"URL to the perpetual trading platform (for the best funding rate)","example":"https://app.hyperliquid.xyz/trade/ETH"},"platformLogo":{"type":"string","nullable":true,"description":"URL to the perpetual platform's logo image","example":"https://api.coins-rating.com/img/projects/12_06_23/648674b19d2c7.webp"},"fundingAprYearlyPct":{"type":"number","description":"The annualized funding rate as a percentage (negative values indicate shorts receive payments)","example":-15.5},"fundingAprAbsPct":{"type":"number","description":"Absolute value of the annualized funding rate as a percentage","example":15.5},"borrowAprPct":{"type":"number","description":"The borrowing APR from the Teller market as a percentage (based on minInterestRateBps)","example":8.2},"borrowFeePct":{"type":"object","description":"Breakdown of borrowing fees (not included in net APR calculation)","required":["marketplaceFeePct","protocolFeePct","totalBorrowFeePct"],"properties":{"marketplaceFeePct":{"type":"number","description":"Marketplace fee as a percentage","example":0.5},"protocolFeePct":{"type":"number","description":"Protocol fee as a percentage (fixed at 0.05%)","example":0.05},"totalBorrowFeePct":{"type":"number","description":"Total of marketplace and protocol fees as a percentage","example":0.55}}},"netAprPct":{"type":"number","description":"Net APR as a percentage (fundingAprAbsPct - borrowAprPct). This is the expected profit.","example":7.3},"principalAvailable":{"type":"string","description":"Available borrowing principal in the Teller pool (in wei or smallest token unit)","example":"50000000000000000000"},"principalAvailableUsd":{"type":"number","description":"Available borrowing principal in USD","example":150000.5},"allPlatforms":{"type":"array","description":"Funding rates from all available perpetual platforms for this coin","items":{"$ref":"#/components/schemas/PlatformFundingData"}},"raw":{"type":"object","description":"Raw data from the underlying services for debugging","required":["row","funding"],"properties":{"row":{"type":"object","description":"Raw borrowing data from Teller"},"funding":{"type":"object","description":"Raw funding rate data from the perpetual exchange"}}}}},"PlatformFundingData":{"type":"object","required":["platformUrl","fundingAprYearlyPct","fundingAprAbsPct"],"properties":{"platformUrl":{"type":"string","description":"URL to the perpetual trading platform","example":"https://app.hyperliquid.xyz/trade/ETH"},"platformLogo":{"type":"string","nullable":true,"description":"URL to the platform's logo","example":"https://api.coins-rating.com/img/projects/12_06_23/648674b19d2c7.webp"},"fundingAprYearlyPct":{"type":"number","description":"Annualized funding rate as a percentage","example":-15.5},"fundingAprAbsPct":{"type":"number","description":"Absolute value of annualized funding rate as a percentage","example":15.5},"fundingRate8h":{"type":"number","nullable":true,"description":"8-hour funding rate","example":-0.0005},"fundingRateHourly":{"type":"number","nullable":true,"description":"Hourly funding rate","example":-0.000062},"oraclePx":{"type":"number","nullable":true,"description":"Oracle price for the asset","example":3000.25},"openInterest":{"type":"number","nullable":true,"description":"Total open interest on the platform","example":12500000}}}}},"tags":[{"name":"Perpetuals","description":"Endpoints related to perpetual futures data and delta-neutral arbitrage"},{"name":"Borrow","description":"Endpoints related to borrowing opportunities, terms, and pool data"},{"name":"Loans","description":"Endpoints related to loan management, repayment, and rollover. See external documentation for implementation details."}]}