Skip to main content

Write

deposit

Deposits the supplied Gobblers/Goo from the owner and sends fractions to the receiver.

function deposit(
uint256[] calldata gobblers,
uint256 gooTokens,
address receiver
) external returns (uint256 fractions);
NameTypeDescription
gobblersuint256[]Array of Gobbler ids.
gooTokensuint256Amount of Goo to deposit.
receiveraddressAddress to receive fractions.

Return Values:

NameTypeDescription
fractionsuint256Amount of fractions created.

safeDeposit

Deposits the supplied Gobblers/Goo from the owner and sends fractions to the receiver whilst ensuring a deadline is met, and a minimum amount of fractions are created.

function safeDeposit(
uint256[] calldata gobblers,
uint256 gooTokens,
address receiver,
uint256 minFractionsOut,
uint256 deadline
) external returns (uint256 fractions);

Parameters:

NameTypeDescription
gobblersuint256[]Array of Gobbler ids to deposit.
gooTokensuint256Amount of Goo to deposit.
receiveraddressAddress to receive fractions.
maxFractionsInuint256Minimum amount of fractions to be sent.
deadlineuint256Unix timestamp by which the transaction must execute.

Return Values:

NameTypeDescription
fractionsuint256Amount of fractions created.

swap

Swaps supplied Gobblers/Goo for Gobblers/Goo in the pool.

tip

Unlike Uni V2, we only need to send the data, because token transfers in are pulled below.

function swap(
uint256[] calldata gobblersIn,
uint256 gooIn,
uint256[] calldata gobblersOut,
uint256 gooOut,
address receiver,
bytes calldata data
) external returns (int256 erroneousGoo);

Parameters:

NameTypeDescription
gobblersInuint256[]Gobblers sent from msg.sender.
gooInuint256Goo sent from msg.sender.
gobblersOutuint256[]Gobblers optimistically transferred to the receiver.
gooOutuint256Goo optimistically transferred to the receiver.
receiveraddressgobblersOut and gooOut transferred to this address.
databytesUsed to trigger flash loan.

Return Values:

NameTypeDescription
erroneousGooint256Difference in gooOut expected compared to actual.

safeSwap

Swaps supplied Gobblers/Goo for Gobblers/Goo in the pool, with slippage and deadline control.

tip

Unlike Uni V2, we only need to send the data, because token transfers in are pulled below.

function safeSwap(
uint256 erroneousGooAbs,
uint256 deadline,
uint256[] calldata gobblersIn,
uint256 gooIn,
uint256[] calldata gobblersOut,
uint256 gooOut,
address receiver,
bytes calldata data
) external returns (int256 erroneousGoo);

Parameters:

NameTypeDescription
erroneousGooAbsuint256Slippage limit on erroneousGoo.
deadlineuint256Unix timestamp by which the transaction must execute.
gobblersInuint256[]Gobblers sent from msg.sender.
gooInuint256Goo sent from msg.sender.
gobblersOutuint256[]Gobblers optimistically transferred to the receiver.
gooOutuint256Goo optimistically transferred to the receiver.
receiveraddressgobblersOut and gooOut transferred to this address.
databytesUsed to trigger flash loan.

Return Values:

NameTypeDescription
erroneousGooint256Difference in gooOut expected compared to actual.

withdraw

Withdraws the requested Gobblers and Goo from the vault.

function withdraw(
uint256[] calldata gobblers,
uint256 gooTokens,
address receiver,
address owner)
external returns (uint256 fractions);

Parameters:

NameTypeDescription
gobblersuint256[]Array of Gobbler ids to withdraw.
gooTokensuint256Amount of Goo to withdraw.
receiveraddressAddress to receive the Goo and Gobblers.
owneraddressOwner of the fractions to be destroyed.

Return Values:

NameTypeDescription
fractionsuint256Amount of fractions destroyed

safeWithdraw

Withdraws the requested Gobblers/Goo from the vault to the receiver and destroys fractions from the owner whilst ensuring a deadline is met, and a maximum amount of fractions are destroyed.

function safeWithdraw(
uint256[] calldata gobblers,
uint256 gooTokens,
address receiver,
address owner,
uint256 maxFractionsIn,
uint256 deadline
) external returns (uint256 fractions);

Parameters:

NameTypeDescription
gobblersuint256[]Array of Gobbler ids to withdraw.
gooTokensuint256Amount of Goo to withdraw.
receiveraddressAddress to receive the Goo and Gobblers.
owneraddressOwner of the fractions to be destroyed.
maxFractionsInuint256Maximum amount of fractions to be destroyed.
deadlineuint256Unix timestamp by which the transaction must execute.

Return Values:

NameTypeDescription
fractionsuint256Amount of fractions destroyed