Skip to main content
This guide shows how to sell a covered WETH call and collect the premium. At the end, the wallet holds the receipt tokens and the USDC premium, and the trade shows as an open position.
There is no testnet environment. To test your integration, use small amounts on mainnet.

Before you begin

  • Get an API key with options taker access. Contact Us.
  • Use a wallet that holds the WETH collateral and ETH for gas. The wallet must hold no option tokens of the instrument that you sell.
  • Have the URL of an Ethereum RPC node.
  • Install the Python packages: pip install httpx web3.
  • Set the environment variables BEBOP_API_KEY, ETH_RPC_URL, and PRIVATE_KEY. Do not put the private key in the source code.
The examples on this page and in the guides use these settings:
1

Find an instrument

List the active WETH calls and choose one where canSell is true. The instrument field is the option token address.The Python example chooses the nearest expiry and its highest strike. Change the selection to the strike and the expiry that you want to sell.
The output is similar to:
If nextCursor is not null, more instruments are on the next page. See List instruments.
2

Set the amount

The amount is in raw collateral units. A WETH call uses 18 decimals, so 0.01 WETH is 10000000000000000.
For a put, the amount is in USDC (6 decimals): the strike times the underlying amount. See Amounts.
3

Approve the collateral to the Greek Factory

The Greek Factory pulls the collateral when the trade settles. Read its address from the factory field of the instrument.
4

Grant the settlement contract the open permission

This permission lets the settlement contract transfer and mint option tokens for the wallet, for every instrument of this Greek Factory. It is not limited to an amount.
Add mask 3 (TRANSFER | MINT) for the settlement contract. Use addPermissions. setPermissions replaces the complete mask.
5

Request a quote

Request a sell-to-open quote with validate=true. Bebop then also checks the wallet balance, allowance, and permission, and lists any problem in issues.
The output is similar to:
premium is the USDC that the wallet receives, after the Bebop fee, in raw units (6 decimals). In this example, the wallet receives 0.643 USDC. fee is already deducted from premium.
6

Send the transaction

Send tx from the wallet in taker_address. The quote is firm until expiry, a Unix timestamp in seconds. Do not change tx.data.
If expiry passes before you send, request a new quote.
7

Verify the position

Read the position with the positionId from the quote. Bebop returns 404 until it indexes the transaction, so try again while the response is 404.
The output is similar to:
The wallet now holds 0.01 RT of the instrument, and its WETH balance is 0.01 lower.

If it does not work