Skip to main content

Zapper

Zapper

Deployment on Ethereum mainnet:

https://etherscan.io/address/0xd7b528e749078daDeE2f0071cde6fca4e191A521

Moves capital from the SeniorPool to TranchedPools without taking fees

config

contract GoldfinchConfig config

Zap

struct Zap {
address owner;
uint256 stakingPositionId;
}

tranchedPoolZaps

mapping(uint256 => struct Zapper.Zap) tranchedPoolZaps

PoolToken.id => Zap

initialize

function initialize(address owner, contract GoldfinchConfig _config) public

zapMultipleToTranchedPool

function zapMultipleToTranchedPool(uint256[] stakingRewardsTokenIds, uint256[] fiduAmounts, contract ITranchedPool tranchedPool, uint256 tranche) public returns (uint256[] poolTokenIds)

Zap multiple StakingRewards tokens to a tranched pool.

Parameters

NameTypeDescription
stakingRewardsTokenIdsuint256[]ids of the StakingRewards ERC721 positions to zap. Token ids MUST be sorted ascending.
fiduAmountsuint256[]FIDU amount to zap for each position such that fiduAmounts[i] FIDU is zapped from position tokenIds[i].
tranchedPoolcontract ITranchedPooladdress of the tranched pool to zap into.
trancheuint256id of the tranch to zap into.

Return Values

NameTypeDescription
poolTokenIdsuint256[]PoolTokens ERC721 ids created by each zap action.

unzapMultipleFromTranchedPools

function unzapMultipleFromTranchedPools(uint256[] poolTokenIds) public

Unzap multiple pool tokens (not necessarily from the same tranched pools). You may perform this action anytime before the respective tranche locks.

Parameters

NameTypeDescription
poolTokenIdsuint256[]PoolTokens ERC721 ids to unzap. Token ids MUST be sorted ascending. The caller MUST be the address that performed the initial zaps.

claimMultipleTranchedPoolZaps

function claimMultipleTranchedPoolZaps(uint256[] poolTokenIds) public

Claim multiple pool tokens (not necessarily from the same tranched pools). A claim only succeeds if the tranched pool has locked.

Parameters

NameTypeDescription
poolTokenIdsuint256[]PoolTokens ERC721 ids to claim. Token ids MUST be sorted ascending. The caller MUST be the address that performed the initial zaps.

zapFiduStakeToTranchedPool

function zapFiduStakeToTranchedPool(uint256 tokenId, contract ITranchedPool tranchedPool, uint256 tranche, uint256 fiduAmount) public returns (uint256 poolTokenId)

Zap staked FIDU into the junior tranche of a TranchedPool without losing unvested rewards or paying a withdrawal fee. This function is preferred over zapStakeToTranchedPool for zapping an entire position because the latter accepts a USDC amount, which cannot precisely represent FIDU due to lack of decimals.

The minted pool token is held by this contract until either claimZap or unzap is called.

Parameters

NameTypeDescription
tokenIduint256StakingRewards ERC721 token id to zap.
tranchedPoolcontract ITranchedPoolTranchedPool to deposit into.
trancheuint256id of the tranche to deposit into.
fiduAmountuint256amount to deposit in FIDU.

Return Values

NameTypeDescription
poolTokenIduint256PoolTokens ERC721 id of the TranchedPool deposit.

zapStakeToTranchedPool

function zapStakeToTranchedPool(uint256 tokenId, contract ITranchedPool tranchedPool, uint256 tranche, uint256 usdcAmount) public returns (uint256 poolTokenId)

Zap staked FIDU into the junior tranche of a TranchedPool without losing unvested rewards or paying a withdrawal fee

The minted pool token is held by this contract until either claimZap or unzap is called

Parameters

NameTypeDescription
tokenIduint256A staking position token ID. The owner MUST perform an ERC721 approval
tranchedPoolcontract ITranchedPoolTranchedPool to deposit into.
trancheuint256id of the tranche to deposit into.
usdcAmountuint256The USDC amount to deposit.

Return Values

NameTypeDescription
poolTokenIduint256PoolTokens ERC721 id of the TranchedPool deposit. for the Zapper address before calling this function.

claimTranchedPoolZap

function claimTranchedPoolZap(uint256 poolTokenId) public

Claim the underlying PoolToken for a zap initiated with zapStakeToTranchePool. The pool token will be transferred to msg.sender if msg.sender initiated the zap and we are past the tranche's lockedUntil time.

Parameters

NameTypeDescription
poolTokenIduint256The underyling PoolToken id created in a previously initiated zap

unzapToStakingRewards

function unzapToStakingRewards(uint256 poolTokenId) public

Unwind a zap initiated with zapStakeToTranchePool. The funds will be withdrawn from the TranchedPool and added back to the original staked position in StakingRewards. This method can only be called when the PoolToken's tranche has never been locked.

Parameters

NameTypeDescription
poolTokenIduint256The underyling PoolToken id created in a previously initiated zap

zapStakeToCurve

function zapStakeToCurve(uint256 tokenId, uint256 fiduAmount, uint256 usdcAmount) public

Zap staked FIDU into staked Curve LP tokens without losing unvested rewards or paying a withdrawal fee.

Parameters

NameTypeDescription
tokenIduint256A staking position token ID
fiduAmountuint256The amount in FIDU from the staked position to zap
usdcAmountuint256The amount of USDC to deposit into Curve

_unzapToStakingRewards

function _unzapToStakingRewards(uint256 poolTokenId) internal

See unzapToStakingRewards

_claimTranchedPoolZap

function _claimTranchedPoolZap(uint256 poolTokenId) internal

See claimTranchedPoolZap

_zapUsdcAmountToTranchedPool

function _zapUsdcAmountToTranchedPool(uint256 tokenId, contract ITranchedPool tranchedPool, uint256 tranche, uint256 usdcAmount) internal returns (uint256 poolTokenId)

See zapStakeToTranchedPool

_zapFiduAmountToTranchedPool

function _zapFiduAmountToTranchedPool(uint256 tokenId, contract ITranchedPool tranchedPool, uint256 tranche, uint256 fiduAmount) internal returns (uint256 poolTokenId)

See zapFiduStakeToTranchedPool

_hasAllowedUID

function _hasAllowedUID(contract ITranchedPool pool) internal view returns (bool)

_validPool

function _validPool(contract ITranchedPool pool) internal view returns (bool)