Skip to main content

GedhoZap

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.

ParameterType
usdguint256
maxPriceuint256
minSharesuint256
deadlineuint256
usdgPermitPermit
ReturnsType
sharesuint256
requestIduint256

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.

ParameterType
usdguint256
maxPriceuint256
minPacksuint256
minYieldPriceuint256
deadlineuint256
usdgPermitPermit
ReturnsType
packsuint256
usdgOutuint256
requestIduint256

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.

ParameterType
sharesuint256
minPriceuint256
minUsdguint256
deadlineuint256
sharePermitPermit
ReturnsType
usdguint256
requestIduint256

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.

ParameterType
packsuint256
maxUsdguint256
minPriceuint256
minUsdguint256
deadlineuint256
fixPermitPermit
usdgPermitPermit
ReturnsType
costuint256
usdguint256
requestIduint256

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.

ParameterType
requestIduint256
packsuint256
minUsdguint256
deadlineuint256
sharePermitPermit
ReturnsType
usdguint256

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.

ParameterType
packsuint256
maxUsdguint256
deadlineuint256
fixPermitPermit
usdgPermitPermit
ReturnsType
costuint256
requestIduint256

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.

ParameterType
seriesIduint256
ReturnsType
pooladdress

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.

ReturnsType
pooladdress

Read​

poolOf​

function poolOf(uint256 seriesId) external view returns (address);
ParameterType
seriesIduint256
ReturnsType
-address

sharePool​

function sharePool() external view returns (address);
ReturnsType
-address

Events​

IncomeLocked​

event IncomeLocked(
address indexed owner,
uint256 indexed seriesId,
uint256 packs,
uint256 usdg
);
ParameterType
owner (indexed)address
seriesId (indexed)uint256
packsuint256
usdguint256

YieldBoughtBack​

event YieldBoughtBack(
address indexed owner,
uint256 indexed seriesId,
uint256 packs,
uint256 cost
);
ParameterType
owner (indexed)address
seriesId (indexed)uint256
packsuint256
costuint256

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.

ParameterType
owner (indexed)address
usdgSpentuint256
sharesuint256
usdgQueueduint256
requestIduint256

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.

ParameterType
owner (indexed)address
sharesSolduint256
usdguint256
sharesQueueduint256
requestIduint256

PoolCreated​

event PoolCreated(uint256 indexed seriesId, address indexed pool);
ParameterType
seriesId (indexed)uint256
pool (indexed)address

SharePoolCreated​

event SharePoolCreated(address indexed pool);
ParameterType
pool (indexed)address

Errors​

Expired​

error Expired();

The deadline of the caller passed.

ReceivedTooLittle​

error ReceivedTooLittle(uint256 received, uint256 minimum);

The sale gave less than the caller accepts.

ParameterType
receiveduint256
minimumuint256

NoPool​

error NoPool(uint256 seriesId);

The series has no pool.

ParameterType
seriesIduint256

UnknownSeries​

error UnknownSeries(uint256 seriesId);

The series does not exist.

ParameterType
seriesIduint256

NoLeastPrice​

error NoLeastPrice();

Fix and USDG need a least price for the Yield.

SeriesEnded​

error SeriesEnded(uint256 seriesId);

The series no longer splits.

ParameterType
seriesIduint256

NoSharePrice​

error 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.

ParameterType
requestIduint256

PoolExists​

error PoolExists(address pool);

The pool was already created through this contract.

ParameterType
pooladdress

NotRequestOwner​

error NotRequestOwner(uint256 requestId);

The request does not belong to the caller.

ParameterType
requestIduint256

WrongRouter​

error WrongRouter();

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

NotOwed​

error NotOwed();

Only a pool that this contract moves to its start price calls back, and it is owed nothing.

GasTooLow​

error GasTooLow();

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.

FieldType
valueuint256
deadlineuint256
vuint8
rbytes32
sbytes32