🛠️Custom Contracts

Vyper Protocol allows to create a custom new contract. Let's see how it works. First of all head over to the "Create" page.

There are five steps to create a new contract.

1. PAYOFF

First of all you should select the payoff of the contract, i.e. the type of the derivative you're about to trade. Below each one you will see a short explanation, a link to our Notion with more details and a link to the source code if you want to see the smart contract.

2. UNDERLYING

After the payoff, you should select the underlying of the contract. This is the price of the asset on which the contract is based. We support a large number of underlyings, leveraging oracles from Pyth and Switchboard. In devnet you can also add your own oracle, see

3. CONTRACT PARAMETERS

After the underlying, you should select the parameters of the contract. These depend on the specific payoff you chose at step 1. In this case, since we selected an option, we need to chose the strike price and whether the option is a call option or put option.

4. COLLATERAL

After the parameters, you should select the collateral of your contract. This is the token that the parties of the trade will have to deposit in the contract to enter the trade. You need to specify the two amounts (for long and short) as well as the mint of the token. We currently support USDC and BONK as collateral.

Note that all contract are fully collateralized. That means that after the collateral is deposited, nothing can be deposited or withdrawn until the contract has settled. Learn more here.

5. EXPIRY

Finally, you should select the expiry of the contract. There are two expiries:

  • The deposit window: is how long the parties of the trade have to deposit the collateral in the contract. Both long and short need to deposit, otherwise the contract will not start

  • The contract expiry: is when the trade will finish. After this date, the parties will be able to withdraw their deposited collateral plus profits/losses

After all the steps are completed you can view a Preview of the contract you're about to create. This is a human readable summary of the contract.

If everything checks out, you can click Create and you will be asked to sign a transaction in your wallet.

That's it! You just created a completely permissionless derivative contract, congrats 🥳

Examples

ETHUSD Forward margined in BONK

You and your friend decides to make a trade based on the future price of ETHUSD, you just received your BONK airdrop so you decide to settle the trade in BONK. How can you do so with Vyper? It's easy!

PAYOFF = Forward

UNDERLYING = ETHUSD

STRIKE = Last traded price (1'350$ as of writing)

NOTIONAL = 1000

COLLATERAL = 100'000 BONK for both LONG and SHORT

DEPOSIT WINDOW = enough time for you and your friend to deposit the collateral

CONTRACT EXPIRY = whatever time in the future you agree with your friend: for example a month.

How does the PnL of this trade looks like? In 1 month, Vyper will retrieve the ETHUSD price from the oracle. With a notional of 1000 (ETH) and collateral in BONK, the users are earning/losing 1'000 BONK for each increase/decrease in the $ price of ETHUSD.

For example if ETH is trading at 1'425$ in 1 month, the LONG side will earn 75'000 BONK and the SHORT side will pay 75'000 BONK.

If ETH is trading at 1'300$ in 1 month, the LONG side will pay 50'000 BONK and the SHORT side will earn 50'000 BONK

BTCUSD Vanilla option margined in USDC

PAYOFF = Vanilla Option

UNDERLYING = BTCUSD

STRIKE = 25'000$ (current price of 23'200$ as of writing)

NOTIONAL = 1

TYPE = CALL

COLLATERAL = 100 USDC for the LONG and 1'500 USDC for the SHORT

DEPOSIT WINDOW = enough time for you and your friend to deposit the collateral

CONTRACT EXPIRY = 1 week

How does the PnL of this trade looks like? In 1 month, Vyper will retrieve the BTCUSD price from the oracle. Notional for this trade is 1 (BTC) and collateral is USDC, the users deposited different amount of collateral and the payoff is non linear (vanilla option).

If BTC is trading at 26'000$ in 1 week, the LONG side will earn 900 USDC and the SHORT side will pay 900 USDC (SHORT has received 100 USDC premium and paid out 1'000 USDC)

If BTC is trading at 24'000$ in 1 week, the LONG side will pay 100 USDC and the SHORT side will earn 100 USDC (SHORT has received 100 USDC premium and paid out nothing)

Note for Phantom DEVNET users

If you use Phantom and try to create a contract in devnet you will be shown this warning. This is because Phantom does not automatically detect that you're making a devnet transaction. You can safely ignore this warning a proceed.

Other wallets e.g. Solflare automatically detect the devnet so you won't see this warning.

Last updated