Joins several user steps into one transaction. It has no permission in the other contracts and keeps nothing after a call: what is left goes back to the caller.
Anyone
buyShares
function buyShares(
uint256 usdg,
uint256 maxPrice,
uint256 minShares,
uint256 deadline,
Permit calldata usdgPermit
) external returns (uint256 shares, uint256 requestId);
USDG to FV. Buys at least minShares FV in the pool up to maxPrice. The rest of the USDG asks to enter when it is at least the smallest deposit, and comes back otherwise.
| Parameter | Type |
|---|
usdg | uint256 |
maxPrice | uint256 |
minShares | uint256 |
deadline | uint256 |
usdgPermit | Permit |
| Returns | Type |
|---|
shares | uint256 |
requestId | uint256 |
buyFixAndUsdg
function buyFixAndUsdg(
uint256 usdg,
uint256 maxPrice,
uint256 minPacks,
uint256 minYieldPrice,
uint256 deadline,
Permit calldata usdgPermit
) external returns (uint256 packs, uint256 usdgOut, uint256 requestId);
USDG to Fix and USDG. Buys FV like buyShares, splits at least minPacks of it in the current series, and sells the Yield down to minYieldPrice after the fee of its pool; Yield that does not sell comes back. The rest of the USDG asks to enter with the same choice. FV below one pack comes back.
| Parameter | Type |
|---|
usdg | uint256 |
maxPrice | uint256 |
minPacks | uint256 |
minYieldPrice | uint256 |
deadline | uint256 |
usdgPermit | Permit |
| Returns | Type |
|---|
packs | uint256 |
usdgOut | uint256 |
requestId | uint256 |
sellShares
function sellShares(
uint256 shares,
uint256 minPrice,
uint256 minUsdg,
uint256 deadline,
Permit calldata sharePermit
) external returns (uint256 usdg, uint256 requestId);
FV to USDG. Sells FV in the pool down to minPrice, for at least minUsdg. The rest asks to leave.
| Parameter | Type |
|---|
shares | uint256 |
minPrice | uint256 |
minUsdg | uint256 |
deadline | uint256 |
sharePermit | Permit |
| Returns | Type |
|---|
usdg | uint256 |
requestId | uint256 |
sellFix
function sellFix(
uint256 packs,
uint256 maxUsdg,
uint256 minPrice,
uint256 minUsdg,
uint256 deadline,
Permit calldata fixPermit,
Permit calldata usdgPermit
) external returns (uint256 cost, uint256 usdg, uint256 requestId);
Fix to USDG. Buys packs Yield of the current series for at most maxUsdg of the caller, joins them with Fix, and sells the FV like sellShares.
| Parameter | Type |
|---|
packs | uint256 |
maxUsdg | uint256 |
minPrice | uint256 |
minUsdg | uint256 |
deadline | uint256 |
fixPermit | Permit |
usdgPermit | Permit |
| Returns | Type |
|---|
cost | uint256 |
usdg | uint256 |
requestId | uint256 |
lockIncome
function lockIncome(
uint256 requestId,
uint256 packs,
uint256 minUsdg,
uint256 deadline,
Permit calldata sharePermit
) external returns (uint256 usdg);
Claims an entry, splits packs from the FV of the caller, and sells the Yield for at least minUsdg. Fix and USDG go to the caller, and Yield that did not sell when minUsdg allows it.
requestId is zero when the entry was already claimed. Otherwise the request must belong to the caller.
| Parameter | Type |
|---|
requestId | uint256 |
packs | uint256 |
minUsdg | uint256 |
deadline | uint256 |
sharePermit | Permit |
buyBackAndExit
function buyBackAndExit(
uint256 packs,
uint256 maxUsdg,
uint256 deadline,
Permit calldata fixPermit,
Permit calldata usdgPermit
) external returns (uint256 cost, uint256 requestId);
Buys packs Yield of the current series for at most maxUsdg of the caller, joins them with Fix of the caller, and asks to leave with the FV. The request belongs to the caller.
| Parameter | Type |
|---|
packs | uint256 |
maxUsdg | uint256 |
deadline | uint256 |
fixPermit | Permit |
usdgPermit | Permit |
| Returns | Type |
|---|
cost | uint256 |
requestId | uint256 |
createPool
function createPool(uint256 seriesId) external returns (address pool);
Creates the Yield pool of a series at its start price. Takes an existing pool as it is when it has liquidity, and moves it to the start price when it has none. Anyone can call it, once for each series.
| Parameter | Type |
|---|
seriesId | uint256 |
createSharePool
function createSharePool() external returns (address pool);
Creates the FV pool of the market at the price of one share now, in the same way. Anyone can call it, once.
Read
poolOf
function poolOf(uint256 seriesId) external view returns (address);
| Parameter | Type |
|---|
seriesId | uint256 |
sharePool
function sharePool() external view returns (address);
Events
IncomeLocked
event IncomeLocked(
address indexed owner,
uint256 indexed seriesId,
uint256 packs,
uint256 usdg
);
| Parameter | Type |
|---|
owner (indexed) | address |
seriesId (indexed) | uint256 |
packs | uint256 |
usdg | uint256 |
YieldBoughtBack
event YieldBoughtBack(
address indexed owner,
uint256 indexed seriesId,
uint256 packs,
uint256 cost
);
| Parameter | Type |
|---|
owner (indexed) | address |
seriesId (indexed) | uint256 |
packs | uint256 |
cost | uint256 |
SharesBought
event SharesBought(
address indexed owner,
uint256 usdgSpent,
uint256 shares,
uint256 usdgQueued,
uint256 requestId
);
usdgQueued waits for a round as request requestId, zero when nothing does.
| Parameter | Type |
|---|
owner (indexed) | address |
usdgSpent | uint256 |
shares | uint256 |
usdgQueued | uint256 |
requestId | uint256 |
SharesSold
event SharesSold(
address indexed owner,
uint256 sharesSold,
uint256 usdg,
uint256 sharesQueued,
uint256 requestId
);
sharesQueued waits for a round as request requestId, zero when nothing does.
| Parameter | Type |
|---|
owner (indexed) | address |
sharesSold | uint256 |
usdg | uint256 |
sharesQueued | uint256 |
requestId | uint256 |
PoolCreated
event PoolCreated(uint256 indexed seriesId, address indexed pool);
| Parameter | Type |
|---|
seriesId (indexed) | uint256 |
pool (indexed) | address |
SharePoolCreated
event SharePoolCreated(address indexed pool);
| Parameter | Type |
|---|
pool (indexed) | address |
Errors
Expired
The deadline of the caller passed.
error ReceivedTooLittle(uint256 received, uint256 minimum);
The sale gave less than the caller accepts.
| Parameter | Type |
|---|
received | uint256 |
minimum | uint256 |
NoPool
error NoPool(uint256 seriesId);
The series has no pool.
| Parameter | Type |
|---|
seriesId | uint256 |
UnknownSeries
error UnknownSeries(uint256 seriesId);
The series does not exist.
| Parameter | Type |
|---|
seriesId | uint256 |
NoLeastPrice
Fix and USDG need a least price for the Yield.
SeriesEnded
error SeriesEnded(uint256 seriesId);
The series no longer splits.
| Parameter | Type |
|---|
seriesId | uint256 |
NoSharePrice
One share is worth nothing, so the FV pool has no start price.
ChoiceNotShares
error ChoiceNotShares(uint256 requestId);
The owner of the request chose more than FV; fulfillEntry of GedhoQueue carries it out.
| Parameter | Type |
|---|
requestId | uint256 |
PoolExists
error PoolExists(address pool);
The pool was already created through this contract.
NotRequestOwner
error NotRequestOwner(uint256 requestId);
The request does not belong to the caller.
| Parameter | Type |
|---|
requestId | uint256 |
WrongRouter
The router does not swap in the pools of the factory.
NotOwed
Only a pool that this contract moves to its start price calls back, and it is owed nothing.
Too little gas for a step that may fail. Call again with more.
Types
Permit
ERC-2612 approval, so that a separate approve is not needed. Ignored when deadline is zero.
| Field | Type |
|---|
value | uint256 |
deadline | uint256 |
v | uint8 |
r | bytes32 |
s | bytes32 |