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.
| Parameter | Type | Description |
|---|
usdg | uint256 | |
asset | uint256 | |
owner | address | |
choice | EntryChoice | What the owner receives after the round. |
| Returns | Type |
|---|
requestId | uint256 |
requestExit
function requestExit(
uint256 shares,
address owner
) external returns (uint256 requestId);
Locks FV that will leave.
| Parameter | Type |
|---|
shares | uint256 |
owner | address |
| Returns | Type |
|---|
requestId | uint256 |
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.
| Parameter | Type |
|---|
requestId | uint256 |
| Returns | Type |
|---|
shares | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
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.
| Parameter | Type |
|---|
requestId | uint256 |
| Returns | Type |
|---|
payout | EntryPayout |
shares | uint256 |
packs | uint256 |
usdg | uint256 |
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.
| Parameter | Type |
|---|
requestId | uint256 |
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.
| Parameter | Type |
|---|
requestId | uint256 |
| Returns | Type |
|---|
nextRequestId | uint256 |
Owner of the request
cancelEntry
function cancelEntry(uint256 requestId) external;
Returns a deposit that no round took.
Owner only. Not stopped by any status.
| Parameter | Type |
|---|
requestId | uint256 |
cancelExit
function cancelExit(uint256 requestId) external;
Returns FV that no round took.
Owner only. Not stopped by any status.
| Parameter | Type |
|---|
requestId | uint256 |
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.
| Parameter | Type |
|---|
hour | uint64 |
exitUsdg | uint256 |
refundUsdg | uint256 |
abortRound
function abortRound(
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned
) external;
Ends the open round when the vault winds down.
Vault only.
| Parameter | Type |
|---|
sharesMinted | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
exitSharesReturned | uint256 |
Read
entryRequest
function entryRequest(
uint256 requestId
) external view returns (EntryRequest memory);
| Parameter | Type |
|---|
requestId | uint256 |
exitRequest
function exitRequest(
uint256 requestId
) external view returns (ExitRequest memory);
| Parameter | Type |
|---|
requestId | uint256 |
batch
function batch(uint256 batchId) external view returns (Batch memory);
| Parameter | Type |
|---|
batchId | uint256 |
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.
| Returns | Type |
|---|
newEntry | uint256 |
waitingEntry | uint256 |
newExit | uint256 |
waitingExit | uint256 |
round
function round(uint64 hour) external view returns (Round memory);
openRound
function openRound() external view returns (uint64);
Hour of the round that is executing, zero when there is none.
previewEntry
function previewEntry(
uint256 requestId
) external view returns (uint256 shares, uint256 refundUsdg, uint256 refundAsset, uint256 usdgWaiting);
| Parameter | Type |
|---|
requestId | uint256 |
| Returns | Type |
|---|
shares | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
usdgWaiting | uint256 |
previewExit
function previewExit(
uint256 requestId
) external view returns (uint256 usdg, uint256 usdgWaiting, uint256 sharesWaiting);
| Parameter | Type |
|---|
requestId | uint256 |
| Returns | Type | Description |
|---|
usdg | uint256 | What claimExit() pays now. |
usdgWaiting | uint256 | USDG of the request that has not arrived. |
sharesWaiting | uint256 | FV 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
);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
batch (indexed) | uint256 |
usdg | uint256 |
asset | uint256 |
choice | EntryChoice |
EntryCancelled
event EntryCancelled(uint256 indexed requestId, address indexed owner);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
EntryClaimed
event EntryClaimed(
uint256 indexed requestId,
address indexed owner,
uint256 shares,
uint256 refundUsdg,
uint256 refundAsset
);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
shares | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
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.
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
payout | EntryPayout |
shares | uint256 |
packs | uint256 |
usdg | uint256 |
ExitRequested
event ExitRequested(
uint256 indexed requestId,
address indexed owner,
uint256 indexed batch,
uint256 shares
);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
batch (indexed) | uint256 |
shares | uint256 |
ExitCancelled
event ExitCancelled(
uint256 indexed requestId,
address indexed owner,
uint256 shares
);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
shares | uint256 |
ExitClaimed
event ExitClaimed(
uint256 indexed requestId,
address indexed owner,
uint256 usdg
);
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
owner (indexed) | address |
usdg | uint256 |
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.
| Parameter | Type |
|---|
requestId (indexed) | uint256 |
nextRequestId (indexed) | uint256 |
shares | uint256 |
BatchMerged
event BatchMerged(uint256 indexed batch, uint256 indexed parent);
| Parameter | Type |
|---|
batch (indexed) | uint256 |
parent (indexed) | uint256 |
BatchTaken
event BatchTaken(uint256 indexed batch, uint64 indexed roundHour);
| Parameter | Type |
|---|
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
);
| Parameter | Type |
|---|
hour (indexed) | uint64 |
entryUsdg | uint256 |
entryAsset | uint256 |
entryPrice | uint256 |
entryValue | uint256 |
exitShares | uint256 |
sharePrice | uint256 |
assetPrice | uint256 |
RoundFinalized
event RoundFinalized(
uint64 indexed hour,
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned,
uint256 carryBatch,
uint256 exitUsdg
);
| Parameter | Type |
|---|
hour (indexed) | uint64 |
sharesMinted | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
exitSharesReturned | uint256 |
carryBatch | uint256 |
exitUsdg | uint256 |
RoundAborted
event RoundAborted(
uint64 indexed hour,
uint256 sharesMinted,
uint256 refundUsdg,
uint256 refundAsset,
uint256 exitSharesReturned
);
| Parameter | Type |
|---|
hour (indexed) | uint64 |
sharesMinted | uint256 |
refundUsdg | uint256 |
refundAsset | uint256 |
exitSharesReturned | uint256 |
RoundFunded
event RoundFunded(uint64 indexed hour, uint256 exitUsdg, uint256 refundUsdg);
| Parameter | Type |
|---|
hour (indexed) | uint64 |
exitUsdg | uint256 |
refundUsdg | uint256 |
Errors
NotOwner
error NotOwner(uint256 requestId);
The caller does not own the request.
| Parameter | Type |
|---|
requestId | uint256 |
RequestClosed
error RequestClosed(uint256 requestId);
The request does not exist, was cancelled, or was fully paid.
| Parameter | Type |
|---|
requestId | uint256 |
RequestTaken
error RequestTaken(uint256 requestId);
A round already took the request.
| Parameter | Type |
|---|
requestId | uint256 |
RoundNotReady
error RoundNotReady(uint64 hour);
The round cannot close now, or nothing can be taken.
RoundExecuting
error RoundExecuting(uint64 hour);
An earlier round must be finalized first.
NoOpenRound
No round is executing.
NothingToClaim
error NothingToClaim(uint256 requestId);
There is nothing to pay yet.
| Parameter | Type |
|---|
requestId | uint256 |
StatusForbids
error StatusForbids(Status status);
The status does not allow this.
BelowMinimum
error BelowMinimum(uint256 value, uint256 minimum);
The deposit is below the minimum.
| Parameter | Type |
|---|
value | uint256 |
minimum | uint256 |
VaultFull
error VaultFull(uint256 room);
The vault would grow larger than one order at Lighter can close.
ZeroAmount
Nothing was sent.
NoOwner
A request needs an owner.
LighterStopped
Lighter stopped for good.
NotVault
Only the vault can call this.
NoChoice
error NoChoice(uint256 requestId);
The owner chose FV, which claimEntry pays.
| Parameter | Type |
|---|
requestId | uint256 |
BadChoice
Fix + USDG needs a least price for the Yield.
Too little gas for the sale of the Yield. Call again with more.
WrongRouter
The router does not swap in the pools of the factory.