tapfi-sdk
v0.0.6
Published
SDK to query lending market data (deposit/borrow APR, APY, liquidity, limits) from multiple protocols on Sui.
Readme
Yield Route Aggregator SDK
SDK to query lending market data (deposit/borrow APR, APY, liquidity, limits) from multiple protocols on Sui.
Prerequisites
- Node.js 18+
- pnpm 8+
- Sui fullnode URL (mainnet). Scripts default to mainnet via @mysten helpers.
Project Structure
yield_route_aggreator/
├─ sources/ # Move modules (on-chain helpers)
│ ├─ scallop.move # Scallop Query
│ └─ suilend.move # Suilend Query
│ └─ navi.move # Navi Query
├─ sdk/
│ ├─ src/
│ │ ├─ modules/
│ │ │ ├─ scallop.ts # Scallop market query + calculations
│ │ │ └─ suilend.ts # Suilend market query
│ │ ├─ constants.ts # Protocol addresses
│ │ ├─ types.ts # Common types (CoinInfo, PoolData, etc)
│ │ ├─ config.ts # Protocol configs
│ │ ├─ client.ts # Aggregator client
│ │ └─ utils.ts # Common helpers (e.g., APR->APY)
│ └─ scripts/
│ ├─ query-scallop.ts # devInspect Scallop market
│ └─ query-suilend.ts # devInspect Suilend market
│ └─ query-navi.ts # devInspect Navi market
└─ README.mdInstall
# from repo root
cd sdk
pnpm installRun Suilend Query
pnpm tsx scripts/query-suilend.tsExpected example response (shape may evolve as the SDK aligns protocols):
[
{
"protocol": "Suilend",
"coinType": "0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
"decimals": 0,
"depositApr": 0.023389859551080742,
"depositApy": 0,
"borrowApr": 0.057075294756684415,
"borrowApy": 0,
"availableLiquidity": 34888052431796488,
"totalSupply": 71474344531773026,
"totalBorrow": 36641798821612551,
"utilizationRate": 0.5126566610950017,
"supplyLimit": 100000000000000000,
"borrowLimit": 80000000000000000,
"isolated": false,
"lendingMarketId": "0x84030d26d85eaa7035084a057f2f11f701b7e2e4eda87551becbc7c97505ece1",
"lastUpdated": null
}
]Run Scallop Query
pnpm tsx scripts/query-scallop.tsExample response:
[
{
"protocol": "Scallop",
"coinType": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
"decimals": 0,
"depositApr": 0.025949487501878057,
"depositApy": 0.026288160100167435,
"borrowApr": 0.07650051952712238,
"borrowApy": 0.07949409815721498,
"availableLiquidity": 6130161831271046,
"totalSupply": 10642796428246174,
"totalBorrow": 4512634596975128,
"utilizationRate": 0.4240083541388158,
"supplyLimit": 0,
"borrowLimit": 100000000000000000,
"isolated": null,
"lendingMarketId": "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
"lastUpdated": 1756192560
}
]Run Navi Query
pnpm tsx scripts/query-navi.tsExample response:
{
"protocol": "Navi",
"coinType": "0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
"depositApr": 0.02802,
"depositApy": 0.02802,
"borrowApr": 0.0017499999999999983,
"borrowApy": 0.0017499999999999998,
"availableLiquidity": 12365813820897864,
"totalSupply": 39045185620856192,
"totalBorrow": 18870334675787092,
"utilizationRate": 0.48329478719925467,
"supplyLimit": 54999999999999996,
"borrowLimit": 31236148496684953600000000,
"isolated": false,
"lendingMarketId": "",
"lastUpdated": 1756226060969
}Response attributes (types and descriptions)
| Field | Type | Description | Example | | ------------------ | --------------- | ----------------------------------------------------------------------- | ------------------ | | protocol | string | Protocol label | "Suilend" | | coinType | string | Fully qualified Sui type tag | "0x2::sui::SUI" | | decimals | number | Coin decimals from metadata | 9 | | depositApr | number | Annual deposit rate (fraction, 0.05 = 5%) | 0.0233 | | depositApy | number | Annual deposit yield (fraction) | 0.0236 | | borrowApr | number | Annual borrow rate (fraction). Can be negative; if < 0, no interest due | 0.0571 | | borrowApy | number | Annual borrow yield (fraction). Can be negative; if < 0, no interest due| 0.0595 | | availableLiquidity | BigInt | Available liquidity (coin units) | 34888052431796488 | | totalSupply | BigInt | Total supplied (coin units) | 71474344531773026 | | totalBorrow | BigInt | Total borrowed (coin units) | 36641798821612551 | | utilizationRate | number | totalBorrow / totalSupply (fraction, typically 0–1) | 0.5126 | | supplyLimit | BigInt | Max supply allowed (coin units) | 100000000000000000 | | borrowLimit | BigInt | Max borrow allowed (coin units) | 80000000000000000 | | isolated | boolean or null | Whether the pool is isolated; null if not exposed | false | | lendingMarketId | string | Sui object ID of the lending market | "0x8403...05ece1" | | lastUpdated | number or null | Unix timestamp (seconds) if provided, otherwise null | 1756192560 |
