You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(asset-leasing): convert markdown tables to bullet lists
Converts all 6 markdown tables in defi/asset-leasing/anchor/README.md
to bullet lists (parameter-values example, state/data accounts, token
vaults, user accounts, error catalogue, test matrix).
Tables don't render cleanly on viewers narrower or wider than ~76 chars
(mobile, terminal, narrow editor split); bullet lists work everywhere.
No information lost; wider account tables rewritten as natural prose
rather than mechanical column-by-column key/value bullets.
|`Lease`| yes |`["lease", holder, lease_id]`| data | program | all the lease parameters and current lifecycle state (see below) |
184
+
-**`Lease`** - program-derived address with seeds `["lease", holder, lease_id]`. Data account owned by the program, holding all the lease parameters and current lifecycle state (see below).
|`leased_vault`| yes |`["leased_vault", lease]`| token account | itself (program-derived address-signed) |`leased_amount` while `Listed`; 0 while `Active` (short seller has the tokens); full amount again briefly inside `return_lease`|
195
-
|`collateral_vault`| yes |`["collateral_vault", lease]`| token account | itself (program-derived address-signed) | 0 while `Listed`; `collateral_amount` while `Active`, decreasing as lease fee streams out and increasing on `top_up_collateral`|
188
+
-**`leased_vault`** - program-derived address with seeds `["leased_vault", lease]`. Token account whose authority is itself (program-derived-address-signed). Holds `leased_amount` while `Listed`; `0` while `Active` (the short seller has the tokens); full amount again briefly inside `return_lease`.
189
+
-**`collateral_vault`** - program-derived address with seeds `["collateral_vault", lease]`. Token account whose authority is itself (program-derived-address-signed). Holds `0` while `Listed`; `collateral_amount` while `Active`, decreasing as lease fee streams out and increasing on `top_up_collateral`.
196
190
197
191
### User accounts passed in
198
192
199
-
| Account | Owner | Purpose |
200
-
|---|---|---|
201
-
|`holder` wallet | user |`create_lease` signer, receives the lease fee and final recovery |
|`keeper` wallet | user |`liquidate` signer, receives the bounty |
204
-
|`payer` wallet | user |`pay_lease_fee` signer (can be anyone, not just the short seller) |
205
-
|`holder_leased_account`| token account | holder's [associated token account](https://solana.com/docs/terminology) for the leased mint; source on `create_lease`, destination on `return_lease` / `close_expired`|
206
-
|`holder_collateral_account`| token account | holder's associated token account for the collateral mint; destination for the lease fee and liquidation proceeds |
207
-
|`short_seller_leased_account`| token account | short seller's associated token account for the leased mint; destination on `take_lease`, source on `return_lease`|
208
-
|`short_seller_collateral_account`| token account | short seller's associated token account for the collateral mint; source on `take_lease` / `top_up_collateral`, destination for collateral refund on `return_lease`|
209
-
|`keeper_collateral_account`| token account | keeper's associated token account for the collateral mint; receives the liquidation bounty |
210
-
|`price_update`| Pyth Receiver program |`PriceUpdateV2` account for the feed the lease is pinned to |
193
+
-**`holder` wallet** (user-owned) - `create_lease` signer, receives the lease fee and final recovery.
-**`keeper` wallet** (user-owned) - `liquidate` signer, receives the bounty.
196
+
-**`payer` wallet** (user-owned) - `pay_lease_fee` signer (can be anyone, not just the short seller).
197
+
-**`holder_leased_account`** - holder's [associated token account](https://solana.com/docs/terminology) for the leased mint; source on `create_lease`, destination on `return_lease` / `close_expired`.
198
+
-**`holder_collateral_account`** - holder's associated token account for the collateral mint; destination for the lease fee and liquidation proceeds.
199
+
-**`short_seller_leased_account`** - short seller's associated token account for the leased mint; destination on `take_lease`, source on `return_lease`.
200
+
-**`short_seller_collateral_account`** - short seller's associated token account for the collateral mint; source on `take_lease` / `top_up_collateral`, destination for collateral refund on `return_lease`.
201
+
-**`keeper_collateral_account`** - keeper's associated token account for the collateral mint; receives the liquidation bounty.
202
+
-**`price_update`** - `PriceUpdateV2` account owned by the Pyth Receiver program, for the feed the lease is pinned to.
211
203
212
204
### Fields on `Lease`
213
205
@@ -743,24 +735,22 @@ All of the following come from [`errors.rs`](programs/asset-leasing/src/errors.r
743
735
and are enforced by either an Anchor constraint or a `require!` in the
744
736
handler:
745
737
746
-
| Error | When |
747
-
|---|---|
748
-
|`InvalidLeaseStatus`| Action tried against a lease in the wrong state (e.g. `take_lease` on a lease that is already `Active`) |
749
-
|`InvalidDuration`|`duration_seconds <= 0` on `create_lease`|
750
-
|`InvalidLeasedAmount`|`leased_amount == 0` on `create_lease`|
751
-
|`InvalidCollateralAmount`|`required_collateral_amount == 0` on `create_lease`; `amount == 0` on `top_up_collateral`|
752
-
|`InvalidLeaseFeePerSecond`|`lease_fee_per_second == 0` on `create_lease`|
753
-
|`InvalidMaintenanceMargin`|`maintenance_margin_basis_points == 0` or `> 50_000` on `create_lease`|
754
-
|`InvalidLiquidationBounty`|`liquidation_bounty_basis_points > 2_000` on `create_lease`|
755
-
|`LeaseExpired`| Reserved; not currently used (lease fee accrual naturally caps at `end_timestamp`) |
756
-
|`LeaseNotExpired`|`close_expired` called on an `Active` lease before `end_timestamp`|
757
-
|`PositionHealthy`|`liquidate` called on a lease that passes the maintenance-margin check |
758
-
|`StalePrice`| Pyth price update older than 60 s, or has a future `publish_time`, or fails discriminator / length check |
759
-
|`NonPositivePrice`| Pyth price is `<= 0`|
760
-
|`MathOverflow`| Any of the `checked_*` arithmetic returned `None`|
761
-
|`Unauthorised`| Lease-modifying handler called by someone who is not the registered short seller (`top_up_collateral`, `return_lease`) |
762
-
|`LeasedMintEqualsCollateralMint`|`create_lease` called with the same mint for both sides |
763
-
|`PriceFeedMismatch`|`liquidate` called with a Pyth update whose `feed_id` does not match `lease.feed_id`|
738
+
-**`InvalidLeaseStatus`** - action tried against a lease in the wrong state (e.g. `take_lease` on a lease that is already `Active`).
739
+
-**`InvalidDuration`** - `duration_seconds <= 0` on `create_lease`.
740
+
-**`InvalidLeasedAmount`** - `leased_amount == 0` on `create_lease`.
741
+
-**`InvalidCollateralAmount`** - `required_collateral_amount == 0` on `create_lease`; `amount == 0` on `top_up_collateral`.
742
+
-**`InvalidLeaseFeePerSecond`** - `lease_fee_per_second == 0` on `create_lease`.
743
+
-**`InvalidMaintenanceMargin`** - `maintenance_margin_basis_points == 0` or `> 50_000` on `create_lease`.
744
+
-**`InvalidLiquidationBounty`** - `liquidation_bounty_basis_points > 2_000` on `create_lease`.
745
+
-**`LeaseExpired`** - reserved; not currently used (lease fee accrual naturally caps at `end_timestamp`).
746
+
-**`LeaseNotExpired`** - `close_expired` called on an `Active` lease before `end_timestamp`.
747
+
-**`PositionHealthy`** - `liquidate` called on a lease that passes the maintenance-margin check.
748
+
-**`StalePrice`** - Pyth price update older than 60 s, or has a future `publish_time`, or fails discriminator / length check.
749
+
-**`NonPositivePrice`** - Pyth price is `<= 0`.
750
+
-**`MathOverflow`** - any of the `checked_*` arithmetic returned `None`.
751
+
-**`Unauthorised`** - lease-modifying handler called by someone who is not the registered short seller (`top_up_collateral`, `return_lease`).
752
+
-**`LeasedMintEqualsCollateralMint`** - `create_lease` called with the same mint for both sides.
753
+
-**`PriceFeedMismatch`** - `liquidate` called with a Pyth update whose `feed_id` does not match `lease.feed_id`.
764
754
765
755
### 4.2 Guarded design choices worth knowing
766
756
@@ -897,19 +887,17 @@ test top_up_collateral_increases_vault_balance ... ok
0 commit comments