LogoLogo
Swivel v2.0.0
Swivel v2.0.0
  • Swivel Finance Documentation
  • Litepaper
    • zcTokens
      • Exiting/Selling zcTokens
      • Secondary AMM's
    • nTokens
      • Exiting/Selling nTokens
    • AMM vs. Orderbook
  • Swivel Exchange
    • Testnet Setup
    • Exchange Functions
      • Fixed-Yield Lending
      • Purchasing nTokens
      • Selling zcTokens
      • Selling nTokens
      • Splitting/Combining Tokens
      • Redeeming Tokens/Interest
    • Maturity
    • Liquidity Incentives
    • Minimums, Rate Limits & Fees
    • Retroactive Distribution
    • How to Claim SWIV Tokens
  • Developers
    • Exchange API
      • GET
        • Orderbook
        • Get Order
        • OHCLV (Candles)
        • Get Effective Price (Preview Market Order)
        • Get Order History
        • Get Last Trade Info
        • Get Markets
      • POST
        • Order
    • Swivel.js
      • API
        • Swivel
        • MarketPlace
        • VaultTracker
    • Swivel.py
      • swivel
        • swivel.abstracts
          • swivel.abstracts.deployed
          • swivel.abstracts.market_place
          • swivel.abstracts.swivel
          • swivel.abstracts.vault_tracker
        • swivel.contracts
          • swivel.contracts.market_place
          • swivel.contracts.swivel
          • swivel.contracts.vault_tracker
        • swivel.vendors
          • swivel.vendors.signer
          • swivel.vendors.w3
    • Scrivel (Python Examples)
    • Contracts Overview
      • Contracts
        • Swivel
        • MarketPlace
        • VaultTracker
    • Ubiquitous Language V2
      • Shared Language
      • UI Language
      • Technical Language
      • Compound Language
      • Finance Terms
  • Community & Media
  • Other Resources
    • Institutions
      • Rate Profile Optimization
        • Instruments and Participants
        • Market Opportunities and Pricing
        • Counterparty Risk Management
        • Benefits and drawbacks of standardization
        • User Needs
          • Corporate Treasury and Funding
          • Institutional Investors and Asset Managers
          • Speculators and Proprietary Trading Functions
          • Brokers and Market Makers
          • Liquidity Management, Funding and Resource Management
          • Risk Management and Insurance
          • Smaller Institutions and Individuals
      • Swivel for Enterprise
        • Overview
        • How Swivel works
        • Flexible Order Book
        • Future Developments
      • Delegated Credit
        • Challenges of Delegated Credit
          • Credit Pools
          • Intermediating Trust in Credit Delegation
Powered by GitBook
On this page
  • constructor
  • Parameters:
  • initiate
  • Parameters:
  • initiateVaultFillingZcTokenInitiate
  • Parameters:
  • initiateZcTokenFillingVaultInitiate
  • Parameters:
  • initiateZcTokenFillingZcTokenExit
  • Parameters:
  • initiateVaultFillingVaultExit
  • Parameters:
  • exit
  • Parameters:
  • exitZcTokenFillingZcTokenInitiate
  • Parameters:
  • exitVaultFillingVaultInitiate
  • Parameters:
  • exitVaultFillingZcTokenExit
  • Parameters:
  • exitZcTokenFillingVaultExit
  • Parameters:
  • cancel
  • Parameters:
  • transferAdmin
  • Parameters:
  • scheduleWithdrawal
  • Parameters:
  • blockWithdrawal
  • Parameters:
  • withdraw
  • Parameters:
  • setFee
  • Parameters:
  • approveUnderlying
  • Parameters:
  • splitUnderlying
  • Parameters:
  • combineTokens
  • Parameters:
  • redeemZcToken
  • Parameters:
  • redeemVaultInterest
  • Parameters:
  • validOrderHash
  • Parameters:
  • Return Values:
  • Initiate
  • Exit
  • ScheduleWithdrawal
  • BlockWithdrawal
  • SetFee
  1. Developers
  2. Contracts Overview
  3. Contracts

Swivel

Annotated source of the Swivel.sol smart contract

constructor

  function constructor(
    address m
  ) public

Parameters:

Name
Type
Description

m

address

deployed MarketPlace contract address

initiate

  function initiate(
    struct Hash.Order[] o,
    uint256[] a,
    struct Sig.Components[] c
  ) external returns (bool)

Allows a user to initiate a position

Parameters:

Name
Type
Description

o

struct Hash.Order[]

Array of offline Swivel.Orders

a

uint256[]

Array of order volume (principal) amounts relative to passed orders

c

struct Sig.Components[]

Array of Components from valid ECDSA signatures

initiateVaultFillingZcTokenInitiate

  function initiateVaultFillingZcTokenInitiate(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (premium) being filled by the taker's initiate

c

struct Sig.Components

Components of a valid ECDSA signature

initiateZcTokenFillingVaultInitiate

  function initiateZcTokenFillingVaultInitiate(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (principal) being filled by the taker's initiate

c

struct Sig.Components

Components of a valid ECDSA signature

initiateZcTokenFillingZcTokenExit

  function initiateZcTokenFillingZcTokenExit(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (principal) being filled by the taker's initiate

c

struct Sig.Components

Components of a valid ECDSA signature

initiateVaultFillingVaultExit

  function initiateVaultFillingVaultExit(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (interest) being filled by the taker's exit

c

struct Sig.Components

Components of a valid ECDSA signature

exit

  function exit(
    struct Hash.Order[] o,
    uint256[] a,
    struct Sig.Components[] c
  ) external returns (bool)

Allows a user to exit (sell) a currently held position to the marketplace.

Parameters:

Name
Type
Description

o

struct Hash.Order[]

Array of offline Swivel.Orders

a

uint256[]

Array of order volume (principal) amounts relative to passed orders

c

struct Sig.Components[]

Components of a valid ECDSA signature

exitZcTokenFillingZcTokenInitiate

  function exitZcTokenFillingZcTokenInitiate(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (interest) being filled by the taker's exit

c

struct Sig.Components

Components of a valid ECDSA signature

exitVaultFillingVaultInitiate

  function exitVaultFillingVaultInitiate(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (principal) being filled by the taker's exit

c

struct Sig.Components

Components of a valid ECDSA signature

exitVaultFillingZcTokenExit

  function exitVaultFillingZcTokenExit(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (principal) being filled by the taker's exit

c

struct Sig.Components

Components of a valid ECDSA signature

exitZcTokenFillingVaultExit

  function exitZcTokenFillingVaultExit(
    struct Hash.Order o,
    uint256 a,
    struct Sig.Components c
  ) internal

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

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being filled

a

uint256

Amount of volume (interest) being filled by the taker's exit

c

struct Sig.Components

Components of a valid ECDSA signature

cancel

  function cancel(
    struct Hash.Order o,
    struct Sig.Components c
  ) external returns (bool)

Allows a user to cancel an order, preventing it from being filled in the future

Parameters:

Name
Type
Description

o

struct Hash.Order

Order being cancelled

c

struct Sig.Components

Components of a valid ECDSA signature

transferAdmin

  function transferAdmin(
    address a
  ) external returns (bool)

Parameters:

Name
Type
Description

a

address

Address of a new admin

scheduleWithdrawal

  function scheduleWithdrawal(
    address e
  ) external returns (bool)

Allows the admin to schedule the withdrawal of tokens

Parameters:

Name
Type
Description

e

address

Address of (erc20) token to withdraw

blockWithdrawal

  function blockWithdrawal(
    address e
  ) external returns (bool)

Emergency function to block unplanned withdrawals

Parameters:

Name
Type
Description

e

address

Address of token withdrawal to block

withdraw

  function withdraw(
    address e
  ) external returns (bool)

Allows the admin to withdraw the given token, provided the holding period has been observed

Parameters:

Name
Type
Description

e

address

Address of token to withdraw

setFee

  function setFee(
    uint16 i,
    uint16 d
  ) external returns (bool)

Allows the admin to set a new fee denominator

Parameters:

Name
Type
Description

i

uint16

The index of the new fee denominator

d

uint16

The new fee denominator

approveUnderlying

  function approveUnderlying(
    address[] u,
    address[] c
  ) external returns (bool)

Allows the admin to bulk approve given compound addresses at the underlying token, saving marginal approvals

Parameters:

Name
Type
Description

u

address[]

array of underlying token addresses

c

address[]

array of compound token addresses

splitUnderlying

  function splitUnderlying(
    address u,
    uint256 m,
    uint256 a
  ) external returns (bool)

Allows users to deposit underlying and in the process split it into/mint zcTokens and vault notional. Calls mPlace.mintZcTokenAddingNotional

Parameters:

Name
Type
Description

u

address

Underlying token address associated with the market

m

uint256

Maturity timestamp of the market

a

uint256

Amount of underlying being deposited

combineTokens

  function combineTokens(
    address u,
    uint256 m,
    uint256 a
  ) external returns (bool)

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.

Parameters:

Name
Type
Description

u

address

Underlying token address associated with the market

m

uint256

Maturity timestamp of the market

a

uint256

Amount of zcTokens being redeemed

redeemZcToken

  function redeemZcToken(
    address u,
    uint256 m,
    uint256 a
  ) external returns (bool)

Allows zcToken holders to redeem their tokens for underlying tokens after maturity has been reached (via MarketPlace).

Parameters:

Name
Type
Description

u

address

Underlying token address associated with the market

m

uint256

Maturity timestamp of the market

a

uint256

Amount of zcTokens being redeemed

redeemVaultInterest

  function redeemVaultInterest(
    address u,
    uint256 m
  ) external returns (bool)

Allows Vault owners to redeem any currently accrued interest (via MarketPlace)

Parameters:

Name
Type
Description

u

address

Underlying token address associated with the market

m

uint256

Maturity timestamp of the market

validOrderHash

  function validOrderHash(
    struct Hash.Order o,
    struct Sig.Components c
  ) internal returns (bytes32)

Varifies the validity of an order and it's signature.

Parameters:

Name
Type
Description

o

struct Hash.Order

An offline Swivel.Order

c

struct Sig.Components

Components of a valid ECDSA signature

Return Values:

Name
Type
Description

the

struct Hash.Order

hashed order.

## Events

### Cancel

```solidity

event Cancel(

)

```

Emitted on order cancellation

Initiate

  event 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

  event 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

  event ScheduleWithdrawal(
  )

Emitted on token withdrawal scheduling

BlockWithdrawal

  event BlockWithdrawal(
  )

Emitted on token withdrawal blocking

SetFee

  event SetFee(
  )

Emitted on a change to the feenominators array

PreviousContractsNextMarketPlace

Last updated 2 years ago