šŸŽ‰ Welcome to PartyFinance documentation!
Protocol
Contracts
libraries
LibParty

DepositNotEnough

error DepositNotEnough()

"Deposit is not enough"

DepositExceeded

error DepositExceeded()

"Deposit exceeds maximum required"

UserBalanceNotEnough

error UserBalanceNotEnough()

"User balance is not enough"

FailedAproveReset

error FailedAproveReset()

"Failed approve reset"

FailedAprove

error FailedAprove()

"Failed approving sellToken"

ZeroXFail

error ZeroXFail()

"0x Protocol: SWAP_CALL_FAILED"

InvalidSignature

error InvalidSignature()

"Invalid approval signature"

InvalidSwap

error InvalidSwap()

"Only one swap at a time"

TokenGateRestriction

error TokenGateRestriction()

"The user doesn't hold enough balance for the party tokenGates"

FetchTokenBalanceFail

error FetchTokenBalanceFail()

"Calling balanceOf(address) to token address failed"

LibParty

AllocationFilled

event AllocationFilled(address member, address[] sellTokens, address[] buyTokens, uint256[] soldAmounts, uint256[] boughtAmounts, uint256 partyValueDA)

Emitted when quotes are filled by 0x for allocation of funds

SwapToken is not included on this event, since its have the same information

Parameters

NameTypeDescription
memberaddressAddress of the user
sellTokensaddress[]Array of sell tokens
buyTokensaddress[]Array of buy tokens
soldAmountsuint256[]Array of sold amount of tokens
boughtAmountsuint256[]Array of bought amount of tokens
partyValueDAuint256The party value in denomination asset prior to the allocation

RedeemedShares

event RedeemedShares(address member, uint256 burnedPT, bool liquidate, address[] redeemedAssets, uint256[] redeemedAmounts, uint256[] redeemedFees, uint256[] redeemedNetAmounts)

Emitted when a member redeems shares from a party

Parameters

NameTypeDescription
memberaddressAddress of the user
burnedPTuint256Burned party tokens for redemption
liquidateboolRedemption by liquitating shares into denomination asset
redeemedAssetsaddress[]Array of asset addresses
redeemedAmountsuint256[]Array of asset amounts
redeemedFeesuint256[]Array of asset fees
redeemedNetAmountsuint256[]Array of net asset amounts

getPlatformFee

function getPlatformFee(uint256 amount, uint256 feeBps) internal pure returns (uint256 fee)

Retrieves the Platform fee to be taken from an amount

Parameters

NameTypeDescription
amountuint256Base amount to calculate fees
feeBpsuint256

collectPlatformFee

function collectPlatformFee(uint256 amount, address token) internal returns (uint256 fee)

Transfers a fee amount of an ERC20 token to the platform collector address

Parameters

NameTypeDescription
amountuint256Base amount to calculate fees
tokenaddressERC-20 token address

ensureTokenGate

function ensureTokenGate(address user) internal view

Ensures that the user has all the requirements from the tokenGates array

Parameters

NameTypeDescription
useraddressAddress of the user

swapToken

function swapToken(struct LibSignatures.Allocation allocation, struct LibSignatures.Sig approval) internal returns (uint256 soldAmount, uint256 boughtAmount, uint256 fee)

Swap a token using 0x Protocol

Parameters

NameTypeDescription
allocationstruct LibSignatures.AllocationThe swap allocation
approvalstruct LibSignatures.SigThe platform signature approval for the allocation

mintPartyTokens

function mintPartyTokens(address user, uint256 amountDA, struct LibSignatures.Allocation allocation, struct LibSignatures.Sig approval) internal returns (uint256 fee, uint256 mintedPT)

Mints PartyTokens in exchange for a deposit

Parameters

NameTypeDescription
useraddressUser address
amountDAuint256The deposit amount in DA
allocationstruct LibSignatures.AllocationThe deposit allocation
approvalstruct LibSignatures.SigThe platform signature approval for the allocation

redeemPartyTokens

function redeemPartyTokens(uint256 amountPT, address _memberAddress, struct LibSignatures.Allocation allocation, struct LibSignatures.Sig approval, bool liquidate) internal

Redeems funds in exchange for PartyTokens

Parameters

NameTypeDescription
amountPTuint256The PartyTokens amount
_memberAddressaddressThe member's address to redeem PartyTokens in
allocationstruct LibSignatures.AllocationThe withdraw allocation
approvalstruct LibSignatures.SigThe platform signature approval for the allocation
liquidateboolWhether to withdraw by swapping funds into DA or not

redeemHoldings

function redeemHoldings(uint256 amountPT, uint256 totalSupply, address _memberAddress, address[] tokens) private

Redeems assets without liquidating them

Parameters

NameTypeDescription
amountPTuint256The PartyTokens amount
totalSupplyuint256The current totalSupply of the PartyTokens
_memberAddressaddressThe member's address to redeem PartyTokens in
tokensaddress[]Current tokens in the party

liquidateHoldings

function liquidateHoldings(uint256 amountPT, uint256 totalSupply, address _memberAddress, struct LibSignatures.Allocation allocation, struct LibSignatures.Sig approval, address denominationAsset, address sentinel) private

Redeems assets by liquidating them into DA

Parameters

NameTypeDescription
amountPTuint256The PartyTokens amount
totalSupplyuint256The current totalSupply of the PartyTokens
_memberAddressaddressThe member's address to redeem PartyTokens in
allocationstruct LibSignatures.AllocationThe liquidation allocation
approvalstruct LibSignatures.SigThe platform signature approval for the allocation
denominationAssetaddressThe party's denomination asset address
sentineladdressThe platform sentinel address

allocateAssets

function allocateAssets(address sender, struct LibSignatures.Allocation allocation, struct LibSignatures.Sig approval, address sentinel) private returns (struct LibSharedStructs.Allocated allocated)

Allocates multiple 0x quotes

Parameters

NameTypeDescription
senderaddressThe user's address
allocationstruct LibSignatures.AllocationThe allocation
approvalstruct LibSignatures.SigThe platform signature approval for the allocation
sentineladdressThe platform sentinel address

fillQuote

function fillQuote(address sellToken, uint256 sellAmount, address buyToken, address spender, address payable swapTarget, bytes swapCallData) private returns (struct LibSharedStructs.FilledQuote filledQuote)

Swap a token held by this contract using a 0x-API quote.

Parameters

NameTypeDescription
sellTokenaddressThe token address to sell
sellAmountuint256The token amount to sell
buyTokenaddressThe token address to buy
spenderaddressThe spender address
swapTargetaddress payableThe swap target to interact (0x Exchange Proxy)
swapCallDatabytesThe swap calldata to pass