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
  • Classes
  • Functions
  1. Build with PsyFi
  2. Developers
  3. Client Integration

Namespace: serumInstructions

PreviousNamespace: instructionsNextNamespace: serum utils

Last updated 3 years ago

Classes

Functions

cancelAllOpenOrders

▸ Const cancelAllOpenOrders(program, optionMarketKey, dexProgramId, serumMarketKey): Promise<TransactionInstruction[]>

Create an array of TransactionInstructions to cancel all of the wallet's orders for a given OptionMarket and SerumMarket.

NOTE: Current implementation does not account for Transaction packet size limitations. It is on the client to slice the instructions to be within the limits.

Parameters

Name
Type
Description

program

Anchor Program for Psy American

optionMarketKey

PublicKey

The address of the OptionMarket for the option in the Seurm Market

dexProgramId

PublicKey

The PublicKey of the DEX program

serumMarketKey

PublicKey

The PublicKey of the Serum market

Returns

Promise<TransactionInstruction[]>

Defined in

cancelOrderByClientId

▸ Const cancelOrderByClientId(program, optionMarketKey, dexProgramId, serumMarketKey, order, marketAuthorityBump?): Promise<TransactionInstruction>

Generate a TransactionInstruction for canceling an open order by the set clientId

Parameters

Name
Type
Description

program

Anchor Program for Psy American

optionMarketKey

PublicKey

The address of the OptionMarket for the option in the Seurm Market

dexProgramId

PublicKey

The PublicKey of the DEX program

serumMarketKey

PublicKey

The PublicKey of the Serum market

order

Order

The Serum Order to cancel

marketAuthorityBump

number

Optional: bump seed for the Serum market

Returns

Promise<TransactionInstruction>

Defined in

cancelOrderInstructionV2

▸ Const cancelOrderInstructionV2(program, optionMarketKey, dexProgramId, serumMarketKey, order, marketAuthorityBump?): Promise<TransactionInstruction>

Create a TransactionInstruction for canceling a specific order

Parameters

Name
Type
Description

program

Anchor Program for Psy American

optionMarketKey

PublicKey

The address of the OptionMarket for the option in the Seurm Market

dexProgramId

PublicKey

The PublicKey of the DEX program

serumMarketKey

PublicKey

The PublicKey of the Serum market

order

Order

The Serum Order to cancel

marketAuthorityBump

number

Optional: bump seed for the Serum market

Returns

Promise<TransactionInstruction>

Defined in

closeOpenOrdersInstruction

▸ Const closeOpenOrdersInstruction(program, optionMarketKey, dexProgramId, serumMarketKey, openOrdersKey, marketAuthorityBump, solWallet?): Promise<TransactionInstruction>

Create instruction to close OpenOrders account.

Parameters

Name
Type
Description

program

Anchor Psy American Program

optionMarketKey

PublicKey

The OptionMarket address

dexProgramId

PublicKey

The Serum DEX program ID

serumMarketKey

PublicKey

The Serum market address

openOrdersKey

PublicKey

The open orders key for the account we're closing

marketAuthorityBump

number

OPTIONAL: pass in the market authority bump seed

solWallet?

PublicKey

OPTIONAL: pass in a different address to send the unlocked Sol to

Returns

Promise<TransactionInstruction>

Defined in

initOpenOrdersInstruction

▸ Const initOpenOrdersInstruction(program, owner, optionMarketKey, dexProgramId, serumMarketKey, marketAuthorityBump?): Promise<Object>

Create a proxied InitOpenOrdersInstruction

Parameters

Name
Type
Description

program

Anchor Psy American program

owner

PublicKey

The user's wallet address

optionMarketKey

PublicKey

The OptionMarket address key

dexProgramId

PublicKey

Serum DEX id

serumMarketKey

PublicKey

The Serum market address

marketAuthorityBump

number

OPTIONAL: pass in the market authority bump seed

Returns

Promise<Object>

Defined in

marketLoader

▸ Const marketLoader(program, optionMarketKey, marketAuthorityBump, dexProgramId, marketKey, opts?): Promise<MarketProxy>

Create a MarketProxy for the Psy American V 1.1 program

Parameters

Name
Type
Description

program

Anchor Psy American program

optionMarketKey

PublicKey

The OptionMarket address

marketAuthorityBump

number

The marketAuthority bump seed

dexProgramId

PublicKey

The Serum DEX program id

marketKey

PublicKey

The Serum market address

opts

Object

-

opts.enableLogger

boolean

-

Returns

Promise<MarketProxy>

Defined in

newOrderInstruction

▸ Const newOrderInstruction(program, optionMarketKey, dexProgramId, serumMarketKey, orderArguments, marketAuthorityBump?): Promise<Object>

Create a new order proxied through the Psy American Protocol

Parameters

Name
Type
Description

program

Anchor Psy American program

optionMarketKey

PublicKey

The OptionMarket address

dexProgramId

PublicKey

The Serum DEX program ID

serumMarketKey

PublicKey

The Serum market address

orderArguments

The Serum OrderParams

marketAuthorityBump

number

OPTIONAL: pass in the market authority bump seed

Returns

Promise<Object>

Defined in

settleFundsInstruction

▸ Const settleFundsInstruction(program, optionMarketKey, dexProgramId, serumMarketKey, baseWallet, quoteWallet, serumReferralKey, openOrdersKey, marketAuthorityBump?): Promise<TransactionInstruction>

Create a TransactionInstruction for the settleFunds instruction

Parameters

Name
Type
Description

program

Anchor Psy American Program

optionMarketKey

PublicKey

The OptionMarket address

dexProgramId

PublicKey

The Serum DEX program ID

serumMarketKey

PublicKey

The Serum market address

baseWallet

PublicKey

The wallet address that contains the user's base asset tokens

quoteWallet

PublicKey

The wallet address that contains the user's quote asset tokens

serumReferralKey

PublicKey

The Psy American referral address for the quote asset

openOrdersKey

PublicKey

The open orders keys

marketAuthorityBump

number

OPTIONAL: pass in the market authority bump seed

Returns

Promise<TransactionInstruction>

Defined in

settleMarketFundsInstruction

▸ Const settleMarketFundsInstruction(program, optionMarketKey, dexProgramId, serumMarket, baseWallet, quoteWallet, openOrdersKey): Promise<TransactionInstruction>

Create a TransactionInstruction for the settleFunds instruction

Note: this API abstracts the complexity of the serumReferralKey away.

Parameters

Name
Type
Description

program

Anchor Psy American Program

optionMarketKey

PublicKey

The OptionMarket address

dexProgramId

PublicKey

The Serum DEX program ID

serumMarket

Market

The Serum market

baseWallet

PublicKey

The wallet address that contains the user's base asset tokens

quoteWallet

PublicKey

The wallet address that contains the user's quote asset tokens

openOrdersKey

PublicKey

The open orders keys

Returns

Promise<TransactionInstruction>

Defined in

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

Program<>

<PublicKey>

Program<>

Program<>

Validation
serumInstructions/cancelOrder.ts:109
serumInstructions/cancelOrder.ts:63
serumInstructions/cancelOrder.ts:22
serumInstructions/closeOpenOrders.ts:19
serumInstructions/initOpenOrders.ts:18
serumInstructions/marketLoader.ts:16
serumInstructions/newOrder.ts:22
serumInstructions/settleFunds.ts:24
serumInstructions/settleFunds.ts:74
PsyAmerican
PsyAmerican
PsyAmerican
PsyAmerican
PsyAmerican
PsyAmerican
PsyAmerican
OrderParamsWithFeeRate
PsyAmerican
PsyAmerican