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
Name | Type | Description |
---|---|---|
member | address | Address of the user |
sellTokens | address[] | Array of sell tokens |
buyTokens | address[] | Array of buy tokens |
soldAmounts | uint256[] | Array of sold amount of tokens |
boughtAmounts | uint256[] | Array of bought amount of tokens |
partyValueDA | uint256 | The 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
Name | Type | Description |
---|---|---|
member | address | Address of the user |
burnedPT | uint256 | Burned party tokens for redemption |
liquidate | bool | Redemption by liquitating shares into denomination asset |
redeemedAssets | address[] | Array of asset addresses |
redeemedAmounts | uint256[] | Array of asset amounts |
redeemedFees | uint256[] | Array of asset fees |
redeemedNetAmounts | uint256[] | 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
Name | Type | Description |
---|---|---|
amount | uint256 | Base amount to calculate fees |
feeBps | uint256 |
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
Name | Type | Description |
---|---|---|
amount | uint256 | Base amount to calculate fees |
token | address | ERC-20 token address |
ensureTokenGate
function ensureTokenGate(address user) internal view
Ensures that the user has all the requirements from the tokenGates
array
Parameters
Name | Type | Description |
---|---|---|
user | address | Address 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
Name | Type | Description |
---|---|---|
allocation | struct LibSignatures.Allocation | The swap allocation |
approval | struct LibSignatures.Sig | The 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
Name | Type | Description |
---|---|---|
user | address | User address |
amountDA | uint256 | The deposit amount in DA |
allocation | struct LibSignatures.Allocation | The deposit allocation |
approval | struct LibSignatures.Sig | The 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
Name | Type | Description |
---|---|---|
amountPT | uint256 | The PartyTokens amount |
_memberAddress | address | The member's address to redeem PartyTokens in |
allocation | struct LibSignatures.Allocation | The withdraw allocation |
approval | struct LibSignatures.Sig | The platform signature approval for the allocation |
liquidate | bool | Whether 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
Name | Type | Description |
---|---|---|
amountPT | uint256 | The PartyTokens amount |
totalSupply | uint256 | The current totalSupply of the PartyTokens |
_memberAddress | address | The member's address to redeem PartyTokens in |
tokens | address[] | 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
Name | Type | Description |
---|---|---|
amountPT | uint256 | The PartyTokens amount |
totalSupply | uint256 | The current totalSupply of the PartyTokens |
_memberAddress | address | The member's address to redeem PartyTokens in |
allocation | struct LibSignatures.Allocation | The liquidation allocation |
approval | struct LibSignatures.Sig | The platform signature approval for the allocation |
denominationAsset | address | The party's denomination asset address |
sentinel | address | The 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
Name | Type | Description |
---|---|---|
sender | address | The user's address |
allocation | struct LibSignatures.Allocation | The allocation |
approval | struct LibSignatures.Sig | The platform signature approval for the allocation |
sentinel | address | The 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
Name | Type | Description |
---|---|---|
sellToken | address | The token address to sell |
sellAmount | uint256 | The token amount to sell |
buyToken | address | The token address to buy |
spender | address | The spender address |
swapTarget | address payable | The swap target to interact (0x Exchange Proxy) |
swapCallData | bytes | The swap calldata to pass |