MarketPlace
A TypeScript wrapper for the MarketPlace smart contract.
Overview
The MarketPlace contract wrapper allows a user to fetch market information from the MarketPlace smart contract, mature a market or transfer their vault notional.
Market information is returned in a struct of the following shape:
Market
Creating a MarketPlace instance
The snippet below illustrates how you can create a MarketPlace instance and what information you need to do so.
Properties
address
Holds the current contract address used by the MarketPlace instance.
Signature
Getters
admin
Allows a user to get the admin address of this MarketPlace.
Signature
Returns
A promise that resolves with the admin address if the contract call succeeds and rejects otherwise.
swivel
Allows a user to get the Swivel contract address associated with this MarketPlace.
Signature
Returns
A promise that resolves with the Swivel contract's address if the contract call succeeds and rejects otherwise.
paused
Allows a user to check if this MarketPlace has been paused.
Signature
Returns
A promise that resolves with true
or false
if the contract call succeeds and rejects otherwise.
Methods
constructor
Creates an instance of the MarketPlace smart contract wrapper.
Signature
Parameters
v
Vendor
A vendor instance (ethers.js or web3.js vendor) to use.
at
Connects a MarketPlace instance to a deployed MarketPlace smart contract on chain.
Signature
Parameters
a
string
The address of the deployed MarketPlace smart contract.
o
TxOptions
Optional transaction options to override ethers.js' default transaction options.
Returns
The connected MarketPlace instance.
markets
Allows a user to retrieve market information from the MarketPlace.
Signature
Parameters
u
string
The address of the market's underlying token.
m
uint256
The market's maturity.
Returns
A promise that resolves with a Market
if the contract call succeeds and rejects otherwise.
Example
Fetch the market information from one of Swivel's markets from the MarketPlace contract.
A market is identified my its underlying token address and its maturity. You can use the Swivel Exchange API to fetch the available markets (underlying/maturity pairs).
matureMarket
Allows a user to mature a market in the MarketPlace.
Signature
Parameters
u
string
The address of the market's underlying token.
m
uint256
The market's maturity.
Returns
A promise that resolves with a TxResonse
if the contract call succeeds and rejects otherwise.
transferVaultNotional
Allows a user to transfer the their notional from a market in the MarketPlace.
Signature
Parameters
u
string
The address of the market's underlying token.
m
uint256
The market's maturity.
t
string
The target address to which to transfer the notional.
a
uint256
The amount of notional to transfer.
Returns
A promise that resolves with a TxResonse
if the contract call succeeds and rejects otherwise.
Last updated