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

143 lines
3.2 KiB
TypeScript
Raw Permalink Normal View History

2022-03-23 05:18:34 -07:00
import { AccountInfo, PublicKey } 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'
2022-02-09 08:28:57 -08:00
import { I80F48 } from '@blockworks-foundation/mango-client'
export interface Token {
chainId: number // 101,
address: string // 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
symbol: string // 'USDC',
name: string // 'Wrapped USDC',
decimals: number // 6,
logoURI: string // 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW/logo.png',
tags: string[] // [ 'stablecoin' ]
}
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 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
2022-02-19 17:32:45 -08:00
decimals?: number | 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 PerpTriggerOrder {
orderId: number
marketIndex: number
orderType: 'limit' | 'ioc' | 'postOnly' | 'market'
side: 'buy' | 'sell'
price: number
size: number
triggerCondition: 'above' | 'below'
triggerPrice: number
}
export type StringPublicKey = string
export interface PromiseFulfilledResult<T> {
status: 'fulfilled'
value: T
}
export interface PromiseRejectedResult {
status: 'rejected'
reason: any
}
export type PromiseSettledResult<T> =
| PromiseFulfilledResult<T>
| PromiseRejectedResult