/// import { Commitment, PublicKey, Transaction } from "@solana/web3.js"; import { web3 } from "@coral-xyz/anchor"; import { Dip, ParsedDipState } from "./types"; /** * API class with functions to interact with the DIP Program using Solana Web3 JS API. */ export declare class DIP { private connection; private program; private commitment; /** * Create a DIP helper object. * * @param rpcUrl The solana cluster endpoint used for the connecton. * @param commitment Commitment level for RPCs. Defaults to finalized. */ constructor(rpcUrl: string, commitment?: Commitment); /** * Deposit to the premium account. A normal token transfer can be used instead * of this. This is just a simplification since wallets dont always make it * easy to send to a PDA. * * @param authority Wallet where the USDC is coming from, must be signer. * @param usdcMint USDC mint which depends on the network used. * @param numPremiumTokenAtoms Premium amount. */ depositPremiumsInstruction(authority: PublicKey, usdcMint: PublicKey, numPremiumTokenAtoms: number): Promise; /** * Deposits specified amount to a premium account. * * @param authority Wallet where the USDC is coming from, must be signer. * @param usdcMint USDC mint which depends on the network used. * @param numPremiumTokenAtoms Premium amount. * @returns Transaction object with instruction for depositing premium. */ depositPremiumTransaction(authority: PublicKey, usdcMint: PublicKey, numPremiumTokenAtoms: number): Promise; /** * Initializes a DIP along with related mm account * * @param authority Wallet paying rent. Restricted to team wallets for now. * @param strikeAtomsPerBaseToken Strike price for the DIP. * @param expirationSec Expiration of the DIP. * @param baseMint Mint for the token that the user is depositing. * @param quoteMint Mint for the token that the user could be swapped into. */ initDip(authority: PublicKey, strikeAtomsPerBaseToken: number, expirationSec: number, baseMint: PublicKey, quoteMint: PublicKey, displayStrike: number): Promise; /** * Deposit into a DIP with streaming prices. Because the DMS is based on a * streaming price, this instruction is not guaranteed to be valid for long. * * @param authority Signer of the instruction. * @param numTokensAtoms How many tokens to deposit. * @param strikeAtomsPerBaseToken Strike price for the DIP. * @param expirationSec Expiration of the DIP. * @param baseMint Mint for the token that the user is depositing. * @param quoteMint Mint for the token that the user could be swapped into. * @param usdcMint Usdc mint for premium token. Cannot necessarily be inferred from other inputs. */ depositStreamingInstruction(authority: PublicKey, numTokensAtoms: number, strikeAtomsPerBaseToken: number, expirationSec: number, baseMint: PublicKey, quoteMint: PublicKey, usdcMint: PublicKey): Promise; /** * Deposit into a DIP with streaming prices. This method sets up * associated token accounts, syncs native balance and leverages LSOs * if mint is available for provided parameters. * * @param authority Signer of the instruction. * @param amount How many tokens (in base atoms) to deposit. * @param strikeInQuoteAtomsPerBaseToken Strike price (in quote atoms per base token) of the DIP. * @param expirationInSeconds Expiration of the DIP in unix seconds. * @param baseMint Mint for the token being deposited. * @param quoteMint Mint for the token that could be swapped into. * @param premiumMint Mint for premium token. * @returns Transaction object with instructions needed to deposit into a DIP */ depositStreamingTransaction(authority: PublicKey, amount: number, strikeInQuoteAtomsPerBaseToken: number, expirationInSeconds: number, baseMint: PublicKey, quoteMint: PublicKey, premiumMint: PublicKey): Promise; /** * Get an instruction to withdraw from an expired DIP * * @param authority Signer for the instruction. * @param strikeAtomsPerBaseToken Strike price for the DIP. * @param expirationSec Expiration of the DIP. * @param baseMint Mint for the token that the user is depositing. * @param quoteMint Mint for the token that the user could be swapped into. */ withdrawInstruction(authority: PublicKey, strikeAtomsPerBaseToken: number, expirationSec: number, baseMint: PublicKey, quoteMint: PublicKey): Promise; /** * Exercises a long DIP token. This method sets up associated token accounts, * syncs native balance if denominated in SOL and adds exercise instruction * all under one transaction. * * @param authority Signer for the transaction. * @param numTokensAtoms Amount in quote token atoms. * @param strikeAtomsPerBaseToken Strike price (in quote atoms per base token) of the DIP. * @param expirationSec Expiration of the DIP in unix seconds. * @param baseMint Mint for the token that mm swaps to. * @param quoteMint Mint for the token that mm swaps from. */ exerciseOptionsTransaction(authority: PublicKey, numTokensAtoms: number, strikeAtomsPerBaseToken: number, expirationSec: number, baseMint: PublicKey, quoteMint: PublicKey): Promise; /** * Get an instruction to exercise a long DIP token. * * @param authority Signer for the instruction. * @param strikeAtomsPerBaseToken Strike price for the DIP. * @param expirationSec Expiration of the DIP. * @param baseMint Mint for the token that the user is depositing. * @param quoteMint Mint for the token that the user could be swapped into. */ exerciseOptionInstruction(authority: PublicKey, numTokensAtoms: number, strikeAtomsPerBaseToken: number, expirationSec: number, baseMint: PublicKey, quoteMint: PublicKey): Promise; /** * Fetch all DIPs that are currently active and usable. Returns an object * which maps base token to an array of Dip objects. */ getActiveDips(): Promise<{ [pk: string]: Dip[]; }>; /** * Parse a DIPState using the idl. */ parseDipState(buf: Buffer): ParsedDipState; /** * Fetch all the onchain dipMm pricing accounts for active DIPs and return an * MmPrice object. */ private fetchMmPricing; }