Swivel
Annotated source of the Swivel.sol smart contract
Swivel
Contents
Globals
Note this list contains both internal and external attributes
Var | Type |
---|---|
cancelled | mapping(bytes32 => bool) |
filled | mapping(bytes32 => uint256) |
withdrawals | mapping(address => uint256) |
approvals | mapping(address => mapping(address => uint256)) |
NAME | string |
VERSION | string |
HOLD | uint256 |
feeChange | uint256 |
domain | bytes32 |
marketPlace | address |
admin | address |
aaveAddr | address |
MIN_FEENOMINATOR | uint16 |
feenominators | uint16[4] |
Modifiers
authorized
Restricts msg.sender
as the only viable caller of a method
Declaration
Functions
constructor
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| address | Deployed MarketPlace contract address |
| address | Address of a deployed Aave contract implementing our interface |
initiate
Allows a user to initiate a position
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order[] | Array of offline Swivel.Orders |
| uint256[] | Array of order volume (principal) amounts relative to passed orders |
| struct Sig.Components[] | Array of Components from valid ECDSA signatures |
initiateVaultFillingZcTokenInitiate
Allows a user to initiate a Vault by filling an offline zcToken initiate order
This method should pass (underlying, maturity, maker, sender, principalFilled) to MarketPlace.custodialInitiate
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (premium) being filled by the taker's initiate |
| struct Sig.Components | Components of a valid ECDSA signature |
initiateZcTokenFillingVaultInitiate
Allows a user to initiate a zcToken by filling an offline vault initiate order
This method should pass (underlying, maturity, sender, maker, a) to MarketPlace.custodialInitiate
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (principal) being filled by the taker's initiate |
| struct Sig.Components | Components of a valid ECDSA signature |
initiateZcTokenFillingZcTokenExit
Allows a user to initiate zcToken? by filling an offline zcToken exit order
This method should pass (underlying, maturity, maker, sender, a) to MarketPlace.p2pZcTokenExchange
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (principal) being filled by the taker's initiate |
| struct Sig.Components | Components of a valid ECDSA signature |
initiateVaultFillingVaultExit
Allows a user to initiate a Vault by filling an offline vault exit order
This method should pass (underlying, maturity, maker, sender, principalFilled) to MarketPlace.p2pVaultExchange
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (interest) being filled by the taker's exit |
| struct Sig.Components | Components of a valid ECDSA signature |
exit
Allows a user to exit (sell) a currently held position to the marketplace.
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order[] | Array of offline Swivel.Orders |
| uint256[] | Array of order volume (principal) amounts relative to passed orders |
| struct Sig.Components[] | Components of a valid ECDSA signature |
exitZcTokenFillingZcTokenInitiate
Allows a user to exit their zcTokens by filling an offline zcToken initiate order
This method should pass (underlying, maturity, sender, maker, principalFilled) to MarketPlace.p2pZcTokenExchange
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (interest) being filled by the taker's exit |
| struct Sig.Components | Components of a valid ECDSA signature |
exitVaultFillingVaultInitiate
Allows a user to exit their Vault by filling an offline vault initiate order
This method should pass (underlying, maturity, sender, maker, a) to MarketPlace.p2pVaultExchange
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (principal) being filled by the taker's exit |
| struct Sig.Components | Components of a valid ECDSA signature |
exitVaultFillingZcTokenExit
Allows a user to exit their Vault filling an offline zcToken exit order
This method should pass (underlying, maturity, maker, sender, a) to MarketPlace.exitFillingExit
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (principal) being filled by the taker's exit |
| struct Sig.Components | Components of a valid ECDSA signature |
exitZcTokenFillingVaultExit
Allows a user to exit their zcTokens by filling an offline vault exit order
This method should pass (underlying, maturity, sender, maker, principalFilled) to MarketPlace.exitFillingExit
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | Order being filled |
| uint256 | Amount of volume (interest) being filled by the taker's exit |
| struct Sig.Components | Components of a valid ECDSA signature |
cancel
Allows a user to cancel an order, preventing it from being filled in the future
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order[] | Array of offline orders being cancelled |
setAdmin
Sets the admin
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of a new admin |
scheduleWithdrawal
Allows the admin to schedule the withdrawal of tokens
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of (ERC20) token to withdraw |
scheduleApproval
Allows the admin to schedule the approval of tokens
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of (ERC20) token to approve |
| address | Address of the contract to approve |
scheduleFeeChange
allows the admin to schedule a change to the fee denominators
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| uint16[4] | array of length 4 holding values which suggest replacing any at the same index for the current feenominators |
blockWithdrawal
Emergency function to block unplanned withdrawals
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of token withdrawal to block |
blockApproval
Emergency function to block unplanned approvals
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of token approval to block |
| address | Address of the contract to block approval of |
blockFeeChange
Emergency function to block unplanned changes to fee structure
Declaration
Modifiers:
Modifier |
---|
authorized |
withdraw
Allows the admin to withdraw the given token, provided the holding period has been observed
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address | Address of token to withdraw |
changeFee
allows the admin to set new fee denominators
note that, since 0 values are allowable the way to leave a feenominator value unchanged is to pass the existing value
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| uint16[4] | array of length 4 holding values which will replace any at the same index in the current feenominators |
approveUnderlying
Allows the admin to bulk approve given compounding addresses at the underlying token, saving marginal approvals, providing the holding period has been observed
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| address[] | array of underlying token addresses |
| address[] | array of compound token addresses |
splitUnderlying
Allows users to deposit underlying and in the process split it into/mint zcTokens and vault notional. Calls mPlace.mintZcTokenAddingNotional
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum value associated with this market pair |
| address | Underlying token address associated with this market pair |
| uint256 | Maturity timestamp of this associated market |
| uint256 | Amount of underlying being deposited |
combineTokens
Allows users deposit/burn 1-1 amounts of both zcTokens and vault notional, in the process "combining" the two, and redeeming underlying. Calls mPlace.burnZcTokenRemovingNotional.
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum value associated with this market pair |
| address | Underlying token address associated with the market |
| uint256 | Maturity timestamp of the market |
| uint256 | Amount of zcTokens being redeemed |
authRedeem
Allows MarketPlace to complete its contractual obligation as IRedeemer, redeeming zcTokens and withdrawing underlying p Protocol Enum value associated with this market pair
Note that this bubbles up from the zcToken instead of starting on Swivel (as per the ERC5095)
Declaration
Modifiers:
Modifier |
---|
authorized |
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Underlying token address associated with this market pair |
| address | Compound token address associated with this market pair |
| address | Address of the user receiving the underlying tokens |
| address | Amount of underlying being redeemed |
redeemZcToken
Allows zcToken holders to redeem their tokens for underlying tokens after maturity has been reached (via MarketPlace).
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum value associated with this market pair |
| address | Underlying token address associated with the market |
| uint256 | Maturity timestamp of the market |
| uint256 | Amount of zcTokens being redeemed |
redeemVaultInterest
Allows Vault owners to redeem any currently accrued interest (via MarketPlace)
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum value associated with this market pair |
| address | Underlying token address associated with the market |
| uint256 | Maturity timestamp of the market |
redeemSwivelVaultInterest
Allows Swivel to redeem any currently accrued interest (via MarketPlace)
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum value associated with this market pair |
| address | Underlying token address associated with the market |
| uint256 | Maturity timestamp of the market |
validOrderHash
Verifies the validity of an order and it's signature.
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| struct Hash.Order | An offline Swivel.Order |
| struct Sig.Components | Components of a valid ECDSA signature |
Returns:
Type | Description |
---|---|
| hashed order. |
deposit
Use the Protocol Enum to direct deposit type transactions to their specific library abstraction
This functionality is an abstraction used by
IVFZI
,IZFVI
andsplitUnderlying
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum Value |
| address | Address of an underlying token (used by Aave) |
| address | Compounding token address |
| uint256 | Amount to deposit todo compounding or underlying? |
withdraw
Use the Protocol Enum to direct withdraw type transactions to their specific library abstraction
This functionality is an abstraction used by
EVFZE
,EZFVE
,combineTokens
,redeemZcToken
andredeemVaultInterest
. Note that while there is an external methodwithdraw
also on this contract the unique method signatures (and visibility) exclude any possible clashing
Declaration
Modifiers:
No modifiers
Args:
Arg | Type | Description |
---|---|---|
| uint8 | Protocol Enum Value |
| address | Address of an underlying token (used by Aave) |
| address | Compounding token address |
| uint256 | Amount to withdraw |
Events
Cancel
Emitted on order cancellation
Initiate
Emitted on any initiate*
filled is 'principalFilled' when (vault:false, exit:false) && (vault:true, exit:true) filled is 'premiumFilled' when (vault:true, exit:false) && (vault:false, exit:true)
Exit
Emitted on any exit*
filled is 'principalFilled' when (vault:false, exit:false) && (vault:true, exit:true) filled is 'premiumFilled' when (vault:true, exit:false) && (vault:false, exit:true)
ScheduleWithdrawal
Emitted on token withdrawal scheduling
ScheduleApproval
Emitted on token approval scheduling
ScheduleFeeChange
Emitted on fee change scheduling
BlockWithdrawal
Emitted on token withdrawal blocking
BlockApproval
Emitted on token approval blocking
BlockFeeChange
Emitted on fee change blocking
ChangeFee
Emitted on a change to the fee structure
SetAdmin
Emitted on a change of the admin
Last updated