2022-04-12 07:19:58 -07:00
|
|
|
import { utf8 } from '@project-serum/anchor/dist/cjs/utils/bytes';
|
2022-04-08 08:25:34 -07:00
|
|
|
import { PublicKey } from '@solana/web3.js';
|
2022-04-02 23:57:45 -07:00
|
|
|
|
|
|
|
export class Serum3Market {
|
2022-04-12 07:19:58 -07:00
|
|
|
public name: string;
|
2022-04-02 23:57:45 -07:00
|
|
|
static from(
|
|
|
|
publicKey: PublicKey,
|
|
|
|
obj: {
|
2022-04-12 07:19:58 -07:00
|
|
|
name: number[];
|
2022-04-02 23:57:45 -07:00
|
|
|
group: PublicKey;
|
|
|
|
serumProgram: PublicKey;
|
|
|
|
serumMarketExternal: PublicKey;
|
|
|
|
marketIndex: number;
|
|
|
|
baseTokenIndex: number;
|
|
|
|
quoteTokenIndex: number;
|
|
|
|
bump: number;
|
|
|
|
reserved: unknown;
|
|
|
|
},
|
|
|
|
): Serum3Market {
|
|
|
|
return new Serum3Market(
|
|
|
|
publicKey,
|
2022-04-12 07:19:58 -07:00
|
|
|
obj.name,
|
2022-04-02 23:57:45 -07:00
|
|
|
obj.group,
|
|
|
|
obj.serumProgram,
|
|
|
|
obj.serumMarketExternal,
|
|
|
|
obj.marketIndex,
|
|
|
|
obj.baseTokenIndex,
|
|
|
|
obj.quoteTokenIndex,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
public publicKey: PublicKey,
|
2022-04-12 07:19:58 -07:00
|
|
|
name: number[],
|
2022-04-02 23:57:45 -07:00
|
|
|
public group: PublicKey,
|
|
|
|
public serumProgram: PublicKey,
|
|
|
|
public serumMarketExternal: PublicKey,
|
|
|
|
public marketIndex: number,
|
|
|
|
public baseTokenIndex: number,
|
|
|
|
public quoteTokenIndex: number,
|
2022-04-12 07:19:58 -07:00
|
|
|
) {
|
|
|
|
this.name = utf8.decode(new Uint8Array(name)).split('\x00')[0];
|
|
|
|
}
|
2022-04-02 23:57:45 -07:00
|
|
|
}
|
|
|
|
|
2022-04-03 22:29:22 -07:00
|
|
|
export class Serum3SelfTradeBehavior {
|
|
|
|
static decrementTake = { decrementTake: {} };
|
|
|
|
static cancelProvide = { cancelProvide: {} };
|
|
|
|
static abortTransaction = { abortTransaction: {} };
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Serum3OrderType {
|
|
|
|
static limit = { limit: {} };
|
|
|
|
static immediateOrCancel = { immediateOrCancel: {} };
|
|
|
|
static postOnly = { postOnly: {} };
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Serum3Side {
|
|
|
|
static bid = { bid: {} };
|
|
|
|
static ask = { ask: {} };
|
|
|
|
}
|