@deriverse/kit 1.0.27 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Address, Base64EncodedDataResponse, Rpc, IAccountMeta, IInstruction, Commitment } from "@solana/kit";
2
- import { Instrument, GetClientSpotOrdersInfoResponse, GetClientSpotOrdersArgs, GetClientSpotOrdersResponse, SpotOrderCancelArgs, GetClientDataResponse, GetClientSpotOrdersInfoArgs, SpotLpArgs, getInstrAccountByTagArgs, GetInstrIdArgs, NewSpotOrderArgs, DepositArgs, WithdrawArgs, SpotQuotesReplaceArgs, SpotMassCancelArgs, InstrId, GetClientPerpOrdersInfoArgs, GetClientPerpOrdersInfoResponse, GetClientPerpOrdersArgs, GetClientPerpOrdersResponse, PerpDepositArgs, NewPerpOrderArgs, PerpQuotesReplaceArgs, PerpOrderCancelArgs, PerpMassCancelArgs, PerpForcedCloseArgs, CommunityData, LogMessage, PerpChangeLeverageArgs, PerpStatisticsResetArgs, EngineArgs, NewInstrumentArgs } from './types';
2
+ import { Instrument, GetClientSpotOrdersInfoResponse, GetClientSpotOrdersArgs, GetClientSpotOrdersResponse, SpotOrderCancelArgs, GetClientDataResponse, GetClientSpotOrdersInfoArgs, SpotLpArgs, getInstrAccountByTagArgs, GetInstrIdArgs, NewSpotOrderArgs, DepositArgs, WithdrawArgs, SpotQuotesReplaceArgs, SpotMassCancelArgs, InstrId, GetClientPerpOrdersInfoArgs, GetClientPerpOrdersInfoResponse, GetClientPerpOrdersArgs, GetClientPerpOrdersResponse, PerpDepositArgs, NewPerpOrderArgs, PerpQuotesReplaceArgs, PerpOrderCancelArgs, PerpMassCancelArgs, PerpForcedCloseArgs, CommunityData, LogMessage, PerpChangeLeverageArgs, PerpStatisticsResetArgs, EngineArgs, NewInstrumentArgs, PerpBuySeatArgs } from './types';
3
3
  import { InstrAccountHeaderModel, RootStateModel, TokenStateModel } from "./structure_models";
4
4
  export * from './types';
5
5
  export * from './logs_models';
@@ -180,6 +180,13 @@ export declare class Engine {
180
180
  * @returns Transaction instruction
181
181
  */
182
182
  perpDepositInstruction(args: PerpDepositArgs): Promise<any>;
183
+ /**
184
+ * Build instruction for perp buy seat in particular instrument
185
+ * @param args Order data
186
+ * @returns Transaction instruction
187
+ */
188
+ perpBuySeatInstruction(args: PerpBuySeatArgs): Promise<any>;
189
+ perpSellSeatInstruction(args: PerpBuySeatArgs): Promise<any>;
183
190
  /**
184
191
  * Build instruction for new perp order in particular instrument
185
192
  * @param args Order data
package/dist/index.js CHANGED
@@ -306,6 +306,35 @@ class Engine {
306
306
  }
307
307
  break;
308
308
  }
309
+ case logs_models_1.LogType.buyMarketSeat: {
310
+ if (buffer.length == logs_models_1.BuyMarketSeatReportModel.LENGTH) {
311
+ let report = logs_models_1.BuyMarketSeatReportModel.fromBuffer(buffer);
312
+ if (this.uiNumbers) {
313
+ const instrInfo = this.instruments.get(report.instrId);
314
+ if (instrInfo) {
315
+ crncyTokenDec = this.tokenDec(instrInfo.header.crncyTokenId);
316
+ report.amount /= crncyTokenDec;
317
+ report.seatPrice /= crncyTokenDec;
318
+ }
319
+ }
320
+ logs.push(report);
321
+ }
322
+ break;
323
+ }
324
+ case logs_models_1.LogType.sellMarketSeat: {
325
+ if (buffer.length == logs_models_1.SellMarketSeatReportModel.LENGTH) {
326
+ let report = logs_models_1.SellMarketSeatReportModel.fromBuffer(buffer);
327
+ if (this.uiNumbers) {
328
+ const instrInfo = this.instruments.get(report.instrId);
329
+ if (instrInfo) {
330
+ crncyTokenDec = this.tokenDec(instrInfo.header.crncyTokenId);
331
+ report.seatPrice /= crncyTokenDec;
332
+ }
333
+ }
334
+ logs.push(report);
335
+ }
336
+ break;
337
+ }
309
338
  case logs_models_1.LogType.perpWithdraw: {
310
339
  if (buffer.length == logs_models_1.PerpWithdrawReportModel.LENGTH) {
311
340
  let report = logs_models_1.PerpWithdrawReportModel.fromBuffer(buffer);
@@ -2329,6 +2358,52 @@ class Engine {
2329
2358
  };
2330
2359
  });
2331
2360
  }
2361
+ /**
2362
+ * Build instruction for perp buy seat in particular instrument
2363
+ * @param args Order data
2364
+ * @returns Transaction instruction
2365
+ */
2366
+ perpBuySeatInstruction(args) {
2367
+ return __awaiter(this, void 0, void 0, function* () {
2368
+ if (!(yield this.checkClient())) {
2369
+ throw new Error("Client account not found");
2370
+ }
2371
+ const instr = this.instruments.get(args.instrId);
2372
+ let keys = [
2373
+ { address: this.signer, role: kit_1.AccountRole.READONLY_SIGNER },
2374
+ { address: this.rootAccount, role: kit_1.AccountRole.READONLY },
2375
+ { address: this.clientPrimaryAccount, role: kit_1.AccountRole.WRITABLE },
2376
+ ...yield this.getPerpContext(instr.header),
2377
+ { address: SYSTEM_PROGRAM_ID, role: kit_1.AccountRole.READONLY },
2378
+ ];
2379
+ return {
2380
+ accounts: keys,
2381
+ programAddress: this.programId,
2382
+ data: (0, instruction_models_1.buyMarketSeatData)(47, args.instrId, args.amount * this.tokenDec(instr.header.crncyTokenId)),
2383
+ };
2384
+ });
2385
+ }
2386
+ perpSellSeatInstruction(args) {
2387
+ return __awaiter(this, void 0, void 0, function* () {
2388
+ if (!(yield this.checkClient())) {
2389
+ throw new Error("Client account not found");
2390
+ }
2391
+ const instr = this.instruments.get(args.instrId);
2392
+ let keys = [
2393
+ { address: this.signer, role: kit_1.AccountRole.READONLY_SIGNER },
2394
+ { address: this.rootAccount, role: kit_1.AccountRole.READONLY },
2395
+ { address: this.clientPrimaryAccount, role: kit_1.AccountRole.WRITABLE },
2396
+ ...yield this.getPerpContext(instr.header),
2397
+ { address: yield this.getAccountByTag(types_1.AccountType.COMMUNITY), role: kit_1.AccountRole.READONLY },
2398
+ { address: SYSTEM_PROGRAM_ID, role: kit_1.AccountRole.READONLY },
2399
+ ];
2400
+ return {
2401
+ accounts: keys,
2402
+ programAddress: this.programId,
2403
+ data: (0, instruction_models_1.sellMarketSeatData)(48, args.instrId),
2404
+ };
2405
+ });
2406
+ }
2332
2407
  /**
2333
2408
  * Build instruction for new perp order in particular instrument
2334
2409
  * @param args Order data
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Address, Commitment } from "@solana/kit";
2
2
  import { BaseCrncyRecordModel, ClientCommunityAccountHeaderModel, ClientCommunityRecordModel, CommunityAccountHeaderModel, InstrAccountHeaderModel, LineQuotesModel, OrderModel } from "./structure_models";
3
- import { DepositReportModel, DrvsAirdropReportModel, EarningsReportModel, FeesDepositReportModel, FeesWithdrawReportModel, PerpChangeLeverageReportModel, PerpDepositReportModel, PerpFeesReportModel, PerpFillOrderReportModel, PerpFundingReportModel, PerpMassCancelReportModel, PerpNewOrderReportModel, PerpOrderCancelReportModel, PerpOrderRevokeReportModel, PerpPlaceMassCancelReportModel, PerpPlaceOrderReportModel, PerpSocLossReportModel, PerpWithdrawReportModel, SpotFeesReportModel, SpotFillOrderReportModel, SpotlpTradeReportModel, SpotMassCancelReportModel, SpotNewOrderReportModel, SpotOrderCancelReportModel, SpotOrderRevokeReportModel, SpotPlaceMassCancelReportModel, SpotPlaceOrderReportModel, WithdrawReportModel } from "./logs_models";
3
+ import { BuyMarketSeatReportModel, DepositReportModel, DrvsAirdropReportModel, EarningsReportModel, FeesDepositReportModel, FeesWithdrawReportModel, PerpChangeLeverageReportModel, PerpDepositReportModel, PerpFeesReportModel, PerpFillOrderReportModel, PerpFundingReportModel, PerpMassCancelReportModel, PerpNewOrderReportModel, PerpOrderCancelReportModel, PerpOrderRevokeReportModel, PerpPlaceMassCancelReportModel, PerpPlaceOrderReportModel, PerpSocLossReportModel, PerpWithdrawReportModel, SellMarketSeatReportModel, SpotFeesReportModel, SpotFillOrderReportModel, SpotlpTradeReportModel, SpotMassCancelReportModel, SpotNewOrderReportModel, SpotOrderCancelReportModel, SpotOrderRevokeReportModel, SpotPlaceMassCancelReportModel, SpotPlaceOrderReportModel, WithdrawReportModel } from "./logs_models";
4
4
  export declare enum InstrMask {
5
5
  DRV = 268435456,
6
6
  READY_TO_DRV_UPGRADE = 536870912,
@@ -544,6 +544,13 @@ export interface PerpDepositArgs {
544
544
  instrId: number;
545
545
  amount: number;
546
546
  }
547
+ export interface PerpBuySeatArgs {
548
+ instrId: number;
549
+ amount: number;
550
+ }
551
+ export interface PerpSellSeatArgs {
552
+ instrId: number;
553
+ }
547
554
  export interface NewPerpOrderArgs {
548
555
  instrId: number;
549
556
  ioc?: number;
@@ -559,4 +566,4 @@ export interface NewInstrumentArgs {
559
566
  newProgramAccountAddress?: Address<any>;
560
567
  initialPrice: number;
561
568
  }
562
- export type LogMessage = DepositReportModel | WithdrawReportModel | PerpDepositReportModel | PerpWithdrawReportModel | FeesDepositReportModel | FeesWithdrawReportModel | SpotlpTradeReportModel | EarningsReportModel | DrvsAirdropReportModel | SpotPlaceOrderReportModel | SpotFillOrderReportModel | SpotNewOrderReportModel | SpotOrderCancelReportModel | SpotOrderRevokeReportModel | SpotFeesReportModel | SpotPlaceMassCancelReportModel | SpotMassCancelReportModel | PerpPlaceOrderReportModel | PerpFillOrderReportModel | PerpNewOrderReportModel | PerpOrderCancelReportModel | PerpOrderRevokeReportModel | PerpFeesReportModel | PerpPlaceMassCancelReportModel | PerpMassCancelReportModel | PerpFundingReportModel | PerpSocLossReportModel | PerpChangeLeverageReportModel;
569
+ export type LogMessage = DepositReportModel | WithdrawReportModel | PerpDepositReportModel | PerpWithdrawReportModel | FeesDepositReportModel | FeesWithdrawReportModel | SpotlpTradeReportModel | EarningsReportModel | DrvsAirdropReportModel | SpotPlaceOrderReportModel | SpotFillOrderReportModel | SpotNewOrderReportModel | SpotOrderCancelReportModel | SpotOrderRevokeReportModel | SpotFeesReportModel | SpotPlaceMassCancelReportModel | SpotMassCancelReportModel | PerpPlaceOrderReportModel | PerpFillOrderReportModel | PerpNewOrderReportModel | PerpOrderCancelReportModel | PerpOrderRevokeReportModel | PerpFeesReportModel | PerpPlaceMassCancelReportModel | PerpMassCancelReportModel | PerpFundingReportModel | PerpSocLossReportModel | PerpChangeLeverageReportModel | BuyMarketSeatReportModel | SellMarketSeatReportModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deriverse/kit",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",