mango-ui-v3/@types/types.tsx

125 lines
2.8 KiB
TypeScript
Raw Normal View History

2021-06-23 07:36:51 -07:00
import { AccountInfo, PublicKey, Transaction } from '@solana/web3.js'
2021-04-02 11:26:21 -07:00
import { Market, OpenOrders } from '@project-serum/serum'
import { Event } from '@project-serum/serum/lib/queue'
2021-07-05 08:03:57 -07:00
import { I80F48 } from '@blockworks-foundation/mango-client/lib/src/fixednum'
export interface MarketInfo {
2021-04-02 11:26:21 -07:00
address: PublicKey
name: string
programId: PublicKey
deprecated: boolean
quoteLabel?: string
baseLabel?: string
}
export interface CustomMarketInfo {
2021-04-02 11:26:21 -07:00
address: string
name: string
programId: string
quoteLabel?: string
baseLabel?: string
}
export interface TokenAccount {
2021-04-02 11:26:21 -07:00
pubkey: PublicKey
account: AccountInfo<Buffer> | null
effectiveMint: PublicKey
}
export interface Trade extends Event {
2021-04-02 11:26:21 -07:00
side: string
price: number
feeCost: number
size: number
}
interface BalancesBase {
2021-04-02 11:26:21 -07:00
key: string
2021-07-05 08:03:57 -07:00
symbol: string
2021-04-02 11:26:21 -07:00
wallet?: number | null | undefined
orders?: number | null | undefined
openOrders?: OpenOrders | null | undefined
unsettled?: number | null | undefined
}
export interface Balances extends BalancesBase {
2021-04-02 11:26:21 -07:00
market?: Market | null | undefined
2021-08-18 13:43:51 -07:00
deposits?: I80F48 | null | undefined
2021-07-05 08:03:57 -07:00
borrows?: I80F48 | null | undefined
net?: I80F48 | null | undefined
2021-09-03 05:11:21 -07:00
value?: I80F48 | null | undefined
2021-09-06 04:51:18 -07:00
depositRate?: I80F48 | null | undefined
borrowRate?: I80F48 | null | undefined
}
export interface OpenOrdersBalances extends BalancesBase {
2021-04-02 11:26:21 -07:00
market?: string | null | undefined
baseCurrencyAccount:
| { pubkey: PublicKey; account: AccountInfo<Buffer> }
| null
| undefined
quoteCurrencyAccount:
| { pubkey: PublicKey; account: AccountInfo<Buffer> }
| null
| undefined
}
export interface EndpointInfo {
2021-04-02 11:26:21 -07:00
name: string
url: string
websocket: string
2021-04-02 11:26:21 -07:00
custom: boolean
}
/**
* {tokenMint: preferred token account's base58 encoded public key}
*/
export interface SelectedTokenAccounts {
2021-04-02 11:26:21 -07:00
[tokenMint: string]: string
}
2021-04-05 13:48:24 -07:00
export interface ChartTradeType {
2021-04-02 11:26:21 -07:00
market: string
size: number
price: number
orderId: string
time: number
side: string
feeCost: number
marketAddress: string
}
export interface FeeRates {
2021-04-02 11:26:21 -07:00
taker: number
maker: number
}
// Type declaration for the margin accounts for the mango group
2021-04-02 11:26:21 -07:00
export type mangoTokenAccounts = {
mango_group: string
accounts: TokenAccount[]
}
// Token infos
export interface KnownToken {
2021-04-02 11:26:21 -07:00
tokenSymbol: string
tokenName: string
icon?: string
mintAddress: string
}
2021-04-13 22:23:50 -07:00
export const DEFAULT_PUBLIC_KEY = new PublicKey(
'11111111111111111111111111111111'
)
export interface WalletAdapter {
publicKey: PublicKey
autoApprove: boolean
connected: boolean
signTransaction: (transaction: Transaction) => Promise<Transaction>
signAllTransactions: (transaction: Transaction[]) => Promise<Transaction[]>
connect: () => any
disconnect: () => any
2021-04-14 11:40:28 -07:00
on(event: string, fn: () => void): this
2021-04-13 22:23:50 -07:00
}