Skip to main content

GedhoQueue

Requests to enter and leave, the hourly round, and the claims.

Inherits Upgradeable base.

Anyone​

requestEntry​

function requestEntry(
uint256 usdg,
uint256 asset,
address owner,
EntryChoice calldata choice
) external returns (uint256 requestId);

Sends USDG, the asset, or both. The money counts only after the round is final.

ParameterTypeDescription
usdguint256
assetuint256
owneraddress
choiceEntryChoiceWhat the owner receives after the round.
ReturnsType
requestIduint256

requestExit​

function requestExit(
uint256 shares,
address owner
) external returns (uint256 requestId);

Locks FV that will leave.

ParameterType
sharesuint256
owneraddress
ReturnsType
requestIduint256

closeRound​

function closeRound() external;

Closes the round of this hour: sets prices and issues the orders.

finalizeRound​

function finalizeRound() external;

Finalizes the open round after its reports and asset trades.

claimEntry​

function claimEntry(
uint256 requestId
) external returns (uint256 shares, uint256 refundUsdg, uint256 refundAsset);

Pays FV, the asset and the USDG that arrived so far to the owner of the request. Call it again when more USDG arrived. Anyone can call it, but when the owner chose more than FV, only the owner takes the FV this way.

Not stopped by any status.

ParameterType
requestIduint256
ReturnsType
sharesuint256
refundUsdguint256
refundAssetuint256

fulfillEntry​

function fulfillEntry(
uint256 requestId
) external returns (EntryPayout payout, uint256 shares, uint256 packs, uint256 usdg);

Carries out the choice of the owner once its round is final: splits the FV of the request into Fix and Yield of the chosen series, and sells the Yield in its pool when asked. The owner receives Fix and Yield when the sale gives less than the least price or the pool is missing, and FV when the series no longer splits. Leftover FV below one pack goes to the owner.

Not for USDG and the asset that come back; claimEntry pays those.

ParameterType
requestIduint256
ReturnsType
payoutEntryPayout
sharesuint256
packsuint256
usdguint256

claimExit​

function claimExit(uint256 requestId) external returns (uint256 usdg);

Pays the USDG that arrived so far to the owner of the request. Call it again when more arrived. Anyone can call it.

Not stopped by any status.

ParameterType
requestIduint256
ReturnsType
usdguint256

carryExit​

function carryExit(uint256 requestId) external returns (uint256 nextRequestId);

Makes a request for the shares that the round of requestId could not close. They are already waiting for the next round without it. Anyone can call it, once.

ParameterType
requestIduint256
ReturnsType
nextRequestIduint256

Owner of the request​

cancelEntry​

function cancelEntry(uint256 requestId) external;

Returns a deposit that no round took.

Owner only. Not stopped by any status.

ParameterType
requestIduint256

cancelExit​

function cancelExit(uint256 requestId) external;

Returns FV that no round took.

Owner only. Not stopped by any status.

ParameterType
requestIduint256

Deployer​

initialize​

function initialize() external;

Marks the proxy as initialized, once. The queue has nothing else to set.

The vault​

fundRound​

function fundRound(uint64 hour, uint256 exitUsdg, uint256 refundUsdg) external;

Counts USDG that arrived for a round.

Vault only.

ParameterType
houruint64
exitUsdguint256
refundUsdguint256

abortRound​

function abortRound(
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned
) external;

Ends the open round when the vault winds down.

Vault only.

ParameterType
sharesMinteduint256
refundUsdguint256
refundAssetuint256
exitSharesReturneduint256

Read​

entryRequest​

function entryRequest(
uint256 requestId
) external view returns (EntryRequest memory);
ParameterType
requestIduint256
ReturnsType
-EntryRequest

exitRequest​

function exitRequest(
uint256 requestId
) external view returns (ExitRequest memory);
ParameterType
requestIduint256
ReturnsType
-ExitRequest

batch​

function batch(uint256 batchId) external view returns (Batch memory);
ParameterType
batchIduint256
ReturnsType
-Batch

liveBatches​

function liveBatches(

) external view returns (uint256 newEntry, uint256 waitingEntry, uint256 newExit, uint256 waitingExit);

Batches of new requests, and the batches that wait for a round.

ReturnsType
newEntryuint256
waitingEntryuint256
newExituint256
waitingExituint256

round​

function round(uint64 hour) external view returns (Round memory);
ParameterType
houruint64
ReturnsType
-Round

openRound​

function openRound() external view returns (uint64);

Hour of the round that is executing, zero when there is none.

ReturnsType
-uint64

previewEntry​

function previewEntry(
uint256 requestId
) external view returns (uint256 shares, uint256 refundUsdg, uint256 refundAsset, uint256 usdgWaiting);
ParameterType
requestIduint256
ReturnsType
sharesuint256
refundUsdguint256
refundAssetuint256
usdgWaitinguint256

previewExit​

function previewExit(
uint256 requestId
) external view returns (uint256 usdg, uint256 usdgWaiting, uint256 sharesWaiting);
ParameterType
requestIduint256
ReturnsTypeDescription
usdguint256What claimExit() pays now.
usdgWaitinguint256USDG of the request that has not arrived.
sharesWaitinguint256FV that waits for a round: all of it until the round is final, then the part that came back until carryExit() makes it a request.

Events​

EntryRequested​

event EntryRequested(
uint256 indexed requestId,
address indexed owner,
uint256 indexed batch,
uint256 usdg,
uint256 asset,
EntryChoice choice
);
ParameterType
requestId (indexed)uint256
owner (indexed)address
batch (indexed)uint256
usdguint256
assetuint256
choiceEntryChoice

EntryCancelled​

event EntryCancelled(uint256 indexed requestId, address indexed owner);
ParameterType
requestId (indexed)uint256
owner (indexed)address

EntryClaimed​

event EntryClaimed(
uint256 indexed requestId,
address indexed owner,
uint256 shares,
uint256 refundUsdg,
uint256 refundAsset
);
ParameterType
requestId (indexed)uint256
owner (indexed)address
sharesuint256
refundUsdguint256
refundAssetuint256

EntryFulfilled​

event EntryFulfilled(
uint256 indexed requestId,
address indexed owner,
EntryPayout payout,
uint256 shares,
uint256 packs,
uint256 usdg
);

The choice of the owner was carried out. payout is what the owner received: the choice, Fix and Yield when the Yield sold for too little, or FV when the series no longer splits.

ParameterType
requestId (indexed)uint256
owner (indexed)address
payoutEntryPayout
sharesuint256
packsuint256
usdguint256

ExitRequested​

event ExitRequested(
uint256 indexed requestId,
address indexed owner,
uint256 indexed batch,
uint256 shares
);
ParameterType
requestId (indexed)uint256
owner (indexed)address
batch (indexed)uint256
sharesuint256

ExitCancelled​

event ExitCancelled(
uint256 indexed requestId,
address indexed owner,
uint256 shares
);
ParameterType
requestId (indexed)uint256
owner (indexed)address
sharesuint256

ExitClaimed​

event ExitClaimed(
uint256 indexed requestId,
address indexed owner,
uint256 usdg
);
ParameterType
requestId (indexed)uint256
owner (indexed)address
usdguint256

ExitCarried​

event ExitCarried(
uint256 indexed requestId,
uint256 indexed nextRequestId,
uint256 shares
);

The shares that a round could not close are now a request of their own.

ParameterType
requestId (indexed)uint256
nextRequestId (indexed)uint256
sharesuint256

BatchMerged​

event BatchMerged(uint256 indexed batch, uint256 indexed parent);
ParameterType
batch (indexed)uint256
parent (indexed)uint256

BatchTaken​

event BatchTaken(uint256 indexed batch, uint64 indexed roundHour);
ParameterType
batch (indexed)uint256
roundHour (indexed)uint64

RoundClosed​

event RoundClosed(
uint64 indexed hour,
uint256 entryUsdg,
uint256 entryAsset,
uint256 entryPrice,
uint256 entryValue,
uint256 exitShares,
uint256 sharePrice,
uint256 assetPrice
);
ParameterType
hour (indexed)uint64
entryUsdguint256
entryAssetuint256
entryPriceuint256
entryValueuint256
exitSharesuint256
sharePriceuint256
assetPriceuint256

RoundFinalized​

event RoundFinalized(
uint64 indexed hour,
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned,
uint256 carryBatch,
uint256 exitUsdg
);
ParameterType
hour (indexed)uint64
sharesMinteduint256
refundUsdguint256
refundAssetuint256
exitSharesReturneduint256
carryBatchuint256
exitUsdguint256

RoundAborted​

event RoundAborted(
uint64 indexed hour,
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned
);
ParameterType
hour (indexed)uint64
sharesMinteduint256
refundUsdguint256
refundAssetuint256
exitSharesReturneduint256

RoundFunded​

event RoundFunded(uint64 indexed hour, uint256 exitUsdg, uint256 refundUsdg);
ParameterType
hour (indexed)uint64
exitUsdguint256
refundUsdguint256

Errors​

NotOwner​

error NotOwner(uint256 requestId);

The caller does not own the request.

ParameterType
requestIduint256

RequestClosed​

error RequestClosed(uint256 requestId);

The request does not exist, was cancelled, or was fully paid.

ParameterType
requestIduint256

RequestTaken​

error RequestTaken(uint256 requestId);

A round already took the request.

ParameterType
requestIduint256

RoundNotReady​

error RoundNotReady(uint64 hour);

The round cannot close now, or nothing can be taken.

ParameterType
houruint64

RoundExecuting​

error RoundExecuting(uint64 hour);

An earlier round must be finalized first.

ParameterType
houruint64

NoOpenRound​

error NoOpenRound();

No round is executing.

NothingToClaim​

error NothingToClaim(uint256 requestId);

There is nothing to pay yet.

ParameterType
requestIduint256

StatusForbids​

error StatusForbids(Status status);

The status does not allow this.

ParameterType
statusStatus

BelowMinimum​

error BelowMinimum(uint256 value, uint256 minimum);

The deposit is below the minimum.

ParameterType
valueuint256
minimumuint256

VaultFull​

error VaultFull(uint256 room);

The vault would grow larger than one order at Lighter can close.

ParameterType
roomuint256

ZeroAmount​

error ZeroAmount();

Nothing was sent.

NoOwner​

error NoOwner();

A request needs an owner.

LighterStopped​

error LighterStopped();

Lighter stopped for good.

NotVault​

error NotVault();

Only the vault can call this.

NoChoice​

error NoChoice(uint256 requestId);

The owner chose FV, which claimEntry pays.

ParameterType
requestIduint256

BadChoice​

error BadChoice();

Fix + USDG needs a least price for the Yield.

GasTooLow​

error GasTooLow();

Too little gas for the sale of the Yield. Call again with more.

WrongRouter​

error WrongRouter();

The router does not swap in the pools of the factory.