@triadxyz/triad-protocol 1.8.2-beta → 1.8.4-beta

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/trade.js CHANGED
@@ -522,11 +522,16 @@ class Trade {
522
522
  const { userTradePDA: buyerTrade, ixs: userTradeIxs } = yield this.getUserTradeIxs();
523
523
  const orderBook = yield this.getOrderBook(marketId);
524
524
  let remainingUSDC = amount * Math.pow(10, this.decimals);
525
- const orders = direction[0].hype ? orderBook.hype.ask : orderBook.flop.ask;
525
+ const orders = Object.keys(direction)[0] === 'hype'
526
+ ? orderBook.hype.ask
527
+ : orderBook.flop.ask;
526
528
  const sortedOrders = orders.sort((a, b) => Number(a.price) - Number(b.price));
527
529
  for (const order of sortedOrders) {
528
530
  if (remainingUSDC <= 0)
529
531
  break;
532
+ if (order.authority === this.provider.publicKey.toBase58()) {
533
+ continue;
534
+ }
530
535
  const orderPrice = Number(order.price);
531
536
  const maxSharesForPrice = remainingUSDC / orderPrice;
532
537
  const availableShares = Number(order.totalShares);
@@ -540,7 +545,8 @@ class Trade {
540
545
  ixs.push(yield this.program.methods
541
546
  .marketBidOrder({
542
547
  amount: new bn_js_1.default(usdcAmount),
543
- orderDirection: direction
548
+ orderDirection: direction,
549
+ askOrderId: new bn_js_1.default(order.orderId)
544
550
  })
545
551
  .accounts({
546
552
  signer: this.provider.publicKey,
@@ -548,7 +554,8 @@ class Trade {
548
554
  buyerTrade,
549
555
  sellerTrade: sellerTradePDA,
550
556
  mint,
551
- tokenProgram: (0, helpers_1.getTokenProgram)(mint)
557
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint),
558
+ sellerAuthority: new web3_js_1.PublicKey(order.authority)
552
559
  })
553
560
  .instruction());
554
561
  remainingUSDC -= usdcAmount;
@@ -856,8 +856,11 @@
856
856
  },
857
857
  {
858
858
  "name": "squads",
859
- "writable": true,
860
- "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
859
+ "writable": true
860
+ },
861
+ {
862
+ "name": "seller_authority",
863
+ "writable": true
861
864
  },
862
865
  {
863
866
  "name": "buyer_trade",
@@ -931,10 +934,6 @@
931
934
  }
932
935
  }
933
936
  },
934
- {
935
- "name": "seller_authority",
936
- "writable": true
937
- },
938
937
  {
939
938
  "name": "seller_to_ata",
940
939
  "writable": true,
@@ -2250,7 +2249,7 @@
2250
2249
  },
2251
2250
  {
2252
2251
  "name": "fee_bps",
2253
- "type": "u8"
2252
+ "type": "u16"
2254
2253
  },
2255
2254
  {
2256
2255
  "name": "payout_fee",
@@ -2348,6 +2347,10 @@
2348
2347
  "name": "amount",
2349
2348
  "type": "u64"
2350
2349
  },
2350
+ {
2351
+ "name": "ask_order_id",
2352
+ "type": "u64"
2353
+ },
2351
2354
  {
2352
2355
  "name": "order_direction",
2353
2356
  "type": {
@@ -2,6 +2,7 @@ import { PublicKey } from '@solana/web3.js';
2
2
  export type RpcOptions = {
3
3
  skipPreflight?: boolean;
4
4
  microLamports?: number;
5
+ computeBudget?: number;
5
6
  };
6
7
  export type MintTicketArgs = {
7
8
  discount: number;
@@ -1182,7 +1182,10 @@ export type TriadProtocol = {
1182
1182
  {
1183
1183
  name: 'squads';
1184
1184
  writable: true;
1185
- address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
1185
+ },
1186
+ {
1187
+ name: 'sellerAuthority';
1188
+ writable: true;
1186
1189
  },
1187
1190
  {
1188
1191
  name: 'buyerTrade';
@@ -1314,10 +1317,6 @@ export type TriadProtocol = {
1314
1317
  };
1315
1318
  };
1316
1319
  },
1317
- {
1318
- name: 'sellerAuthority';
1319
- writable: true;
1320
- },
1321
1320
  {
1322
1321
  name: 'sellerToAta';
1323
1322
  writable: true;
@@ -3010,7 +3009,7 @@ export type TriadProtocol = {
3010
3009
  },
3011
3010
  {
3012
3011
  name: 'feeBps';
3013
- type: 'u8';
3012
+ type: 'u16';
3014
3013
  },
3015
3014
  {
3016
3015
  name: 'payoutFee';
@@ -3108,6 +3107,10 @@ export type TriadProtocol = {
3108
3107
  name: 'amount';
3109
3108
  type: 'u64';
3110
3109
  },
3110
+ {
3111
+ name: 'askOrderId';
3112
+ type: 'u64';
3113
+ },
3111
3114
  {
3112
3115
  name: 'orderDirection';
3113
3116
  type: {
@@ -1,6 +1,6 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
2
  import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
3
- import { PublicKey } from '@solana/web3.js';
3
+ import { PublicKey, AddressLookupTableAccount } from '@solana/web3.js';
4
4
  export declare const encodeString: (value: string, alloc?: number) => number[];
5
5
  export declare const decodeString: (bytes: number[]) => string;
6
6
  export declare const formatStakeVault: (stakeVault: any) => StakeVault;
@@ -38,3 +38,4 @@ export declare const getOrderStatus: (status: {
38
38
  } | {
39
39
  waiting: {};
40
40
  }) => OrderStatus;
41
+ export declare const defaultLookupTable: AddressLookupTableAccount;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.defaultLookupTable = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
+ const web3_js_1 = require("@solana/web3.js");
5
6
  const constants_1 = require("./constants");
6
7
  const spl_token_1 = require("@solana/spl-token");
7
8
  const spl_token_2 = require("@solana/spl-token");
@@ -190,3 +191,19 @@ const getOrderStatus = (status) => {
190
191
  }
191
192
  };
192
193
  exports.getOrderStatus = getOrderStatus;
194
+ exports.defaultLookupTable = {
195
+ isActive: () => true,
196
+ key: new web3_js_1.PublicKey('A2wLWeXEHjmeRvSAyijS9ofv87N1GzFyQfdYPgPoQhZf'),
197
+ state: {
198
+ deactivationSlot: BigInt(18446744073709551615),
199
+ lastExtendedSlot: 328789868,
200
+ lastExtendedSlotStartIndex: 0,
201
+ authority: new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR'),
202
+ addresses: [
203
+ new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV'),
204
+ new web3_js_1.PublicKey('6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq'),
205
+ new web3_js_1.PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'),
206
+ new web3_js_1.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL')
207
+ ]
208
+ }
209
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.8.2-beta",
3
+ "version": "1.8.4-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",