PsyFi Documentation
  • Welcome to PsyFi
    • Why use PsyFi?
    • PsyFi Product Suite
    • PsyVaults - Vaults Product
      • 🏗️Covered Calls & Secured Puts Vaults Architecture
      • 📶Leveraged Strategy Vaults (Call Spreads & Put Spreads) - Currently Paused
      • 💹Market Making Vaults - Currently Paused
      • 📚PsyVaults Resources
        • PsyFi Vault Contracts
      • 👩‍🏫PsyVaults Tutorials
        • 💵Weekly Bidding on V2 Vaults
        • 💰PsyVault Rewards
          • Auto-Deposit into PsyLend to Earn Rewards
          • Understanding Staking Rewards
          • Boosting your Staking Rewards
      • ❓PsyVaults FAQs
    • PsyLend - Structured Products Lending
      • 👩‍🎓Tutorials - Supplying & Borrowing
      • 🎰Supply & Interest Rate Calculations
      • 🅿️Lending Parameters
      • ⚒️Liquidations
      • 💰Rewards
      • ⚡Fees
      • *️Risks & Insurance Fund
      • PsyLend FAQs
      • PsyLend Glossary
  • PsyFi DAO Audits
    • Audits
  • Build with PsyFi
    • Options Protocol
      • American Style Options
      • Tokenized European Style Options
      • Under-Collateralized European Style Options
      • PsyOptions FAQ
    • Fusion - Airdropping Options - Deprecated
      • 👩‍🏫Fusion Tutorials
        • Users: Option Rewards and What You Can Do With Them
        • Users: Claiming Airdrops Through Fusion
    • Developers
      • Program Integration
      • Client Integration
        • Namespace: instructions
        • Namespace: serumInstructions
        • Namespace: serum utils
        • Enumeration: ClusterName
        • Enumeration: ProgramVersions
        • Class: Validation
      • PsyFi DAO Contributor Support
    • Designers
      • Logos
      • Fonts
  • Options Education
    • Styles of Options
    • Calls & Puts
    • Option Strategies
    • Glossary
  • PSY Token & DAO
    • PSY Tokenomics
      • PSY Token Unlock Schedule
    • Governance Infrastructure & Tokenomics
    • Governance Parameters
    • PSY 2.0: PSY Stake and DeMux Overview [RFC]
    • Governance Tutorials
      • Governance Overview & Walkthrough
      • Initializing a Proposal Using Poseidon [RFC]
      • PsyOptions Protocol Governance Actions
      • Voter Stake Registry Set Up
        • How to Lock Your Own Tokens
        • How to Propose Issuing Locked Tokens
        • How to Propose Clawing Back Granted Tokens
      • PSY 2.0 - How to Stake Your PSY to Start Participating in PSY 2.0 Governance
      • PSY 2.0 - How to Claim Rewards For Staked PSY
      • PSY 2.0 - How to Setup a RewardPool
      • PSY 2.0 - How to perform DeMuX Actions on Reward Pools [RFC]
      • PSY 2.0 - How to view tokens that are sent to DeMux [RFC]
    • Governance FAQ
      • 🐛PSY DAO Bug Bounty
    • Poseidon [RFC]
    • PsyFi DAO Contributors
Powered by GitBook
On this page
  1. Build with PsyFi
  2. Developers
  3. Client Integration

Namespace: instructions

PreviousClient IntegrationNextNamespace: serumInstructions

Last updated 3 years ago

Functions

burnWriterForQuote

▸ Const burnWriterForQuote(program, size, optionMarket, writerTokenSrc, writerQuoteDest): TransactionInstruction

Burn WriterTokens to get the size * OptionMarket.quoteAmountPerContract from the OptionMarket's quote asset pool. This instruction will fail if no one has exercised or the quote assets in the pool have already been claimed.

Parameters

Name
Type
Description

program

Anchor Program for Psy American

size

BN

The amount of WriterTokens to burn and retrieve the quote assets for

optionMarket

The deserialized OptionMarket data

writerTokenSrc

PublicKey

The SPL Token account that holds the WriterTokens

writerQuoteDest

PublicKey

SPL Token account that is the destination for the quote assets

Returns

TransactionInstruction

Defined in

closePositionInstruction

▸ Const closePositionInstruction(program, size, optionMarket, writerTokenSrc, optionTokenSrc, underlyingAssetDest): TransactionInstruction

Close size option positions by burning the OptionTokens and WriterTokens.

Parameters

Name
Type
Description

program

Anchor Program for Psy American

size

BN

The amount of OptionTokens and WriterTokens to burn

optionMarket

The OptionMarket the OptionTokens and WriterTokens belong to

writerTokenSrc

PublicKey

The SPL Token address that holds the WriterTokens

optionTokenSrc

PublicKey

The SPL Token address that holds the OptionTokens

underlyingAssetDest

PublicKey

The SPL Token address destination for the returned underlying assets

Returns

TransactionInstruction

Defined in

closePostExpirationInstruction

▸ Const closePostExpirationInstruction(program, size, optionMarket, writerTokenSrc, underlyingAssetDest): TransactionInstruction

After a market has expired, burn WriterTokens to get the underlying assets back from the contract(s).

Parameters

Name
Type
Description

program

Anchor Program for Psy American

size

BN

The amount of options to exercise

optionMarket

The OptionMarket data from the chain for the options to exercise

writerTokenSrc

PublicKey

The SPL Token address holding the WriterTokens

underlyingAssetDest

PublicKey

The SPL Token address where the underlying assets will be sent

Returns

TransactionInstruction

Defined in

exerciseOptionsInstruction

▸ Const exerciseOptionsInstruction(program, size, optionMarket, exerciserOptionTokenSrc, underlyingAssetDest, quoteAssetSrc, opts?): Promise<TransactionInstruction>

Exercise OptionTokens you're holding

Parameters

Name
Type
Description

program

Anchor Program for Psy American

size

BN

The amount of options to exercise

optionMarket

The OptionMarket data from the chain for the options to exercise

exerciserOptionTokenSrc

PublicKey

The SPL Token address holding the OptionTokens

underlyingAssetDest

PublicKey

The SPL Token address where the underlying assets will be sent

quoteAssetSrc

PublicKey

The SPL Token address holding the quote asset used to exercise

opts

Object

opts.optionAuthority?

PublicKey

The authority account that owns the options

Returns

Promise<TransactionInstruction>

Defined in

exerciseOptionsV2Instruction

▸ Const exerciseOptionsV2Instruction(program, size, optionMarket, exerciserOptionTokenSrc, underlyingAssetDest, quoteAssetSrc, opts?): TransactionInstruction

Exercise OptionTokens you're holding without fees!

Parameters

Name
Type
Description

program

Anchor Program for Psy American

size

BN

The amount of options to exercise

optionMarket

The OptionMarket data from the chain for the options to exercise

exerciserOptionTokenSrc

PublicKey

The SPL Token address holding the OptionTokens

underlyingAssetDest

PublicKey

The SPL Token address where the underlying assets will be sent

quoteAssetSrc

PublicKey

The SPL Token address holding the quote asset used to exercise

opts

Object

opts.optionAuthority?

PublicKey

The authority account that owns the options

Returns

TransactionInstruction

Defined in

initializeMarket

▸ Const initializeMarket(program, __namedParameters): Promise<Object>

Initialize a new OptionMarket

Parameters

Name
Type
Description

program

The Psy American program

__namedParameters

Object

-

__namedParameters.expirationUnixTimestamp

BN

The option market expiration timestamp in seconds

__namedParameters.quoteAmountPerContract

BN

The quote amount per contract for the OptionMarket Strike price is derived from underlyingAmountPerContract & quoteAmountPerContract

__namedParameters.quoteMint

PublicKey

The quote asset mint

__namedParameters.underlyingAmountPerContract

BN

The underlying amount per contract for the OptionMarket. * Strike price is derived from underlyingAmountPerContract & quoteAmountPerContract

__namedParameters.underlyingMint

PublicKey

The underlying mint address

Returns

Promise<Object>

Defined in

initializeSerumMarket

▸ Const initializeSerumMarket(program, __namedParameters): Promise<Object>

Parameters

Name
Type
Description

program

Anchor Psy American Program

__namedParameters

Object

-

__namedParameters.asks?

PublicKey

The address for the new Serum market's asks

__namedParameters.bids?

PublicKey

The address for the new Serum market's bids

__namedParameters.eventQueue?

PublicKey

The address for the new Serum market's eventual Event Queue

__namedParameters.optionMarketKey

PublicKey

The OptionMarket address that owns the OptionToken mint

__namedParameters.optionMint

PublicKey

The OptionToken's Mint address. This is the base token for the Serum market

__namedParameters.pcDustThreshold

BN

Serum market's dust threshold for the price currency

__namedParameters.pcLotSize

BN

Serum market's price currency lot size

__namedParameters.pcMint

PublicKey

The Serum's price currency mint

__namedParameters.serumProgramKey

PublicKey

The Serum DEX program ID

Returns

Promise<Object>

Defined in

mintOptionInstruction

▸ Const mintOptionInstruction(program, minterOptionAcct, minterWriterAcct, minterUnderlyingAccount, size, optionMarket): Promise<Object>

Create a TransactionInstruction for minting size option contracts

Parameters

Name
Type
Description

program

Anchor Program for the PsyAmerican program and the minter as the provider wallet

minterOptionAcct

PublicKey

Where the OptionTokens will be sent

minterWriterAcct

PublicKey

Where the WriterTokens will be sent

minterUnderlyingAccount

PublicKey

Where the underlying asset tokens come from

size

BN

The amount of contracts to mint

optionMarket

The OptionMarket data

Returns

Promise<Object>

Defined in

mintOptionV2Instruction

▸ Const mintOptionV2Instruction(program, minterOptionAcct, minterWriterAcct, minterUnderlyingAccount, size, optionMarket): Promise<Object>

Create a TransactionInstruction for minting size option contracts using V2 instruction

Parameters

Name
Type
Description

program

Anchor Program for the PsyAmerican program and the minter as the provider wallet

minterOptionAcct

PublicKey

Where the OptionTokens will be sent

minterWriterAcct

PublicKey

Where the WriterTokens will be sent

minterUnderlyingAccount

PublicKey

Where the underlying asset tokens come from

size

BN

The amount of contracts to mint

optionMarket

The OptionMarket data

Returns

Promise<Object>

Defined in

mintOptionsTx

▸ Const mintOptionsTx(program, minterOptionAcct, minterWriterAcct, minterUnderlyingAccount, size, optionMarket): Promise<Object>

Execute a transaction to mint size options

Parameters

Name
Type
Description

program

Anchor Program for the PsyAmerican program and the minter as the provider wallet

minterOptionAcct

PublicKey

Where the OptionTokens will be sent

minterWriterAcct

PublicKey

Where the WriterTokens will be sent

minterUnderlyingAccount

PublicKey

Where the underlying asset tokens come from

size

BN

The amount of contracts to mint

optionMarket

The OptionMarket data

Returns

Promise<Object>

Defined in

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

instructions/burnWriterForQuote.ts:18
instructions/closePosition.ts:17
instructions/closePostExpiration.ts:17
instructions/exerciseOptions.ts:21
instructions/exerciseOptions.ts:85
instructions/initializeMarket.ts:30
instructions/initializeSerumMarket.ts:22
instructions/mintOptions.ts:92
instructions/mintOptions.ts:156
instructions/mintOptions.ts:29
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey
PsyAmerican
PsyAmerican
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey
PsyAmerican
OptionMarketWithKey