Skip to main content

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.

FieldTypeDescription
houruint64Hour of the first request.
parentuint256Batch that took this one over while it waited, zero when none did.
roundHouruint64Round that took the batch, zero while it waits.
usdguint256
assetuint256
valueuint256Sum of the values of its entries.
sharesuint256

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.

FieldTypeDescription
assetuint256Asset held by the contract for this book. Counted, not read from the balance.
collateralint256Deposits to Lighter minus withdrawals from it, without funding.
shortSizeuint256Asset sold short. A multiple of the lot of the market.
shortNotionalint256USDG the open short was sold for.
adjustmentint256Losses that are in no other field. Never positive.
capitalCashuint256USDG of the capital that waits in the vault.
boxCashuint256USDG of the Funding Box in the vault.
boxReceivableint256USDG of the Funding Box still at Lighter. Negative when the box owes Lighter. boxCash + boxReceivable is never negative.
assetToSelluint256Asset that a protection must still sell from this book.

Command​

Permission to change the short and trade the asset by a limited amount.

FieldTypeDescription
kindCommandKind
opensShortboolTrue when the short grows.
sentByContractboolTrue when the order was sent by the contract, so it has no deadline.
reportedboolReports said that nothing more will be filled.
finishedboolThe books are final.
issuedAtuint64
deadlineuint64Last moment at which a fill counts. Zero without a deadline.
sizeuint256
filledSizeuint256
filledNotionaluint256
sellsAssetboolAmount of the asset the command may trade, and the result so far.
assetLimituint256
assetTradeduint256
usdgTradeduint256
costint256Cost 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.

FieldTypeDescription
payoutEntryPayout
seriesIduint256Series to split into. Shares when it no longer runs.
minYieldPriceuint256Least 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​

FieldTypeDescription
owneraddress
batchuint256
usdguint256
assetuint256
valueuint256USDG value when it was requested. Counts until the round is final.
cancelledbool
sharesPaidbool
assetPaidbool
usdgPaiduint256
choiceEntryChoice

ExitRequest​

FieldTypeDescription
owneraddress
batchuint256
sharesuint256
usdgPaiduint256
cancelledbool
nextuint256Request 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.

FieldTypeDescription
commandIduint256
sizeuint256
notionaluint256
priceRoundIduint80Chainlink round that was in force while the command was open. Only read when the size grew since the report before.
doneboolNothing more will be filled.

HoldReason​

Why the vault is held. Several reasons can be active together.

BitValueDescription
REPORT_LATE1 << 0No valid hourly report in time. Ends when the last reported hour is recent again.
REPORT_MISMATCH1 << 1The two reports of the same time differ. Ends when they match.
REPORT_LIMIT1 << 2Matching reports broke a limit. Ends when accepted as exceptional, or replaced.
POSITION1 << 3Asset and short differ too much. Judged by reports, finished commands, final rounds and public sales.
GUARD1 << 4guard() was used. Ends when reports settle its order.
EMERGENCY_EXIT1 << 5emergencyExit() was used. Ends when reports settle its order.
PRICE1 << 6The 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.

FieldTypeDescription
labelstringPart of every token name of the market, such as ETH.
assetaddress
priceFeedaddressChainlink price of the asset in USD.
pooladdressUniswap v3 pool of the asset and USDG.
lighterMarketuint16
lighterSizeDecimalsuint8
lighterPriceDecimalsuint8
maintenanceMarginBpsuint16Equity over the value of a position below which Lighter liquidates it.
fundingLimitHouruint64
fundingLimitDayuint64
fundingLimitMonthuint64
positionToleranceuint128
fillPriceToleranceBpsuint16Largest fair difference between a price at Lighter and Chainlink.
liquidationMarginBpsuint16Margin of the books at or below which a liquidation is believable.
maxPriceAgeuint32
twapToleranceBpsuint16
swapToleranceBpsuint16
contractOrderToleranceBpsuint16Worst price of an order sent by the contract, above the Chainlink price. Its fills may differ as much.
adjustRiseBpsuint16
guardRiseBpsuint16
emergencyRiseBpsuint16
seedDeposituint64First deposit. Its shares stay locked.
seedCollateraluint64Part of the seed that creates the Lighter account. The rest pays for the first asset.
minDeposituint64
yieldPoolStartPriceuint64USDG for 1e18 Yield when the pool is created.

Report​

All Lighter accounts of the vault together, at one moment.

FieldTypeDescription
kindReportKind
numberuint64Rises by one with every accepted report.
timeuint64Moment described. An hourly report is exactly on the hour, an execution report never.
fundingint256Funding of the hour that ended at time. Positive is received. Zero in an execution report.
shortSizeuint256
cashint256Account value plus shortSize times the price Lighter used for it. Holds no asset price.
depositsCrediteduint256Everything credited from outside since the start, also what others sent.
withdrawalsExecuteduint256Withdrawals to the vault that Lighter executed since the start.
liquidatedboolLighter reduced the short by itself, by liquidation or auto-deleveraging.
liquidatedSizeuint256
liquidatedNotionaluint256
liquidationRoundIduint80Chainlink round in force since the report before. Only read with liquidated.
fillsFill[]

ReportKind​

An enum with these values, from 0: Hourly, Execution.

Round​

One hourly round. A request gets its part of the totals.

FieldTypeDescription
phaseRoundPhase
houruint64
entryBatchuint256Batches that the round took, zero for a kind it did not take.
exitBatchuint256
entryCommandIduint256
exitCommandIduint256
entryUsdguint256
entryAssetuint256
entryPriceuint256Price for the asset, 8 decimals, the lower of Chainlink and pool.
assetPriceuint256Chainlink price when the round closed, 8 decimals.
entryValueuint256Denominator of entry parts. Not below the sum of all requests.
sharePriceuint256USD per share when the round closed, 18 decimals.
sharesMinteduint256
refundUsdguint256
refundUsdgFundeduint256
refundAssetuint256
exitSharesuint256
exitSharesReturneduint256Shares that were not closed, and the batch they went to.
carryBatchuint256
exitUsdguint256
exitUsdgFundeduint256

RoundPhase​

An enum with these values, from 0: None, Executing, Finalized, Aborted.

Series​

FieldTypeDescription
fixaddress
yieldaddress
openedAtuint64
maturityuint64
sharePriceAtOpenuint256USD per share, 18 decimals.
indexAtOpenint256
sharesPerPackuint256Shares in one pack, 18 decimals. One pack is worth 1 USD when the series opens.
packsuint256
lockedSharesuint256
settledbool
packsAtSettlementuint256Packs at settlement. Later redemptions do not change it.
yieldUsdguint256USDG for all Yield, and the part that arrived.
yieldUsdgFundeduint256
fixSharesuint256Shares for all Fix.
yieldLimituint256Wind-down: what Yield gets first from one pack, USD with 18 decimals.
fixRedeemeduint256
yieldRedeemeduint256
packsExchangeduint256Wind-down: packs whose shares were exchanged.
feeRateuint256Protocol 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.

FieldTypeDescription
purposeWithdrawalPurpose
refuint256Series id or round hour.
amountuint256
receiveduint256