Types
The structs and enums that the functions and events of the Gedho contracts take and return.
Batch
Requests of one kind, entries or exits, that go into a round together.
| Field | Type | Description |
|---|---|---|
hour | uint64 | Hour of the first request. |
parent | uint256 | Batch that took this one over while it waited, zero when none did. |
roundHour | uint64 | Round that took the batch, zero while it waits. |
usdg | uint256 | |
asset | uint256 | |
value | uint256 | Sum of the values of its entries. |
shares | uint256 |
Book
One set of books: the vault, or the part of a round that is leaving or entering.
USDG has 6 decimals, the asset and the short those of the token. Money at Lighter that belongs to the book is collateral + shortNotional + adjustment + boxReceivable.
| Field | Type | Description |
|---|---|---|
asset | uint256 | Asset held by the contract for this book. Counted, not read from the balance. |
collateral | int256 | Deposits to Lighter minus withdrawals from it, without funding. |
shortSize | uint256 | Asset sold short. A multiple of the lot of the market. |
shortNotional | int256 | USDG the open short was sold for. |
adjustment | int256 | Losses that are in no other field. Never positive. |
capitalCash | uint256 | USDG of the capital that waits in the vault. |
boxCash | uint256 | USDG of the Funding Box in the vault. |
boxReceivable | int256 | USDG of the Funding Box still at Lighter. Negative when the box owes Lighter. boxCash + boxReceivable is never negative. |
assetToSell | uint256 | Asset that a protection must still sell from this book. |
Command
Permission to change the short and trade the asset by a limited amount.
| Field | Type | Description |
|---|---|---|
kind | CommandKind | |
opensShort | bool | True when the short grows. |
sentByContract | bool | True when the order was sent by the contract, so it has no deadline. |
reported | bool | Reports said that nothing more will be filled. |
finished | bool | The books are final. |
issuedAt | uint64 | |
deadline | uint64 | Last moment at which a fill counts. Zero without a deadline. |
size | uint256 | |
filledSize | uint256 | |
filledNotional | uint256 | |
sellsAsset | bool | Amount of the asset the command may trade, and the result so far. |
assetLimit | uint256 | |
assetTraded | uint256 | |
usdgTraded | uint256 | |
cost | int256 | Cost against the Chainlink price of the part that belongs to the vault, short and asset together. Negative is a gain. Only a positive total is charged. |
CommandKind
An enum with these values, from 0: Entry, Exit, Adjust, Align, Reset, Reopen, Guard, EmergencyExit, AdminClose, WindDown.
EntryChoice
Chosen with the deposit, and never changed.
| Field | Type | Description |
|---|---|---|
payout | EntryPayout | |
seriesId | uint256 | Series to split into. Shares when it no longer runs. |
minYieldPrice | uint256 | Least USDG for 1e18 Yield. |
EntryPayout
What the owner of an entry receives after its round.
An enum with these values, from 0: Shares, FixAndYield, FixAndUsdg.
EntryRequest
| Field | Type | Description |
|---|---|---|
owner | address | |
batch | uint256 | |
usdg | uint256 | |
asset | uint256 | |
value | uint256 | USDG value when it was requested. Counts until the round is final. |
cancelled | bool | |
sharesPaid | bool | |
assetPaid | bool | |
usdgPaid | uint256 | |
choice | EntryChoice |
ExitRequest
| Field | Type | Description |
|---|---|---|
owner | address | |
batch | uint256 | |
shares | uint256 | |
usdgPaid | uint256 | |
cancelled | bool | |
next | uint256 | Request for the shares that the round could not close, zero while there is none. |
Fill
Total fills of one command since it was issued. A report holds every command that was issued at or before its time and not yet reported as done, once, operator commands first, then those sent by the contract, each in the order of their id. Operator commands without an order are left out.
| Field | Type | Description |
|---|---|---|
commandId | uint256 | |
size | uint256 | |
notional | uint256 | |
priceRoundId | uint80 | Chainlink round that was in force while the command was open. Only read when the size grew since the report before. |
done | bool | Nothing more will be filled. |
HoldReason
Why the vault is held. Several reasons can be active together.
| Bit | Value | Description |
|---|---|---|
REPORT_LATE | 1 << 0 | No valid hourly report in time. Ends when the last reported hour is recent again. |
REPORT_MISMATCH | 1 << 1 | The two reports of the same time differ. Ends when they match. |
REPORT_LIMIT | 1 << 2 | Matching reports broke a limit. Ends when accepted as exceptional, or replaced. |
POSITION | 1 << 3 | Asset and short differ too much. Judged by reports, finished commands, final rounds and public sales. |
GUARD | 1 << 4 | guard() was used. Ends when reports settle its order. |
EMERGENCY_EXIT | 1 << 5 | emergencyExit() was used. Ends when reports settle its order. |
PRICE | 1 << 6 | The asset price is old or disagrees with the pool. Ends when the price is good again. |
MarketTerms
Everything that differs between two markets. Set once, when the market is deployed.
Percentages are in basis points (1 bp = 0.01%), except funding limits, which are scaled by 1e18.
| Field | Type | Description |
|---|---|---|
label | string | Part of every token name of the market, such as ETH. |
asset | address | |
priceFeed | address | Chainlink price of the asset in USD. |
pool | address | Uniswap v3 pool of the asset and USDG. |
lighterMarket | uint16 | |
lighterSizeDecimals | uint8 | |
lighterPriceDecimals | uint8 | |
maintenanceMarginBps | uint16 | Equity over the value of a position below which Lighter liquidates it. |
fundingLimitHour | uint64 | |
fundingLimitDay | uint64 | |
fundingLimitMonth | uint64 | |
positionTolerance | uint128 | |
fillPriceToleranceBps | uint16 | Largest fair difference between a price at Lighter and Chainlink. |
liquidationMarginBps | uint16 | Margin of the books at or below which a liquidation is believable. |
maxPriceAge | uint32 | |
twapToleranceBps | uint16 | |
swapToleranceBps | uint16 | |
contractOrderToleranceBps | uint16 | Worst price of an order sent by the contract, above the Chainlink price. Its fills may differ as much. |
adjustRiseBps | uint16 | |
guardRiseBps | uint16 | |
emergencyRiseBps | uint16 | |
seedDeposit | uint64 | First deposit. Its shares stay locked. |
seedCollateral | uint64 | Part of the seed that creates the Lighter account. The rest pays for the first asset. |
minDeposit | uint64 | |
yieldPoolStartPrice | uint64 | USDG for 1e18 Yield when the pool is created. |
Report
All Lighter accounts of the vault together, at one moment.
| Field | Type | Description |
|---|---|---|
kind | ReportKind | |
number | uint64 | Rises by one with every accepted report. |
time | uint64 | Moment described. An hourly report is exactly on the hour, an execution report never. |
funding | int256 | Funding of the hour that ended at time. Positive is received. Zero in an execution report. |
shortSize | uint256 | |
cash | int256 | Account value plus shortSize times the price Lighter used for it. Holds no asset price. |
depositsCredited | uint256 | Everything credited from outside since the start, also what others sent. |
withdrawalsExecuted | uint256 | Withdrawals to the vault that Lighter executed since the start. |
liquidated | bool | Lighter reduced the short by itself, by liquidation or auto-deleveraging. |
liquidatedSize | uint256 | |
liquidatedNotional | uint256 | |
liquidationRoundId | uint80 | Chainlink round in force since the report before. Only read with liquidated. |
fills | Fill[] |
ReportKind
An enum with these values, from 0: Hourly, Execution.
Round
One hourly round. A request gets its part of the totals.
| Field | Type | Description |
|---|---|---|
phase | RoundPhase | |
hour | uint64 | |
entryBatch | uint256 | Batches that the round took, zero for a kind it did not take. |
exitBatch | uint256 | |
entryCommandId | uint256 | |
exitCommandId | uint256 | |
entryUsdg | uint256 | |
entryAsset | uint256 | |
entryPrice | uint256 | Price for the asset, 8 decimals, the lower of Chainlink and pool. |
assetPrice | uint256 | Chainlink price when the round closed, 8 decimals. |
entryValue | uint256 | Denominator of entry parts. Not below the sum of all requests. |
sharePrice | uint256 | USD per share when the round closed, 18 decimals. |
sharesMinted | uint256 | |
refundUsdg | uint256 | |
refundUsdgFunded | uint256 | |
refundAsset | uint256 | |
exitShares | uint256 | |
exitSharesReturned | uint256 | Shares that were not closed, and the batch they went to. |
carryBatch | uint256 | |
exitUsdg | uint256 | |
exitUsdgFunded | uint256 |
RoundPhase
An enum with these values, from 0: None, Executing, Finalized, Aborted.
Series
| Field | Type | Description |
|---|---|---|
fix | address | |
yield | address | |
openedAt | uint64 | |
maturity | uint64 | |
sharePriceAtOpen | uint256 | USD per share, 18 decimals. |
indexAtOpen | int256 | |
sharesPerPack | uint256 | Shares in one pack, 18 decimals. One pack is worth 1 USD when the series opens. |
packs | uint256 | |
lockedShares | uint256 | |
settled | bool | |
packsAtSettlement | uint256 | Packs at settlement. Later redemptions do not change it. |
yieldUsdg | uint256 | USDG for all Yield, and the part that arrived. |
yieldUsdgFunded | uint256 | |
fixShares | uint256 | Shares for all Fix. |
yieldLimit | uint256 | Wind-down: what Yield gets first from one pack, USD with 18 decimals. |
fixRedeemed | uint256 | |
yieldRedeemed | uint256 | |
packsExchanged | uint256 | Wind-down: packs whose shares were exchanged. |
feeRate | uint256 | Protocol fee of GedhoControl when the series opened, 1e18 is 100%. Charged at settlement. Last, so that the series of an upgraded proxy keep their fields. |
Status
What the vault allows right now.
The order of strength is WindDown, Emergency, Held, then NoShort or Normal.
An enum with these values, from 0: Normal, Held, Emergency, NoShort, WindDown.
WithdrawalPurpose
An enum with these values, from 0: SeriesPayment, ExitPayout, EntryRefund, FundingSweep, Capital, FeeWithdrawal, NoTicket.
WithdrawalTicket
Money asked from Lighter. Arrivals fill series payments first, then exit payouts and entry refunds, then funding sweeps and capital, then the protocol fee, each in order of their number.
| Field | Type | Description |
|---|---|---|
purpose | WithdrawalPurpose | |
ref | uint256 | Series id or round hour. |
amount | uint256 | |
received | uint256 |