Smart Contracts

The smart contract we developed allows the issuance, matching, settlement and trading of peer to peer American put options on NFT collections.

User actions

Those actions can be executed by any user.

Issuance of an Order to make an Option

Happens offchain, to interact with function matchOrder

Issuance of a put Option happens offchain, through the signing of an Order by a wallet that will be designed as the Maker. The Maker can either be the Option buyer (the Seller of the NFT) or the Option seller (the Buyer of the NFT).

Any wallet can issue an Order.

The Order he will sign will include the following information :

Field
Description

Premium

Price that must be paid by the Option buyer (NFT Seller) (fees excluded)

Collateral

Price that must be paid by the Option seller (NFT Buyer) to collateralize the Option (fees excluded)

Validity

Timestamp until when the Order can be used

Expiry

Timestamp of the Option expiry

Nonce

Nonce to distinguish similar orders and facilitate cancellation of multiple orders

Fee

BullvBear platform fees as a %

Maker

Wallet address of the Maker

Asset

Currency of the Option (ETH/WETH only for now)

Collection

The collection on which the Option is

isBull

Whether the Maker is Bull (Buyer) or Bear (Seller)

This order is made available to anyone to use through our app on bullvbear.xyz

Additionally, the Maker will need to approve our smart contract to allow it to collect at least his price (Premium or Collateral) + Fees in the Asset (WETH only originally).

Those orders can be cancelled through function cancelOrder and function setMinimumValidNonce

Any user can check if an Order can be matched through function checkIsValidOrder

Matching the Option with a Taker

function matchOrder

The actual matching of the Option happens when a Taker will take the Order to the blockchain as well as the amount of money+fees he needs to bring as the Buyer or the Seller and therefore binds the Maker and the Taker together into a Contract.

Any wallet can execute a Match.

In that process, the Fee is kept in the smart contract.

Settlement by the Option buyer (Bear)

function settleContract

Before the Expiry specified in the Order, the Option buyer (Seller of the NFT) can decide to transfer a NFT of the Collection to the Option seller (Buyer of the NFT) for the collateral that is left in the smart contract : premium + collateral.

The Option buyer will first need to approve our smart contract to transfer NFTs from the collection out of his wallet. He will also need to have a NFT of the collection in his wallet.

Only the Seller can Settle an Option.

The NFT is kept in our smart contract and can be later retrieved by the Buyer through a call to function withdrawToken

Reclaim by the Option seller (Buyer)

function reclaimContract

Once the Expiry has passed and it has not been settled by the Seller, or the NFT has been sent by the Seller, the put Option is expired, and the Option seller (Buyer) can now reclaim the full amount left in the contract : premium + collateral or the NFT

The reclaim can be executed by the Buyer himself, or by any other party. In particular, we as BullvBear may decide to offer an auto reclaim feature where we will execute the reclaim ourselves, with the money obviously still going to the Option seller.

If needed, this can also be done as a batch to reclaim multiple Options in one transaction.

Selling an existing Bear or Bull position

Happens offchain, to interact with function reclaimContract

Any Buyer or Seller can decide to sell his position. In order to do so, she will sign a Sell Order offchain containing :

Field
Description

orderHash

ID of the Option with the position to be sold

isBull

If the position sold is the Buyer one or the Seller one

Whitelist

List of wallets that are allowed to use this Sell Order. If it's empty, anyone can use it.

Price

Minimum sell price requested by the position owner

Nonce

Nonce to distinguish similar Sell orders

Start

Timestamp from which the Sell Order can be used

Duration

Amount of time after Start during which the Sell Order can be used

Currency

Currency of the Price

Those Sell Orders can be cancelled through function cancelSellOrder and function setMinimumValidNonceSell

Any user can check if a Sell Order can be matched through function checkIsValidSellOrder

Buying an existing Buyer or Seller position

function buyPosition

The Sell Order can be used by anyone from the Sell Order Whitelist (or anyone if that whitelist is empty) to purchase the position at the Price. After buying it, the wallet that purchased the position is now the owner of that position and can settle/reclaim.

Transfer an existing Seller or Buyer position

function transferPosition

The owner of any position (Seller or Buyer) can transfer that position to another wallet for free.

Match a batch of orders

function batchMatchOrders

Allow a user to match multiple orders in one transaction.

Settle as a Seller a batch of options

function batchSettleContracts

A user can settle multiple Seller positions in one transaction.

Reclaim as a user a batch of options

function batchReclaimContracts

A user can reclaim a batch of Buyer positions in one transaction. The user does not need to be the Buyer in those transactions, but the money will still go to those Buyers.

Owner actions

Those actions can only be executed by the smart contract owner.

Choice of NFT collections

function setAllowedCollection

NFT collections will be allowed on the smart contract through a whitelist managed by the smart contract owner, BullvBear.

Choice of assets used

function setAllowedAsset

We will initially only allow WETH/ETH for Makers and takers. As the market evolves, we may allow more currencies to be used. This will be done through a whitelist managed by the smart contract owner, BullvBear.

Fees

function setFee and function withdrawFees

The smar contract owner, BullvBear, is able to change the fee level of the smart contract and to withdraw the fees accumulated in the contract. The fees will be capped at 5%. Fees are a % of all amounts going through the contract.

Last updated