Lista DAO 백서

Lista DAO

원문

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

cumulator and is realized in lisUSD on repayment — nothing is charged at borrow time. The rate is set by the `DynamicDutyCalculator` AMO from the lisUSD price. The **Jug** compounds `base + duty` and the Vat only folds the resulting delta into its accumulator, so read both `Jug.base()` and the calculator's own views rather than treating any single value as the rate. `Interaction.borrowApr(token)` returns the combined figure with **20 decimals** — i.e. a *percentage* scaled by `1e18`, so `4035532478367910700` is 4.0355%; divide by `1e20` for a fraction. Despite the name it raises the per-second rate to one year of seconds, so it is a compounded annual figure (an APY). For a liquidation surface that **is** open to third parties, see [Liquidator Integration](/for-developer/lista-lending/liquidator-integration) on Lista Lending. The engine's internals (`Vat`, `Jug`, `Spotter`, `Dog`, `Clipper`, `Abacus`, `Vow`) behave as in the MakerDAO design they were forked from — use the MakerDAO docs for them, and [Smart Contract](/for-developer/collateral-debt-position/smart-contract) for the deployed addresses. ## How the module works These flows are unchanged from the original design and are what the remaining positions still run on. Each step names the contract that performs it. ### Deposit collateral <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2FUJ79SX51nBMRfJsRXYh3%2Fimage.png?alt=media&amp;token=0f9ea484-2dee-4579-a4f8-8aed25815fad" alt=""><figcaption></figcaption></figure> 1. The user transfers collateral to the **Interaction** contract. 2. **Interaction** moves it into **GemJoin**, which custodies it. 3. **Vat** — the core CDP engine — records the collateral against the user. ### Borrow lisUSD <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2FqJpb0pdP1EcltAw5Xukj%2Fimage.png?alt=media&amp;token=c436ea95-6287-4be2-8882-59affc44e407" alt=""><figcaption></figcaption></figure> 1. The user calls `borrow()` on **Interaction**. 2. **Vat** records the debt increase against that collateral. 3. **HayJoin** mints the lisUSD and sends it to the user. 4. **Interaction** snapshots the position on **ListaDistributor** for reward accounting. Interest is not charged here — it accrues in the Vat and is realized on repayment. ### Repay lisUSD <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2FIkR5fyBB3sEntO5UVJ7H%2Fimage.png?alt=media&amp;token=1c726c03-cec5-46b5-b7e8-8839b6176c25" alt=""><figcaption></figcaption></figure> 1. The user specifies the amount to repay against a collateral. 2. **Vat** reduces the recorded debt; repaying in full closes the position. 3. **HayJoin** burns the lisUSD. 4. **Interaction** snapshots the new balance on **ListaDistributor**. ### Withdraw collateral <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2Fz90VLxj3iIBVHnRjS2kx%2Fimage.png?alt=media&amp;token=8779fcfe-429e-49a4-b0ca-d84aa7c3bfbe" alt=""><figcaption></figcaption></figure> 1. The user specifies the amount to withdraw. 2. **Interaction** checks the position stays safe — with debt outstanding, only part of the deposit is withdrawable. 3. **GemJoin** transfers the collateral back. 4. **Vat** records that the collateral left the system. ### Liquidation <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2FmKYJK0VVduz4K6YS3uGp%2Fimage.png?alt=media&amp;token=844df1ba-515d-4190-ac86-8796b4bc68e6" alt=""><figcaption></figcaption></figure> > **The buy side of the auction is permissioned in this fork.** `Clipper.take` and `Clipper.redo` carry `auth`, and `Interaction.buyFromAuction` is whitelisted, so unlike upstream MakerDAO a third party cannot start, bid in, or restart an auction. The worked example below explains the mechanism; it is not an integration path. For a liquidation surface that *is* open to third parties, see [Liquidator Integration](/for-developer/lista-lending/liquidator-integration). A position becomes liquidatable once the collateral value, after the collateral ratio is applied, falls below the debt: * Collateral price $2, collateral ratio 66% → effective unit price `2 × 0.66 = $1.32` * Deposit 10 units (`$20`), borrow limit `20 × 0.66 = $13.2`, borrow `13.2 lisUSD` * Price falls to `$1.80` → effective unit price `1.8 × 0.66 = $1.188`, position worth `1.188 × 10 = $11.88` * `13.2 − 11.88 = $1.32` — the shortfall makes it liquidatable The auction is then prepared from those numbers: * All 10 units of collateral go to the Dutch auction * Liquidation penalty (governance-set): 13% of the debt → cover `13.2 × 1.13 = $14.916` * Buffer (governance-set): 2% → starting price `1.8 × 1.02 = $1.836` <figure><img src="https://1802824789-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F60fXF9rALi6luWHVkkGg%2Fuploads%2FOhnw4d8GvGppjDJMRPhQ%2Fimage.png?alt=media&amp;token=34d07ff4-b108-4671-99bc-300f4944ff1d" alt=""><figcaption></figcaption></figure> The price then decreases over time — at 600 seconds into a 3600-second window, `1.836 × ((3600 − 600) / 3600) = $1.53`. The auction pauses when either governance-set bound is hit: **tail** (elapsed time) or **cusp** (share of the starting price remaining). A paused auction has to be restarted, which pays the restarter a flat **tip** plus a dynamic **chip**. Read the live values from the `Clipper` for the collateral rather than assuming them. ## lisUSD staking The **Jar** (`jar.sol`) is deprecated. The live lisUSD saving-rate product is the **LisUSDPoolSet** / **EarnPool** stack — see [Stable Pool (PSM)](/introduction/collateral-debt-position-lisusd/lisusd/stable-pool-price-stability-module-psm) and [lisUSD Saving Rate (LSR)](/introduction/collateral-debt-position-lisusd/lisusd/lisusd-saving-rate-lsr). That layer is separate from the CDP borrowing engine above and is not being wound down with it. ## See also * [Flash Loan](/for-developer/collateral-debt-position/flash-loan) — ERC-3156 flash minting of lisUSD. # Flash Loan > **The lisUSD CDP is being wound down** — see [Mechanics](/for-developer/collateral-debt-position/mechanics) for the live gates. Flash minting still works, so an existing integration keeps running. New integrations should use [Lista Lending](/for-developer/lista-lending), whose `Moolah.flashLoan` is in the [contract reference](/for-developer/lista-lending/contract-reference). `flash.sol` is a standard **ERC-3156** flash *minter*: it mints lisUSD to your contract, calls you back, and burns it again at the end of the same transaction. There is no collateral and no position — if the loan plus fee is not returned before the call ends, everything reverts. **Mainnet lender:** [`0x64d94e715B6c03A5D8ebc6B2144fcef278EC6aAa`](https://bscscan.com/address/0x64d94e715B6c03A5D8ebc6B2144fcef278EC6aAa) (`FlashMinter` on the [Smart Contract](/for-developer/collateral-debt-position/smart-contract) page) ## The interface ```solidity function maxFlashLoan(address token) external view returns (uint256); function flashFee(address token, uint256 amount) external view returns (uint256); function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data) external returns (bool); ``` * **`token` must be lisUSD.** Anything else reverts `Flash/token-unsupported`; `maxFlashLoan` returns `0` for it. * `flashFee` applies the `toll` rate and returns an 18-decimal wad. * `data` is forwarded verbatim to your callback — it is the only channel for passing state in. ## Writing the borrower Implement [`IERC3156FlashBorrower`](https://github.com/lista-dao/lista-dao-contracts/blob/master/contracts/interfaces/IERC3156FlashBorrower.sol) and do three things in `onFlashLoan`: reject callers that are not the lender, run your logic, and approve the lender for `amount + fee` before returning `keccak256("ERC3156FlashBorrower.onFlashLoan")`. ```solidity pragma solidity ^0.8.10; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IERC3156FlashBorrower.sol"; import "../interfaces/IERC3156FlashLender.sol"; contract FlashBorrower is IERC3156FlashBorrower { IERC3156FlashLender lender; constructor(IERC3156FlashLender lender_) { lender = lender_; } function flashBorrow(address token, uint256 amount) public { bytes memory data = abi.encode(/* your parameters */); lender.flashLoan(this, token, amount, data); } function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external override returns (bytes32) { require(msg.sender == address(lender), "untrusted lender"); require(initiator == address(this), "untrusted initiator"); // ... your logic. It must leave this contract holding `amount + fee`. IERC20(token).approve(address(lender), amount + fee); return keccak256("ERC3156FlashBorrower.onFlashLoan"); } } ``` Return anything other than that hash and the call reverts `Flash/callback-failed`. Skip the approve, or end the callback short of `amount + fee`, and the lender's `transferFrom` reverts `LisUSD/insufficient-allowance` or `LisUSD/insufficient-balance`. > **Flash loans cannot bid on CDP liquidations.** This fork makes the auction buy side permissioned — `Clipper.take` / `redo` are `auth` and `Interaction.buyFromAuction` is whitelisted. The liquidation surface that *is* open to third parties is on Lista Lending: see [Liquidator Integration](/for-developer/lista-lending/liquidator-integration). ## Source * [`flash.sol`](https://github.com/lista-dao/lista-dao-contracts/blob/master/contracts/flash.sol) — the lender, including the `max` ceiling and `toll` rate. * [`flashBorrower.sol`](https://github.com/lista-dao/lista-dao-contracts/blob/master/contracts/mock/flashBorrower.sol) — a fuller borrower, with branching on the decoded `data`. * [`flash.test.js`](https://github.com/lista-dao/lista-dao-contracts/blob/master/test/flash.test.js) — a worked end-to-end example. # CDP API Read-side endpoints for the **lisUSD CDP**, where each position is backed by a single collateral type (`ilk`). They are keyed by `ilk` (collateral type) and collateral token address, not by a Moolah `marketId`. > The CDP is being wound down — see [Mechanics](/for-developer/collateral-debt-position/mechanics). These feeds serve existing positions. For Moolah markets use [Positions, Liquidation & Emission](/for-developer/services/lending-api/position-liquidation-emission). Base URL, response envelope, and chain selector follow the same conventions as the rest of the API — see [Conventions](/for-developer/services/lending-api/conventions). Pagination on these CDP feeds is its own scheme, `start`/`count` (documented per endpoint below), **not** the `page`/`pageSize` scheme conventions.md documents for the Moolah-market endpoints. ## Liquidation feeds These `/api/v2/liquidations/*` and `/api/v2/liquidated` endpoints serve the **CDP (single-collateral) borrow product**, not Moolah markets. They read from the borrower index and key results by collateral token address. Use [Positions, Liquidation & Emission](/for-developer/services/lending-api/position-liquidation-emission) for Moolah-market liquidations. ### GET /api/v2/liquidations/red Positions that are currently liquidatable (current price has crossed the position's liquidation price). | Parameter | Type | Required | Description | | --------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------- | | `start` | number | No | Offset, snapped down to a multiple of 10 and floored at `0`. Omitting it (or sending garbage) defaults to `0`, not an error. | | `count` | number | No | Page size, snapped down to a multiple of 20 then clamped to `[20, 100]`. Omitting it defaults to `20`. | Response `data`: `{ users: [...] }`, each entry containing `userAddress`, `tokenName`, `collateralCurrency`, `collateral`, `liquidationPrice`, `liquidationCost`, `rangeFromLiquidation`. On this endpoint `rangeFromLiquidation` is always `0` (the positions are already liquidatable), and `liquidationCost` is a high-precision decimal string of up to 20 fractional digits — parse it with a big-number library, not `parseFloat`. ### GET /api/v2/liquidations/orange Positions approaching the liquidation threshold (within the danger band, but not yet liquidatable). Same parameters and response shape as `/red`, but **not the same ordering**: `/red` sorts by liquidation price descending, `/orange` by `rangeFromLiquidation` ascending. Here `rangeFromLiquidation` reflects the remaining buffer to liquidation. ### GET /api/v2/liquidations/auctionUser Look up the borrower(s) and clipper (auction contract) for a given liquidation auction. | Parameter | Type | Required | Description | | ----------- | ------ | -------- | ------------------------- | | `auctionId` | number | No\* | Auction identifier. | | `token` | string | No\* | Collateral token address. | > \* Both are bound unconditionally as equality filters. Omitting either returns an empty `users` array rather than an unfiltered list. Response `data`: `{ users: [{ userAddress, clipperAddress }] }`. ### GET /api/v2/liquidated Recently liquidated CDP positions. | Parameter | Type | Required | Description | | --------- | ------ | -------- | ------------------------------------------ | | `start` | number | No | Offset. Defaults to `0`. | | `count` | number | No | Page size. Defaults to and capped at `20`. | ### GET /api/v2/liquidated/:user Liquidations for one address. `GET /api/v2/liquidated/:user/latest?collateral=` returns the volume-weighted average liquidation price for an address and collateral. > Addresses are stored lower-cased by the indexer and `/liquidated/:user` passes the value through verbatim — send lower-case. ## Market feeds `/api/cdp/market/*` serves the CDP markets themselves. `/info`, `/borrowRate/history` and `/userBorrow/history` each take a required `ilk`. `/list` is a paginated listing filtered by collateral **symbol**, returning the `ilk` per row; `/search` takes a required `typeId=collateral`. # Smart Contract #### Click on the name to navigate to the contract address <table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://bscscan.com/address/0xc1359eD77E6B0CBF9a8130a4C28FBbB87B9501b7">ABACI</a></td></tr><tr><td><a href="https://bscscan.com/address/0xbaf8b40a1e2a7b842289778c1c509b6bede3cc03">ABACI (CLASSIC)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x2dcFb02CE33955b6Cc0aF34033189DE3ac4C0292">CLIP</a></td></tr><tr><td><a href="https://bscscan.com/address/0xd57E7b53a1572d27A04d9c1De2c4D423f1926d0B">DOG</a></td></tr><tr><td><a href="https://bscscan.com/address/0x4C798F81de7736620Cd8e6510158b1fE758e22F7">HayJoin</a></td></tr><tr><td><a href="https://bscscan.com/address/0xfA14F330711A2774eC438856BBCf2c9013c2a6a4">ceaBNBcJoin</a></td></tr><tr><td><a href="https://bscscan.com/address/0x0a1Fd12F73432928C190CAF0810b3B767A59717e">JAR</a></td></tr><tr><td><a href="https://bscscan.com/address/0x787BdEaa29A253e40feB35026c3d05C18CbCA7B3">JUG</a></td></tr><tr><td><a href="https://bscscan.com/address/0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5">lisUSD</a></td></tr><tr><td><a href="https://bscscan.com/address/0x49bc2c4E5B035341b7d92Da4e6B267F7426F3038">SPOT</a></td></tr><tr><td><a href="https://bscscan.com/address/0x33A34eAB3ee892D40420507B820347b1cA2201c4">VAT</a></td></tr><tr><td><a href="https://bscscan.com/address/0x2078A1969Ea581D618FDBEa2C0Dc13Fc15CB9fa7">VOW</a></td></tr><tr><td><a href="https://bscscan.com/address/0xe66395EbA979968e574984268979C49a57EB59Ee">HelioRewards</a></td></tr><tr><td><a href="https://bscscan.com/address/0xa835F890Fcde7679e7F7711aBfd515d2A267Ed0B">HelioProvider</a></td></tr><tr><td><a href="https://bscscan.com/address/0xA186D2363E5048D129E0a35E2fddDe767d4dada8">cerosRouter</a></td></tr><tr><td><a href="https://bscscan.com/address/0x563282106A5B0538f8673c787B3A16D3Cc1DbF1a">CeToken</a></td></tr><tr><td><a href="https://bscscan.com/address/0xf81748d12171De989A5Bbf2d76bf10BFbBaEC596">ceaBNBcOracle</a></td></tr><tr><td><a href="https://bscscan.com/address/0x986b40c2618ff295a49ac442c5ec40febb26cc54">MasterVault</a></td></tr><tr><td><a href="https://bscscan.com/address/0xB68443Ee3e828baD1526b3e0Bdf2Dfc6b1975ec4">Interaction</a></td></tr><tr><td><a href="https://bscscan.com/address/0x272d6589cecc19165cfcd0466f73a648cb1ea700">AuctionProxy</a></td></tr><tr><td><a href="https://bscscan.com/address/0x4b30fcAA7945fE9fDEFD2895aae539ba102Ed6F6">slisBNBx</a></td></tr><tr><td><a href="https://bscscan.com/address/0xB0b84D294e0C75A6abe60171b70edEb2EFd14A1B">slisBNB</a></td></tr><tr><td><a href="https://bscscan.com/address/0x91e49983598685dd5acac90ceb4061a772f6e5ae">GemJoin(slisBNB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xba92899ea8bebb717cfc60507251acbb79a3b959">clipCE(slisBNB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x8ecf78fb59e5a4c26cb218d34db29c4696af89f6">Oracle(slisBNB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x6c813d1d114d0cabf3f82f9e910bc29fe7f96451">CeToken(cewBETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xA230805C28121cc97B348f8209c79BEBEa3839C0">CeETHVault</a></td></tr><tr><td><a href="https://bscscan.com/address/0x0326c157bfF399e25dd684613aEF26DBb40D3BA4">HelioETHProvider</a></td></tr><tr><td><a href="https://bscscan.com/address/0x620e897d529EfECa41E57d0344eBB24f75864D1E">clisETH</a></td></tr><tr><td><a href="https://bscscan.com/address/0xA0cD5EAfa37EBA1d04Fb003512f962f2f73C3e86">CerosETHRouter</a></td></tr><tr><td><a href="https://bscscan.com/address/0x5aEfa6309e8Da3eaBd32745aD5B2c9C1EBE54bef">GemJoin(ethJoin)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xdF9cf824D1822Ab61aFAf5c97353682F6df0a8d5">Clipper(clipEthCE)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x9945e33be177b5fccb90710fee59c548cac8acba">EthOracle</a></td></tr><tr><td><a href="https://bscscan.com/address/0xf45c3b619ee86f653805e007fe211b7e930e0b3b">GemJoin(wBETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x96b64bfcdbe658f2792322ac7a9d2dc215eba48f">clipCE(wBETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x25787055964a8d2a0de4387d6ec9ebc0dc139dd5">Oracle(wBETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xad9eAAe95617c39019aCC42301a1dCa4ea5b6f65">GemJoin(BTCB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xb12fF6FD1885a9Cb2b26302c98092644604B1e92">Clipper(BTCB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x2eeDc4723b1ED2f24afCD9c0e3665061bD2D5642">Oracle(BTCB)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xd7E33948e2a43e7C1ec2F19937bf5bf8BbF9BaE8">GemJoin(ezETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x5784e62b4495c7Cc4B09CcD3f206Cc7128449CE0">Clipper(ezETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xE859f3f6EE5532313C33A02283150E201290F45F">Oracle(ezETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x2367f2Da6fd39De6944218CC9EC706BCdc9a6918">GemJoin(weETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xF21B35EdF7A927799b80F09C395C460C3d31D057">Clipper(weETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xE514851E324B54f152F7D9631ACe1A0a87248b46">Oracle(weETH)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x876cd9a380Ee7712129b52f8293F6f06056c3104">GemJoin(Stone)</a></td></tr><tr><td><a href="https://bscscan.com/address/0x5AaBBBe154C0AFA072e313d46b29592936493b26">Clipper(Stone)</a></td></tr><tr><td><a href="https://bscscan.com/address/0xDF5A8e190CF63D74a4Ec743253fA26D4C753
프로젝트로 돌아가기