|
| 1 | +import { AccountInfo, PublicKey, Transaction } from '@solana/web3.js' |
| 2 | +import { Market, OpenOrders } from '@project-serum/serum' |
| 3 | +import { Event } from '@project-serum/serum/lib/queue' |
| 4 | +import { I80F48 } from '@blockworks-foundation/mango-client' |
| 5 | + |
| 6 | +export interface Token { |
| 7 | + chainId: number // 101, |
| 8 | + address: string // 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', |
| 9 | + symbol: string // 'USDC', |
| 10 | + name: string // 'Wrapped USDC', |
| 11 | + decimals: number // 6, |
| 12 | + logoURI: string // 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW/logo.png', |
| 13 | + tags: string[] // [ 'stablecoin' ] |
| 14 | +} |
| 15 | +export interface MarketInfo { |
| 16 | + address: PublicKey |
| 17 | + name: string |
| 18 | + programId: PublicKey |
| 19 | + deprecated: boolean |
| 20 | + quoteLabel?: string |
| 21 | + baseLabel?: string |
| 22 | +} |
| 23 | + |
| 24 | +export interface CustomMarketInfo { |
| 25 | + address: string |
| 26 | + name: string |
| 27 | + programId: string |
| 28 | + quoteLabel?: string |
| 29 | + baseLabel?: string |
| 30 | +} |
| 31 | + |
| 32 | +export interface TokenAccount { |
| 33 | + pubkey: PublicKey |
| 34 | + account: AccountInfo<Buffer> | null |
| 35 | + effectiveMint: PublicKey |
| 36 | +} |
| 37 | + |
| 38 | +export interface Trade extends Event { |
| 39 | + side: string |
| 40 | + price: number |
| 41 | + feeCost: number |
| 42 | + size: number |
| 43 | +} |
| 44 | + |
| 45 | +interface BalancesBase { |
| 46 | + key: string |
| 47 | + symbol: string |
| 48 | + wallet?: number | null | undefined |
| 49 | + orders?: number | null | undefined |
| 50 | + openOrders?: OpenOrders | null | undefined |
| 51 | + unsettled?: number | null | undefined |
| 52 | +} |
| 53 | + |
| 54 | +export interface Balances extends BalancesBase { |
| 55 | + market?: Market | null | undefined |
| 56 | + deposits?: I80F48 | null | undefined |
| 57 | + borrows?: I80F48 | null | undefined |
| 58 | + net?: I80F48 | null | undefined |
| 59 | + value?: I80F48 | null | undefined |
| 60 | + depositRate?: I80F48 | null | undefined |
| 61 | + borrowRate?: I80F48 | null | undefined |
| 62 | + decimals?: number | null | undefined |
| 63 | +} |
| 64 | + |
| 65 | +export interface OpenOrdersBalances extends BalancesBase { |
| 66 | + market?: string | null | undefined |
| 67 | + baseCurrencyAccount: |
| 68 | + | { pubkey: PublicKey; account: AccountInfo<Buffer> } |
| 69 | + | null |
| 70 | + | undefined |
| 71 | + quoteCurrencyAccount: |
| 72 | + | { pubkey: PublicKey; account: AccountInfo<Buffer> } |
| 73 | + | null |
| 74 | + | undefined |
| 75 | +} |
| 76 | + |
| 77 | +export interface EndpointInfo { |
| 78 | + name: string |
| 79 | + url: string |
| 80 | + websocket: string |
| 81 | + custom: boolean |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * {tokenMint: preferred token account's base58 encoded public key} |
| 86 | + */ |
| 87 | +export interface SelectedTokenAccounts { |
| 88 | + [tokenMint: string]: string |
| 89 | +} |
| 90 | + |
| 91 | +export interface ChartTradeType { |
| 92 | + market: string |
| 93 | + size: number |
| 94 | + price: number |
| 95 | + orderId: string |
| 96 | + time: number |
| 97 | + side: string |
| 98 | + feeCost: number |
| 99 | + marketAddress: string |
| 100 | +} |
| 101 | + |
| 102 | +export interface FeeRates { |
| 103 | + taker: number |
| 104 | + maker: number |
| 105 | +} |
| 106 | + |
| 107 | +// Type declaration for the margin accounts for the mango group |
| 108 | +export type mangoTokenAccounts = { |
| 109 | + mango_group: string |
| 110 | + accounts: TokenAccount[] |
| 111 | +} |
| 112 | + |
| 113 | +// Token infos |
| 114 | +export interface KnownToken { |
| 115 | + tokenSymbol: string |
| 116 | + tokenName: string |
| 117 | + icon?: string |
| 118 | + mintAddress: string |
| 119 | +} |
| 120 | + |
| 121 | +export const DEFAULT_PUBLIC_KEY = new PublicKey( |
| 122 | + '11111111111111111111111111111111' |
| 123 | +) |
| 124 | + |
| 125 | +export interface WalletAdapter { |
| 126 | + publicKey: PublicKey |
| 127 | + autoApprove: boolean |
| 128 | + connected: boolean |
| 129 | + signTransaction: (transaction: Transaction) => Promise<Transaction> |
| 130 | + signAllTransactions: (transaction: Transaction[]) => Promise<Transaction[]> |
| 131 | + connect: () => any |
| 132 | + disconnect: () => any |
| 133 | + on(event: string, fn: () => void): this |
| 134 | +} |
| 135 | + |
| 136 | +export interface PerpTriggerOrder { |
| 137 | + orderId: number |
| 138 | + marketIndex: number |
| 139 | + orderType: 'limit' | 'ioc' | 'postOnly' | 'market' |
| 140 | + side: 'buy' | 'sell' |
| 141 | + price: number |
| 142 | + size: number |
| 143 | + triggerCondition: 'above' | 'below' |
| 144 | + triggerPrice: number |
| 145 | +} |
0 commit comments