@triadxyz/triad-protocol 1.6.8-beta-dev → 1.6.8-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.
@@ -3,7 +3,6 @@ export declare const STAKE_VAULT_NAME = "Triad Share 1";
3
3
  export declare const TRD_DECIMALS = 6;
4
4
  export declare const VERIFIER: PublicKey;
5
5
  export declare const TRD_MINT: PublicKey;
6
- export declare const USDC_MINT_DEVNET: PublicKey;
7
6
  export declare const TRIAD_ADMIN: PublicKey;
8
7
  export declare const SOL_MINT: PublicKey;
9
8
  export declare const TICKET_CORE_COLLECTION: PublicKey;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.WHEEL_MINT = exports.VALENT_SPIN_NAME = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.USDC_MINT_DEVNET = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
3
+ exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.WHEEL_MINT = exports.VALENT_SPIN_NAME = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.STAKE_VAULT_NAME = 'Triad Share 1';
6
6
  exports.TRD_DECIMALS = 6;
7
7
  exports.VERIFIER = new web3_js_1.PublicKey('42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919');
8
8
  exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
9
- exports.USDC_MINT_DEVNET = new web3_js_1.PublicKey('4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU');
10
9
  exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
11
10
  exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
12
11
  exports.TICKET_CORE_COLLECTION = new web3_js_1.PublicKey('BaqopH1VXYUCT6VsojbTibVcd3k5jpGGT6296HFb6fVa');
@@ -1,40 +1,11 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
- import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
2
+ import { Market, Order, UserTrade } from '../types/trade';
3
3
  import { PublicKey } 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;
7
7
  export declare const formatStake: (stake: any) => Stake;
8
8
  export declare const formatMarket: (account: any, address: PublicKey) => Market;
9
- export declare const formatOrder: (order: any, account: PublicKey, authority: PublicKey) => Order;
10
- export declare const formatUserTrade: (account: any, user: PublicKey) => UserTrade;
9
+ export declare const formatOrder: (order: any) => Order;
10
+ export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
11
11
  export declare const calculateStakeRewards: (stake: Stake, multiplier: number) => number;
12
- export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
13
- export declare const getOrderDirection: (direction: {
14
- hype: {};
15
- } | {
16
- flop: {};
17
- }) => OrderDirection;
18
- export declare const getOrderType: (type: {
19
- limit: {};
20
- } | {
21
- market: {};
22
- }) => OrderType;
23
- export declare const getOrderSide: (side: {
24
- bid: {};
25
- } | {
26
- ask: {};
27
- }) => OrderSide;
28
- export declare const getOrderStatus: (status: {
29
- init: {};
30
- } | {
31
- open: {};
32
- } | {
33
- closed: {};
34
- } | {
35
- claimed: {};
36
- } | {
37
- liquidated: {};
38
- } | {
39
- waiting: {};
40
- }) => OrderStatus;
@@ -1,10 +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.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
5
  const constants_1 = require("./constants");
6
- const spl_token_1 = require("@solana/spl-token");
7
- const spl_token_2 = require("@solana/spl-token");
8
6
  const encodeString = (value, alloc = 32) => {
9
7
  const buffer = Buffer.alloc(alloc, 32);
10
8
  buffer.write(value);
@@ -74,45 +72,40 @@ const formatMarket = (account, address) => {
74
72
  marketStart: account.marketStart.toString(),
75
73
  marketEnd: account.marketEnd.toString(),
76
74
  question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
77
- creatorFeeAvailable: account.creatorFeeAvailable.toString(),
78
- creatorFeeClaimed: account.creatorFeeClaimed.toString(),
75
+ nftHoldersFeeAvailable: account.nftHoldersFeeAvailable.toString(),
76
+ nftHoldersFeeClaimed: account.nftHoldersFeeClaimed.toString(),
79
77
  marketFeeAvailable: account.marketFeeAvailable.toString(),
80
78
  marketFeeClaimed: account.marketFeeClaimed.toString(),
81
- customerId: account.customerId ? account.customerId.toString() : null,
82
79
  winningDirection: trade_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
83
- marketLiquidityAtStart: account.marketLiquidityAtStart.toString()
80
+ marketLiquidityAtStart: account.marketLiquidityAtStart.toString() > 0
81
+ ? account.marketLiquidityAtStart.toString()
82
+ : '500000000'
84
83
  };
85
84
  };
86
85
  exports.formatMarket = formatMarket;
87
- const formatOrder = (order, account, authority) => {
86
+ const formatOrder = (order) => {
88
87
  return {
89
88
  ts: order.ts.toString(),
90
89
  orderId: order.orderId.toString(),
91
- filledShares: order.filledShares.toString(),
90
+ questionId: order.questionId.toString(),
92
91
  marketId: order.marketId.toString(),
93
- status: (0, exports.getOrderStatus)(order.status),
92
+ status: order.status,
94
93
  price: order.price.toString(),
95
- amount: order.amount.toString(),
96
- shares: order.shares.toString(),
97
- orderType: (0, exports.getOrderType)(order.orderType),
98
- direction: (0, exports.getOrderDirection)(order.orderDirection),
99
- userNonce: order.userNonce.toString(),
100
- orderSide: (0, exports.getOrderSide)(order.orderSide),
101
- authority: authority.toString(),
102
- account: account.toString(),
103
- poseidon: order.poseidon ? order.poseidon.toString() : null,
104
- linkedOrderId: order.linkedOrderId ? order.linkedOrderId.toString() : null
94
+ totalAmount: order.totalAmount.toString(),
95
+ totalShares: order.totalShares.toString(),
96
+ orderType: order.orderType,
97
+ direction: order.direction,
98
+ userNonce: order.userNonce.toString()
105
99
  };
106
100
  };
107
101
  exports.formatOrder = formatOrder;
108
- const formatUserTrade = (account, user) => {
102
+ const formatUserTrade = (account, publicKey) => {
109
103
  return {
110
- user: user.toString(),
111
- authority: account.authority.toString(),
104
+ user: publicKey.toString(),
112
105
  totalDeposits: account.totalDeposits.toString(),
113
106
  totalWithdraws: account.totalWithdraws.toString(),
114
107
  openedOrders: account.openedOrders.toString(),
115
- orders: account.orders.map((order) => (0, exports.formatOrder)(order, user, account.authority)),
108
+ orders: account.orders.map((order) => (0, exports.formatOrder)(order)),
116
109
  nonce: account.nonce.toString(),
117
110
  isSubUser: account.isSubUser
118
111
  };
@@ -125,7 +118,7 @@ const calculateStakeRewards = (stake, multiplier) => {
125
118
  return 0;
126
119
  const collectionsMultiplier = multiplier * 150;
127
120
  const maxRank = 1633;
128
- const rank = 480;
121
+ const rank = 963;
129
122
  const rankWeight = (maxRank - rank + 1) / maxRank;
130
123
  const userStakedAmount = stake.mint === constants_1.TRD_MINT.toBase58()
131
124
  ? stake.amount
@@ -140,51 +133,3 @@ const calculateStakeRewards = (stake, multiplier) => {
140
133
  return (rewards + stake.available) / Math.pow(10, constants_1.TRD_DECIMALS);
141
134
  };
142
135
  exports.calculateStakeRewards = calculateStakeRewards;
143
- const getTokenProgram = (mint) => {
144
- if (mint.toBase58() === constants_1.TRD_MINT.toBase58()) {
145
- return spl_token_2.TOKEN_2022_PROGRAM_ID;
146
- }
147
- return spl_token_1.TOKEN_PROGRAM_ID;
148
- };
149
- exports.getTokenProgram = getTokenProgram;
150
- const getOrderDirection = (direction) => {
151
- if (Object.keys(direction)[0] === 'hype') {
152
- return trade_1.OrderDirection.HYPE;
153
- }
154
- return trade_1.OrderDirection.FLOP;
155
- };
156
- exports.getOrderDirection = getOrderDirection;
157
- const getOrderType = (type) => {
158
- if (Object.keys(type)[0] === 'limit') {
159
- return trade_1.OrderType.LIMIT;
160
- }
161
- return trade_1.OrderType.MARKET;
162
- };
163
- exports.getOrderType = getOrderType;
164
- const getOrderSide = (side) => {
165
- if (Object.keys(side)[0] === 'bid') {
166
- return trade_1.OrderSide.BID;
167
- }
168
- return trade_1.OrderSide.ASK;
169
- };
170
- exports.getOrderSide = getOrderSide;
171
- const getOrderStatus = (status) => {
172
- let currentStatus = Object.keys(status)[0];
173
- switch (currentStatus) {
174
- case 'init':
175
- return trade_1.OrderStatus.INIT;
176
- case 'open':
177
- return trade_1.OrderStatus.OPEN;
178
- case 'closed':
179
- return trade_1.OrderStatus.CLOSED;
180
- case 'claimed':
181
- return trade_1.OrderStatus.CLAIMED;
182
- case 'liquidated':
183
- return trade_1.OrderStatus.LIQUIDATED;
184
- case 'waiting':
185
- return trade_1.OrderStatus.WAITING;
186
- default:
187
- throw new Error('Invalid order status');
188
- }
189
- };
190
- exports.getOrderStatus = getOrderStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.6.8-beta-dev",
3
+ "version": "1.6.8-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",