@triadxyz/triad-protocol 2.5.5-beta → 2.5.7-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/index.d.ts +27 -0
- package/dist/index.js +61 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +13 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,33 @@ export default class TriadProtocolClient {
|
|
|
56
56
|
*
|
|
57
57
|
*/
|
|
58
58
|
getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
|
|
59
|
+
/**
|
|
60
|
+
* Get Costumer By Wallet Address
|
|
61
|
+
* @param wallet - The wallet address of the customer
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
getCustomerByWallet(wallet: PublicKey): Promise<import("./types").Customer>;
|
|
65
|
+
/**
|
|
66
|
+
* Get Refer By Wallet Address
|
|
67
|
+
* @param wallet - The wallet address of the refer
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
getReferByWallet(wallet: PublicKey): Promise<import("./types").Refer>;
|
|
71
|
+
/**
|
|
72
|
+
* Get Current Market ID
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
nextMarketId(): Promise<number>;
|
|
76
|
+
/**
|
|
77
|
+
* Get Next Customer ID
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
nextCustomerId(): Promise<number>;
|
|
81
|
+
/**
|
|
82
|
+
* Get Next Pool ID
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
nextPoolId(): Promise<number>;
|
|
59
86
|
/**
|
|
60
87
|
* Get User Trade PDA
|
|
61
88
|
* @param wallet - User wallet PublicKey
|
package/dist/index.js
CHANGED
|
@@ -137,6 +137,67 @@ class TriadProtocolClient {
|
|
|
137
137
|
return (0, helpers_1.formatMarket)(account, marketAddress);
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Get Costumer By Wallet Address
|
|
142
|
+
* @param wallet - The wallet address of the customer
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
getCustomerByWallet(wallet) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const [customer] = yield this.program.account.customer.all([
|
|
148
|
+
{
|
|
149
|
+
memcmp: {
|
|
150
|
+
offset: 10 + 1,
|
|
151
|
+
bytes: wallet.toBase58()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]);
|
|
155
|
+
return (0, helpers_1.formatCustomer)(customer.account, customer.publicKey);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get Refer By Wallet Address
|
|
160
|
+
* @param wallet - The wallet address of the refer
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
getReferByWallet(wallet) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const referPDA = (0, pda_1.getReferPDA)(this.program.programId, wallet);
|
|
166
|
+
const refer = yield this.program.account.refer.fetch(referPDA);
|
|
167
|
+
return (0, helpers_1.formatRefer)(refer);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get Current Market ID
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
nextMarketId() {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
const markets = yield this.program.account.marketV2.all();
|
|
177
|
+
// 10 is the initial market id
|
|
178
|
+
return markets.length + 10;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get Next Customer ID
|
|
183
|
+
*
|
|
184
|
+
*/
|
|
185
|
+
nextCustomerId() {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const customers = yield this.program.account.customer.all();
|
|
188
|
+
return customers.length + 1;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get Next Pool ID
|
|
193
|
+
*
|
|
194
|
+
*/
|
|
195
|
+
nextPoolId() {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const pools = yield this.program.account.pool.all();
|
|
198
|
+
return pools.length + 1;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
140
201
|
/**
|
|
141
202
|
* Get User Trade PDA
|
|
142
203
|
* @param wallet - User wallet PublicKey
|
package/dist/types/index.d.ts
CHANGED
|
@@ -238,3 +238,12 @@ export type Refer = {
|
|
|
238
238
|
feeBps: number;
|
|
239
239
|
feeClaimed: number;
|
|
240
240
|
};
|
|
241
|
+
export type Customer = {
|
|
242
|
+
id: number;
|
|
243
|
+
authority: string;
|
|
244
|
+
name: string;
|
|
245
|
+
feeRecipient: string;
|
|
246
|
+
feeBps: number;
|
|
247
|
+
isVerified: boolean;
|
|
248
|
+
address: string;
|
|
249
|
+
};
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
3
3
|
import { Stake, StakeVault, Unstake } from './../types/stake';
|
|
4
|
-
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer } from '../types';
|
|
4
|
+
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer, Customer } from '../types';
|
|
5
5
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
6
6
|
export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
7
7
|
export declare const decodeString: (bytes: number[]) => string;
|
|
@@ -46,3 +46,4 @@ export declare const getOrderStatus: (status: {
|
|
|
46
46
|
waiting: {};
|
|
47
47
|
}) => OrderStatus;
|
|
48
48
|
export declare const formatRefer: (account: IdlAccounts<TriadProtocol>['refer']) => Refer;
|
|
49
|
+
export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatRefer = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
3
|
+
exports.formatCustomer = exports.formatRefer = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
6
|
const types_1 = require("../types");
|
|
@@ -235,3 +235,15 @@ const formatRefer = (account) => {
|
|
|
235
235
|
};
|
|
236
236
|
};
|
|
237
237
|
exports.formatRefer = formatRefer;
|
|
238
|
+
const formatCustomer = (account, publicKey) => {
|
|
239
|
+
return {
|
|
240
|
+
id: account.id,
|
|
241
|
+
authority: publicKey.toString(),
|
|
242
|
+
name: account.name,
|
|
243
|
+
feeRecipient: account.feeRecipient.toString(),
|
|
244
|
+
feeBps: account.feeBps,
|
|
245
|
+
isVerified: account.isVerified,
|
|
246
|
+
address: publicKey.toString()
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
exports.formatCustomer = formatCustomer;
|