Lista DAO 백서

Lista DAO

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 53쪽 중 28쪽

turns (uint256 amountOut); function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); ``` `amountOutMinimum` / `amountInMaximum` enforce slippage limits, `deadline` bounds execution time, and `sqrtPriceLimitX96` optionally caps the price movement within the swap. ## Uniswap V3 mechanics Lista V3 is a Uniswap V3 fork and the pool maths is unmodified: ticks (`1.0001^i`, `MIN_TICK`/`MAX_TICK`), `slot0.sqrtPriceX96` in Q64.96, the `feeGrowthGlobal{0,1}X128` accumulators, tick crossing, the observation ring buffer, and the `Mint`/`Burn`/`Collect`/`Swap`/`Flash`/`Initialize` event shapes all behave as documented upstream. Use the [Uniswap V3 docs](https://docs.uniswap.org/contracts/v3/overview) and `@uniswap/v3-sdk` (`TickMath`, `SqrtPriceMath`) for the maths rather than reimplementing it. What differs from Uniswap is the deployed addresses, the fee tiers enabled on the Lista factory, and the pool-address derivation. ## Fee tiers and tick spacing Fee tiers are set in the `ListaV3Factory`. Each tier maps a fee (in hundredths of a basis point, i.e. `1e-6`) to a `tickSpacing`. Five are enabled on the live factory: | Fee tier | `fee` (uint24) | `tickSpacing` | Notes | | -------- | -------------- | ------------- | ------------------------------------------------------- | | 0.0002% | `2` | `1` | Enabled post-deployment; used by Lista stablecoin pools | | 0.01% | `100` | `1` | Enabled post-deployment; used by Lista LST pools | | 0.05% | `500` | `10` | Constructor | | 0.30% | `3000` | `60` | Constructor | | 1.00% | `10000` | `200` | Constructor | > Lista's stablecoin and LST pools (noted in the table above) use the two lowest tiers, which are **not** in the constructor set. Do not assume that Uniswap's common `500` / `3000` / `10000` tiers identify Lista pools; query the factory for the target pool's fee tier. Additional tiers can be added by the factory owner via `enableFeeAmount(fee, tickSpacing)`; a tier, once enabled, can never be removed, and `feeAmountTickSpacing(fee)` returns `0` for tiers that are not enabled. Read `feeAmountTickSpacing(fee)` (or watch the `FeeAmountEnabled` event) for the authoritative live list rather than hard-coding tiers. ```solidity function enableFeeAmount(uint24 fee, int24 tickSpacing) external; // factory owner only event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); ``` ## Building on Lista V3 Because Lista V3 is a Uniswap V3 fork: * Use `@uniswap/v3-sdk` and `@uniswap/sdk-core` for price/tick math, position math, and route encoding, pointing them at the Lista contract addresses and BNB Smart Chain (chainId 56). * The pool address is deterministic from `(factory, token0, token1, fee)` via CREATE2, **but you must use Lista's own pool init-code hash** — `0xa93d35cf943696a95cabbe3aa4b3d87ea5387169face953a337716fc15136ca2` — in the `PoolAddress` computation. Uniswap V3's default init-code hash yields the wrong address for Lista pools. Alternatively, read `factory.getPool(token0, token1, fee)` on-chain instead of deriving it. * Pool, factory, and periphery interfaces match Uniswap V3 `IUniswapV3Pool` / `IUniswapV3Factory` / `INonfungiblePositionManager` / `ISwapRouter`, so existing V3 integrations port with minimal changes (renamed contracts, the upgradeable position manager, and the Lista-specific NFT name/symbol aside). ## Related pages * [V3 Dex overview](/for-developer/dex) — section landing page. # Smart Contract | Contract | Address | | ---------------------------------- | ------------------------------------------ | | ProxyAdmin | 0x97458aE48Fc8362077c30930bc6C004B46a9312f | | ListaV3Factory | 0xcb010ed373523942706F730b89792aA1C1597b20 | | NonfungibleTokenPositionDescriptor | 0xfa9f54098C64e7Dc48B9B6402F26441159bA83c7 | | NonfungiblePositionManager | 0x31677537685EBDF1B695eDa46eC385845395f5dD | | SwapRouter | 0xc43D58722f29390e683c0721285A6c11B8aCD4DE | | ListaV3Pool | 0xd50154428912A887d9a405Bb515d2Ef11307228d | | ListaV3Pool | 0x46eE2C5F2b9De7C6e08Ffe3Bde8Dd88A46D6f568 | | ListaV2Factory | 0x28F5E6C71C7541b1C6523351AE331CcAfC443626 | | ListaV2Router02 | 0x3CcbB50C93ffCdA64e58Cc9E299791Fd85A41941 | | QuoterV2 | 0x6B61a2C67c45B40d754e4e7c1c565590685C03E2 | | ListaV3Pool | 0x8b94363fbBbBcdae25832807BE39e8e2c60a6e15 | | ListaV3Pool | 0x9f0E53D3aC0dc7aEaAF36866cD1A9EEbE16Bf4a1 | | ListaV3FactoryOwner | 0x2BBa5BdED4DD4A597f7BAdC256005C9Aa662Df06 | # Lista Platform Services Three off-chain surfaces support Lista Lending: the liquidation feeds, subscription notifications, and the Lista Lending REST API. ## Contents * [Liquidation (Service)](/for-developer/services/liquidation-logic) — Batch flow, eligibility checks, and contract interaction for liquidations. * [Subscription module](/for-developer/services/subscription-module) — User subscriptions and Telegram (or other) notification flow. * [Moolah Lending API](/for-developer/services/lending-api) — Endpoint reference: [API Conventions](/for-developer/services/lending-api/conventions), [Overall](/for-developer/services/lending-api/overall), [Vault](/for-developer/services/lending-api/vault), [Market](/for-developer/services/lending-api/market), [Position / Liquidation / Emission](/for-developer/services/lending-api/position-liquidation-emission). # Liquidation (Service) Lista operates its own liquidation keeper. Its scheduling, thresholds, and retry behaviour are internal and are not documented here. Third-party liquidators do not need them. What you do need: ## Eligibility A position is liquidatable when its loan-to-value exceeds the market's `lltv`: ``` borrowed = convertBorrowSharesToAssets(borrowShares, totalBorrowAssets, totalBorrowShares) maxBorrow = collateral × price / 1e36 × lltv / 1e18 // price = collateral denominated in the loan asset, 1e36-scaled; lltv is 1e18-scaled isHealthy = maxBorrow ≥ borrowed ``` A position with no debt is always healthy. On a broker market the borrower's debt is replaced by the broker's total debt (Moolah principal plus interest accrued at the broker), while the collateral is still priced at the plain market price. Use the same oracle and market parameters the contract uses, and match its rounding — `maxBorrow` is floored and `borrowed` rounded up, both in the protocol's favour. The exact scale factors, the `isHealthy` view and its caveats, and the liquidation-price formula are in [Consuming Oracle Prices](/for-developer/multi-oracle/consuming-prices). Re-read the oracle and position state at execution time: Moolah accrues interest and re-checks health when your transaction lands, and reverts with the string `"position is healthy"` if the position has recovered — Moolah's health and input checks use `require` strings, not typed errors. (The inherited reentrancy guard is the exception: it reverts a typed `ReentrancyGuardReentrantCall()` — see [Events & Callbacks](/for-developer/lista-lending/events-and-callbacks).) ## Finding candidates * `GET /api/moolah/redPositions` — liquidatable positions on one market. **Start here for open markets**, which are the common case: enumerate markets from `/api/moolah/allMarkets` and fan out. * `GET /api/liquidation/zone/closeToLiquidate` — positions approaching the threshold. * `GET /api/liquidation/zone/list` — the per-market **borrower** whitelist with each account's latest position snapshot. It applies **no** health test, so evaluate eligibility yourself, and it only finds candidates on *gated* markets. * `GET /api/liquidation/zone/history` — settled liquidations. Parameters and response fields are in [Positions, Liquidation & Emission](/for-developer/services/lending-api/position-liquidation-emission). Indexed data can lag; treat it as a candidate feed and confirm on-chain before submitting. ## Executing Liquidations are executed through the `PublicLiquidator` contract. It has no role gate, but reachability is **per market** — an under-water position is not necessarily liquidatable by you, and there are both self-funded and flash-swap paths. Entry points, sizing, the eligibility gate, and the revert reference are in [Liquidator Integration](/for-developer/lista-lending/liquidator-integration). Lista's keeper competes on the same public paths as anyone else. Running your own liquidator does not require, and does not receive, any knowledge of its configuration. For the product-level explanation of liquidation, see [Liquidation](/introduction/lista-lending/liquidation). # Subscription Module The subscription module lets users bind a wallet to **Telegram** and receive notifications (liquidation alerts, borrow-rate reminders). It exposes a **REST API** for client applications and uses a **Telegram Bot** for binding and subscription management. **Base URL:** `/api/v2/subscription` *** ## Binding flow 1. Client application calls **POST /api/v2/subscription/:user/otp** (with wallet signature) -> service returns a **6-character alphanumeric OTP** (`A-Z`, `a-z`, `0-9`), valid for **5 minutes**. 2. User opens the Telegram Bot and sends that OTP in the chat. 3. Bot verifies the OTP and binds the wallet address to the user’s Telegram ID. 4. After binding, the user can receive **liquidation alerts** and **borrow-rate reminders**. *** ## REST API ### 1. Get subscription status **GET /api/v2/subscription/:user** Returns whether the given wallet is bound to Telegram and related subscription state. | Path param | Description | | ---------- | ------------------------- | | `user` | Wallet address (e.g. 0x…) | ### 2. Generate OTP **POST /api/v2/subscription/:user/otp** Generates a one-time 6-character alphanumeric code for the user to send in the Telegram Bot to complete binding. Requires **wallet signature** to prove ownership. | Path param | Description | | ---------- | -------------- | | `user` | Wallet address | **Request body:** `signature` and `message`. `message` must be exactly the literal string `one-time-password` — this is a **different** challenge from the emission endpoints' timestamped message, and anything else returns envelope code `1005`. The server recovers the address from the signature and it must match the path `user`. **Response:** `{ user, password, otpValidUntil }` — the code is under **`password`**, not `otp`, and `otpValidUntil` is a Unix-seconds expiry. Pass the code to the user verbatim. The bot accepts `[0-9a-zA-Z]{6}`, and it validates the trimmed message but looks up the untrimmed one — so trailing whitespace fails even though the code is right. ### 3. Unsubscribe (unbind) **PUT /api/v2/subscription/:user/unsubscribe** Unbinds the wallet from Telegram and stops all notifications. Sends an unbind confirmation to the user’s Telegram. Requires **wallet signature**. | Path param | Description | | ---------- | -------------- | | `user` | Wallet address | **Request body:** `signature` and `message`. *** ## Telegram Bot Binding, subscription management, muting and language are handled inside the Telegram bot itself; the REST API above covers status, OTP issuance and unbind. Once a wallet is bound, the bot delivers liquidation alerts and borrow-rate reminders to it. # Moolah Lending API Technical reference for the **Moolah lending protocol API** used by Lista Lending. The API exposes protocol-level, vault, market, position, liquidation, and emission data for client applications and integrators. **Base URL:** most paths are `GET`/`POST` under `/api/moolah`; the liquidation and aggregated-position feeds sit under `/api/liquidation` and `/api/v2` — see [Conventions](/for-developer/services/lending-api/conventions). *** ## Contents | Page | Description | | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | [API Conventions](/for-developer/services/lending-api/conventions) | Base URL, response envelope, chain selector, pagination, signature-gated endpoints, caching | | [Overall](/for-developer/services/lending-api/overall) | Protocol-level snapshot | | [Vault](/for-developer/services/lending-api/vault) | Vault list, detail, deposit/APY history, allocation | | [Market](/for-developer/services/lending-api/market) | Market list, detail, vaults by market, borrow rate history, allMarkets, search | | [Position, Liquidation, Emission](/for-developer/services/lending-api/position-liquidation-emission) | User position, liquidation, rewards, CDP | # API Conventions Cross-cutting conventions shared by every [Moolah Lending API](/for-developer/services/lending-api) endpoint: the base URL, the response envelope, the chain selector, pagination and sorting, signature-gated endpoints, and caching. Each endpoint page assumes these and only documents what is specific to it. **Host:** `https://api.lista.org`. **Base URL:** most paths are served under `/api/moolah` (for example `GET /api/moolah/borrow/markets`). The liquidation and aggregated-position feeds are the exception — they sit under `/api/liquidation` and `/api/v2`; see [Positions, Liquidation & Emission](/for-developer/services/lending-api/position-liquidation-emission). *** ## Response envelope Responses from the endpoints documented in this section are wrapped in a uniform JSON envelope. (A few unrelated partner routes elsewhere on the host return raw payloads, so do not assume the envelope for paths outside this reference.) The endpoint's own payload is carried in `data`. | Field | Type | Description | | ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `code` | string | Status code. `"000000000"` on success. Any other value indicates an error. | | `msg` | string | Human-readable message for `code`, localized to the request language. | | `data` | any | The endpoint payload — an object or an array. It can be **absent** rather than `null` when there is nothing to return, so read it defensively; see the empty shapes below. Shape is documented per endpoint. | | `timestamp` | number | Server time when the response was built, in **milliseconds** since the Unix epoch. | Success example: ```json { "code": "000000000", "msg": "success", "data": { "total": 12, "list": [] }, "timestamp": 1751414400000 } ``` Error example: ```json { "code": "400", "msg": "Invalid params", "timestamp": 1751414400000 } ``` > Note the error envelope has **no `data` key at all** — it is omitted, not `null`. A client that tests `response.data === null` to detect an error will throw instead. ### Reading responses * **Check `code`, not the HTTP status alone.** Successful responses return HTTP `200` with `code = "000000000"`. Client errors (bad or missing parameters) return HTTP `400` with a non-success `code`; server-side failures return HTTP `500`. An **unknown resource is not an error** — a valid request for an id that does not exist returns HTTP `200`, so check the payload rather than expecting a `404`. Three shapes are possible: `{}`, `[]`, or — on `GET /market/:marketId` — **no `data` key at all**. Read it defensively. Always branch on `code === "000000000"` and read the payload from `data`. * **`timestamp` is in milliseconds**, not seconds — note this when comparing against the `startTime` / `endTime` history parameters, which are in **seconds**. ### Common error codes Codes are strings. This is not the complete set: | `code` | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | | `000000000` | Success. | | `400` | Invalid request parameters. | | `404` | No route matched the path. A valid request for a non-existent id does **not** produce this — see above. | | `401` | Signed message expired (see [Signature-gated endpoints](#signature-gated-endpoints)). | | `1005` | Invalid signature. | | `500` | Server error. | | `-1` | Custom error; read `msg` for the specific reason (e.g. a required query parameter was omitted). | *** ### Display multiplier Endpoints that return a collateral amount also return `collateralUiMultiplier`. It is `"1"` for all non-bStock collateral and for most bStock collateral too; where it differs it is the token's on-chain `uiMultiplier()`, which drifts above 1 over time. **Multiply the raw collateral amount by it before display** — do not infer it from the symbol. ## Chain selector Endpoints that span networks accept a `chain` query parameter. It is a **string network key**, not a numeric chain ID: | Value | Network | | ---------- | ------------------------- | | `bsc` | BNB Smart Chain (mainnet) | | `ethereum` | Ethereum (mainnet) | | `bscTest` | BSC testnet | * **Comma-separated where supported.** Several list endpoints accept multiple keys in one call, e.g. `chain=bsc,ethereum`. The value is split on commas and each key is matched independently. * **Default is environment-dependent.** When `chain` is omitted, endpoints default to the live network — `bsc` in production. Do not rely on the default; pass `chain` explicitly for deterministic behavior. * The `chain` string is also echoed back on most market/vault objects so you can tell which network a record belongs to when querying more than one at a time. *** ## Pagination List endpoints use 1-based page pagination: | Parameter | Type | Description | | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `page` | number | Page number, **1-based**. Values missing or `≤ 0` are treated as `1`. | | `pageSize` | number | Items per page. The default is **endpoint-specific** — `20` on the `/api/liquidation/zone/*` feeds, `10` on `/api/v2/liquidated/lending/history`. Capped per endpoint; requesting more than the cap silently clamps to it. | The `pageSize` cap is endpoint-specific: | Endpoint | `pageSize` cap | | ------------------------------------------------------------------- | -------------- | | `GET /borrow/markets` | `50` | | `GET /emission/userRewardHistory` | `50` | | `GET /market/vault/:marketId` (vaults by market) | `20` | | `GET /vault/list` | `50` | | `GET /vault/allocation` | `50` | | `GET /api/liquidation/zone/list` · `/history` · `/closeToLiquidate` | `50` | | `GET /redPositions` (`count`) | none | Paginated endpoints return `{ total, list }`, where `total` is the full count matching the filters (before pagination) and `list` holds the current page. To detect the last page, compare `page * pageSize` against `total` rather than assuming a full page. > One exception: `GET /market/vault/:marketId` returns `total` as the **number of entries in the current page**, not the full count, so the comparison above does not work there. *** ## Sorting Sortable list endpoints take a pair of parameters: | Parameter | Type | Description | | --------- | ------ | ------------------------------------------------------------------------------------------------------------------ | | `sort` | string | Sort field **key** (a whitelisted alias, not a raw column). Unrecognized keys fall back to a per-endpoint default. | | `order` | string | Sort direction: `asc` or `desc`. Case-insensitive. | Use the pair `sort` + `order`, **not** `sortBy` / `sortOrder`. `order` is optional everywhere. Any value other than `asc` / `desc` (case-insensitive) — including an omitted one — falls back to `desc`. Valid `sort` keys for `GET /borrow/markets`: `rate`, `liquidity`, `lltv`, `loan`, `collateral`, `termType`. See [Market API](/for-developer/services/le
프로젝트로 돌아가기