@triadxyz/triad-protocol 0.7.5-beta.devnet → 0.7.6-beta.devnet
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 +7 -1
- package/dist/index.js +9 -11
- package/dist/local-test.js +26 -98
- package/dist/stake.d.ts +4 -4
- package/dist/stake.js +12 -68
- package/dist/trade.d.ts +66 -16
- package/dist/trade.js +101 -47
- package/dist/types/idl_triad_protocol.json +61 -72
- package/dist/types/trade.d.ts +12 -0
- package/dist/types/triad_protocol.d.ts +61 -101
- package/dist/utils/sendTransactionWithOptions.d.ts +3 -0
- package/dist/utils/sendTransactionWithOptions.js +14 -0
- package/dist/utils/sendVersionedTransaction.d.ts +5 -0
- package/dist/utils/sendVersionedTransaction.js +29 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,21 +13,25 @@ export default class TriadProtocolClient {
|
|
|
13
13
|
/**
|
|
14
14
|
* Get User by wallet
|
|
15
15
|
* @param wallet - User wallet
|
|
16
|
+
*
|
|
16
17
|
*/
|
|
17
18
|
getUser(wallet: PublicKey): Promise<import("./types").User>;
|
|
18
19
|
/**
|
|
19
20
|
* Get User by wallet
|
|
20
21
|
* @param wallet - User wallet
|
|
22
|
+
*
|
|
21
23
|
*/
|
|
22
24
|
getUsers(): Promise<import("./types").User[]>;
|
|
23
25
|
/**
|
|
24
26
|
* Check if user exists
|
|
25
27
|
* @param username - User name
|
|
28
|
+
*
|
|
26
29
|
*/
|
|
27
30
|
hasUser(wallet: PublicKey): Promise<boolean>;
|
|
28
31
|
/**
|
|
29
32
|
* Get Refferal
|
|
30
33
|
* @param name - User name
|
|
34
|
+
*
|
|
31
35
|
*/
|
|
32
36
|
getReferral(name: string): Promise<string>;
|
|
33
37
|
/**
|
|
@@ -36,6 +40,8 @@ export default class TriadProtocolClient {
|
|
|
36
40
|
* @param name - user name
|
|
37
41
|
* @param referral - user referral
|
|
38
42
|
*
|
|
43
|
+
* @param options - RPC options
|
|
44
|
+
*
|
|
39
45
|
*/
|
|
40
|
-
createUser({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions): Promise<
|
|
46
|
+
createUser({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions): Promise<any>;
|
|
41
47
|
}
|
package/dist/index.js
CHANGED
|
@@ -13,12 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
17
16
|
const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
|
|
18
17
|
const trade_1 = __importDefault(require("./trade"));
|
|
19
18
|
const helpers_1 = require("./utils/helpers");
|
|
20
19
|
const pda_1 = require("./utils/pda");
|
|
21
20
|
const stake_1 = __importDefault(require("./stake"));
|
|
21
|
+
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
22
22
|
class TriadProtocolClient {
|
|
23
23
|
constructor(connection, wallet) {
|
|
24
24
|
this.provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
|
|
@@ -29,6 +29,7 @@ class TriadProtocolClient {
|
|
|
29
29
|
/**
|
|
30
30
|
* Get User by wallet
|
|
31
31
|
* @param wallet - User wallet
|
|
32
|
+
*
|
|
32
33
|
*/
|
|
33
34
|
getUser(wallet) {
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -39,6 +40,7 @@ class TriadProtocolClient {
|
|
|
39
40
|
/**
|
|
40
41
|
* Get User by wallet
|
|
41
42
|
* @param wallet - User wallet
|
|
43
|
+
*
|
|
42
44
|
*/
|
|
43
45
|
getUsers() {
|
|
44
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -51,6 +53,7 @@ class TriadProtocolClient {
|
|
|
51
53
|
/**
|
|
52
54
|
* Check if user exists
|
|
53
55
|
* @param username - User name
|
|
56
|
+
*
|
|
54
57
|
*/
|
|
55
58
|
hasUser(wallet) {
|
|
56
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -66,6 +69,7 @@ class TriadProtocolClient {
|
|
|
66
69
|
/**
|
|
67
70
|
* Get Refferal
|
|
68
71
|
* @param name - User name
|
|
72
|
+
*
|
|
69
73
|
*/
|
|
70
74
|
getReferral(name) {
|
|
71
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -95,25 +99,19 @@ class TriadProtocolClient {
|
|
|
95
99
|
* @param name - user name
|
|
96
100
|
* @param referral - user referral
|
|
97
101
|
*
|
|
102
|
+
* @param options - RPC options
|
|
103
|
+
*
|
|
98
104
|
*/
|
|
99
105
|
createUser({ wallet, name, referral }, options) {
|
|
100
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
|
|
107
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods
|
|
102
108
|
.createUser({
|
|
103
109
|
name
|
|
104
110
|
})
|
|
105
111
|
.accounts({
|
|
106
112
|
signer: wallet,
|
|
107
113
|
referral
|
|
108
|
-
});
|
|
109
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
110
|
-
method.postInstructions([
|
|
111
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
112
|
-
microLamports: options.microLamports
|
|
113
|
-
})
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
114
|
+
}), options);
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
}
|
package/dist/local-test.js
CHANGED
|
@@ -36,103 +36,13 @@ const markets = [
|
|
|
36
36
|
const ordersHypeAndFloopBot = [
|
|
37
37
|
{
|
|
38
38
|
marketId: 0,
|
|
39
|
-
amount:
|
|
40
|
-
direction: {
|
|
41
|
-
hype: {}
|
|
42
|
-
},
|
|
43
|
-
orderType: {
|
|
44
|
-
market: {}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
marketId: 0,
|
|
49
|
-
amount: 10000,
|
|
50
|
-
direction: {
|
|
51
|
-
flop: {}
|
|
52
|
-
},
|
|
53
|
-
orderType: {
|
|
54
|
-
market: {}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
marketId: 0,
|
|
59
|
-
amount: 429,
|
|
60
|
-
direction: {
|
|
61
|
-
hype: {}
|
|
62
|
-
},
|
|
63
|
-
orderType: {
|
|
64
|
-
limit: {}
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
marketId: 0,
|
|
69
|
-
amount: 249,
|
|
70
|
-
direction: {
|
|
71
|
-
flop: {}
|
|
72
|
-
},
|
|
73
|
-
orderType: {
|
|
74
|
-
limit: {}
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
marketId: 0,
|
|
79
|
-
amount: 369,
|
|
80
|
-
direction: {
|
|
81
|
-
hype: {}
|
|
82
|
-
},
|
|
83
|
-
orderType: {
|
|
84
|
-
market: {}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
marketId: 0,
|
|
89
|
-
amount: 369,
|
|
39
|
+
amount: 100000,
|
|
90
40
|
direction: {
|
|
91
41
|
flop: {}
|
|
92
42
|
},
|
|
93
43
|
orderType: {
|
|
94
44
|
market: {}
|
|
95
45
|
}
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
marketId: 0,
|
|
99
|
-
amount: 369,
|
|
100
|
-
direction: {
|
|
101
|
-
flop: {}
|
|
102
|
-
},
|
|
103
|
-
orderType: {
|
|
104
|
-
market: {}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
marketId: 0,
|
|
109
|
-
amount: 369,
|
|
110
|
-
direction: {
|
|
111
|
-
hype: {}
|
|
112
|
-
},
|
|
113
|
-
orderType: {
|
|
114
|
-
market: {}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
marketId: 0,
|
|
119
|
-
amount: 369,
|
|
120
|
-
direction: {
|
|
121
|
-
hype: {}
|
|
122
|
-
},
|
|
123
|
-
orderType: {
|
|
124
|
-
market: {}
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
marketId: 0,
|
|
129
|
-
amount: 369,
|
|
130
|
-
direction: {
|
|
131
|
-
hype: {}
|
|
132
|
-
},
|
|
133
|
-
orderType: {
|
|
134
|
-
market: {}
|
|
135
|
-
}
|
|
136
46
|
}
|
|
137
47
|
];
|
|
138
48
|
const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -160,10 +70,15 @@ const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
160
70
|
});
|
|
161
71
|
console.log(updateBoostResponse);
|
|
162
72
|
});
|
|
163
|
-
const
|
|
164
|
-
const markets = yield triadProtocol.trade.
|
|
73
|
+
const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
const markets = yield triadProtocol.trade.getAllMarkets();
|
|
165
75
|
console.log(markets);
|
|
166
76
|
});
|
|
77
|
+
const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const market = yield triadProtocol.trade.getMarketById(1);
|
|
79
|
+
console.log(market);
|
|
80
|
+
});
|
|
81
|
+
getMarket();
|
|
167
82
|
const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
83
|
for (const market of markets) {
|
|
169
84
|
try {
|
|
@@ -183,10 +98,10 @@ const getOrders = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
183
98
|
});
|
|
184
99
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
100
|
for (const order of ordersHypeAndFloopBot) {
|
|
186
|
-
const response = yield triadProtocol.trade.openOrder(
|
|
101
|
+
const response = yield triadProtocol.trade.openOrder({
|
|
102
|
+
marketId: 1,
|
|
187
103
|
amount: order.amount,
|
|
188
104
|
direction: order.direction,
|
|
189
|
-
orderType: order.orderType,
|
|
190
105
|
comment: `hype/flop bot ${order.amount} - ${order.direction}`
|
|
191
106
|
}, {
|
|
192
107
|
skipPreflight: true
|
|
@@ -198,13 +113,13 @@ const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
198
113
|
for (const order of yield getOrders()) {
|
|
199
114
|
try {
|
|
200
115
|
const response = yield triadProtocol.trade.closeOrder({
|
|
201
|
-
marketId:
|
|
116
|
+
marketId: 1,
|
|
202
117
|
orderId: order
|
|
203
118
|
});
|
|
204
119
|
console.log(response);
|
|
205
120
|
}
|
|
206
121
|
catch (e) {
|
|
207
|
-
console.log(
|
|
122
|
+
console.log('Error closing order');
|
|
208
123
|
}
|
|
209
124
|
}
|
|
210
125
|
});
|
|
@@ -218,4 +133,17 @@ const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
218
133
|
yield new Promise((resolve) => setTimeout(resolve, 40000));
|
|
219
134
|
}
|
|
220
135
|
});
|
|
221
|
-
|
|
136
|
+
const initializeQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
const currentTime = Math.floor(Date.now() / 1000) + 10; // Current time in seconds
|
|
138
|
+
const response = yield triadProtocol.trade.initializeQuestion({
|
|
139
|
+
marketId: 1,
|
|
140
|
+
question: 'FUCK OFF?',
|
|
141
|
+
startTime: currentTime,
|
|
142
|
+
endTime: currentTime + 24 * 60 * 60
|
|
143
|
+
});
|
|
144
|
+
console.log(response);
|
|
145
|
+
});
|
|
146
|
+
const resolveQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const response = yield triadProtocol.trade.resolveQuestion(0);
|
|
148
|
+
console.log(response);
|
|
149
|
+
});
|
package/dist/stake.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export default class Stake {
|
|
|
50
50
|
* @param amount - Amount to stake
|
|
51
51
|
*
|
|
52
52
|
*/
|
|
53
|
-
stakeToken({ name, wallet, amount }: StakeTokenArgs, options?: RpcOptions): Promise<
|
|
53
|
+
stakeToken({ name, wallet, amount }: StakeTokenArgs, options?: RpcOptions): Promise<any>;
|
|
54
54
|
/**
|
|
55
55
|
* Update Stake Vault
|
|
56
56
|
* @param wallet - User wallet
|
|
@@ -58,14 +58,14 @@ export default class Stake {
|
|
|
58
58
|
* @param status - Status of the stake vault (optional)
|
|
59
59
|
*
|
|
60
60
|
*/
|
|
61
|
-
updateStakeVault({ wallet, amount, status }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<
|
|
61
|
+
updateStakeVault({ wallet, amount, status }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<any>;
|
|
62
62
|
/**
|
|
63
63
|
* Request Withdraw
|
|
64
64
|
* @param wallet - User wallet
|
|
65
65
|
* @param name - Stake name
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
68
|
-
requestWithdraw({ wallet, name, mint }: RequestWithdrawArgs, options?: RpcOptions): Promise<
|
|
68
|
+
requestWithdraw({ wallet, name, mint }: RequestWithdrawArgs, options?: RpcOptions): Promise<any>;
|
|
69
69
|
/**
|
|
70
70
|
* Withdraw Stake
|
|
71
71
|
* @param wallet - User wallet
|
|
@@ -73,7 +73,7 @@ export default class Stake {
|
|
|
73
73
|
* @param mint - NFT mint
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
|
-
withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<
|
|
76
|
+
withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<any>;
|
|
77
77
|
/**
|
|
78
78
|
* Claim Stake Rewards
|
|
79
79
|
* @param wallet - User wallet
|
package/dist/stake.js
CHANGED
|
@@ -20,6 +20,8 @@ const pda_1 = require("./utils/pda");
|
|
|
20
20
|
const constants_1 = require("./utils/constants");
|
|
21
21
|
const base64_js_1 = require("base64-js");
|
|
22
22
|
const getRarityRank_1 = __importDefault(require("./utils/getRarityRank"));
|
|
23
|
+
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
24
|
+
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
23
25
|
class Stake {
|
|
24
26
|
constructor(program, provider) {
|
|
25
27
|
this.stakeVaultName = constants_1.STAKE_VAULT_NAME;
|
|
@@ -134,20 +136,7 @@ class Stake {
|
|
|
134
136
|
})
|
|
135
137
|
.instruction());
|
|
136
138
|
}
|
|
137
|
-
|
|
138
|
-
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
139
|
-
microLamports: options.microLamports
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
143
|
-
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
144
|
-
instructions: ixs,
|
|
145
|
-
recentBlockhash: blockhash,
|
|
146
|
-
payerKey: wallet
|
|
147
|
-
}).compileToV0Message()), [], {
|
|
148
|
-
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
149
|
-
commitment: 'confirmed'
|
|
150
|
-
});
|
|
139
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
151
140
|
});
|
|
152
141
|
}
|
|
153
142
|
/**
|
|
@@ -160,7 +149,7 @@ class Stake {
|
|
|
160
149
|
stakeToken({ name, wallet, amount }, options) {
|
|
161
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
151
|
const userPDA = (0, pda_1.getUserPDA)(this.program.programId, wallet);
|
|
163
|
-
|
|
152
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods
|
|
164
153
|
.stakeToken({
|
|
165
154
|
name,
|
|
166
155
|
amount: new anchor_1.BN(amount * Math.pow(10, 6)),
|
|
@@ -170,15 +159,7 @@ class Stake {
|
|
|
170
159
|
signer: wallet,
|
|
171
160
|
mint: constants_1.TRD_MINT,
|
|
172
161
|
user: userPDA
|
|
173
|
-
});
|
|
174
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
175
|
-
method.postInstructions([
|
|
176
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
177
|
-
microLamports: options.microLamports
|
|
178
|
-
})
|
|
179
|
-
]);
|
|
180
|
-
}
|
|
181
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
162
|
+
}), options);
|
|
182
163
|
});
|
|
183
164
|
}
|
|
184
165
|
/**
|
|
@@ -190,7 +171,7 @@ class Stake {
|
|
|
190
171
|
*/
|
|
191
172
|
updateStakeVault({ wallet, amount, status }, options) {
|
|
192
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
|
|
174
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods
|
|
194
175
|
.updateStakeVault({
|
|
195
176
|
amount,
|
|
196
177
|
status,
|
|
@@ -199,15 +180,7 @@ class Stake {
|
|
|
199
180
|
.accounts({
|
|
200
181
|
signer: wallet,
|
|
201
182
|
mint: constants_1.TRD_MINT
|
|
202
|
-
});
|
|
203
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
204
|
-
method.postInstructions([
|
|
205
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
206
|
-
microLamports: options.microLamports
|
|
207
|
-
})
|
|
208
|
-
]);
|
|
209
|
-
}
|
|
210
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
183
|
+
}), options);
|
|
211
184
|
});
|
|
212
185
|
}
|
|
213
186
|
/**
|
|
@@ -221,21 +194,13 @@ class Stake {
|
|
|
221
194
|
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
222
195
|
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, name);
|
|
223
196
|
const userPDA = (0, pda_1.getUserPDA)(this.program.programId, wallet);
|
|
224
|
-
|
|
197
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods.requestWithdrawStake().accounts({
|
|
225
198
|
signer: wallet,
|
|
226
199
|
mint: mint,
|
|
227
200
|
user: userPDA,
|
|
228
201
|
stake: stakePDA,
|
|
229
202
|
stakeVault: stakeVaultPDA
|
|
230
|
-
});
|
|
231
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
232
|
-
method.postInstructions([
|
|
233
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
234
|
-
microLamports: options.microLamports
|
|
235
|
-
})
|
|
236
|
-
]);
|
|
237
|
-
}
|
|
238
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
203
|
+
}), options);
|
|
239
204
|
});
|
|
240
205
|
}
|
|
241
206
|
/**
|
|
@@ -250,22 +215,14 @@ class Stake {
|
|
|
250
215
|
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
251
216
|
const userPDA = (0, pda_1.getUserPDA)(this.program.programId, wallet);
|
|
252
217
|
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, name);
|
|
253
|
-
|
|
218
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods.withdrawStake().accounts({
|
|
254
219
|
signer: wallet,
|
|
255
220
|
stake: stakePDA,
|
|
256
221
|
stakeVault: stakeVaultPDA,
|
|
257
222
|
admin: constants_1.TRIAD_ADMIN,
|
|
258
223
|
mint: mint,
|
|
259
224
|
user: userPDA
|
|
260
|
-
});
|
|
261
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
262
|
-
method.postInstructions([
|
|
263
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
264
|
-
microLamports: options.microLamports
|
|
265
|
-
})
|
|
266
|
-
]);
|
|
267
|
-
}
|
|
268
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
225
|
+
}), options);
|
|
269
226
|
});
|
|
270
227
|
}
|
|
271
228
|
/**
|
|
@@ -320,20 +277,7 @@ class Stake {
|
|
|
320
277
|
})
|
|
321
278
|
.instruction());
|
|
322
279
|
}
|
|
323
|
-
|
|
324
|
-
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
325
|
-
microLamports: options.microLamports
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
329
|
-
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
330
|
-
instructions: ixs,
|
|
331
|
-
recentBlockhash: blockhash,
|
|
332
|
-
payerKey: wallet
|
|
333
|
-
}).compileToV0Message()), [], {
|
|
334
|
-
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
335
|
-
commitment: 'confirmed'
|
|
336
|
-
});
|
|
280
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
337
281
|
});
|
|
338
282
|
}
|
|
339
283
|
}
|
package/dist/trade.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TriadProtocol } from './types/triad_protocol';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InitializeQuestionArgs, Market, OpenOrderArgs } from './types/trade';
|
|
5
5
|
import { RpcOptions } from './types';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
export default class Trade {
|
|
@@ -12,19 +12,25 @@ export default class Trade {
|
|
|
12
12
|
/**
|
|
13
13
|
* Get all Markets
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
getAllMarkets(): Promise<Market[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Get Market by ID
|
|
18
|
+
* @param marketId - The ID of the market
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
getMarketById(marketId: number): Promise<Market>;
|
|
22
|
+
/**
|
|
23
|
+
* Get Market by Address
|
|
24
|
+
* @param address - The address of the market
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
16
27
|
getMarketByAddress(address: PublicKey): Promise<Market>;
|
|
17
28
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param name - PYTH/TRD JUP/TRD DRIFT/TRD
|
|
29
|
+
* Get User Trade
|
|
30
|
+
* @param user - The user's public key
|
|
21
31
|
*
|
|
22
32
|
*/
|
|
23
|
-
|
|
24
|
-
marketId: number;
|
|
25
|
-
name: string;
|
|
26
|
-
}, options?: RpcOptions): Promise<string>;
|
|
27
|
-
getUserTrade(): Promise<{
|
|
33
|
+
getUserTrade(user: PublicKey): Promise<{
|
|
28
34
|
bump: number;
|
|
29
35
|
authority: PublicKey;
|
|
30
36
|
totalDeposits: BN;
|
|
@@ -77,14 +83,58 @@ export default class Trade {
|
|
|
77
83
|
}[];
|
|
78
84
|
padding: number[];
|
|
79
85
|
}>;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Initialize Market
|
|
88
|
+
* @param market id - new markert id - length + 1
|
|
89
|
+
* @param name - PYTH/TRD JUP/TRD DRIFT/TRD
|
|
90
|
+
*
|
|
91
|
+
* @param options - RPC options
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
initializeMarket({ marketId, name }: {
|
|
95
|
+
marketId: number;
|
|
96
|
+
name: string;
|
|
97
|
+
}, options?: RpcOptions): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
* Open Order
|
|
100
|
+
* @param marketId - The ID of the market
|
|
101
|
+
* @param amount - The amount of the order
|
|
102
|
+
* @param direction - The direction of the order
|
|
103
|
+
* @param comment - The comment of the order
|
|
104
|
+
*
|
|
105
|
+
* @param options - RPC options
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
openOrder({ marketId, amount, direction, comment }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
|
|
109
|
+
/**
|
|
110
|
+
* Close Order
|
|
111
|
+
* @param marketId - The ID of the market
|
|
112
|
+
* @param orderId - The ID of the order
|
|
113
|
+
*
|
|
114
|
+
* @param options - RPC options
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
86
117
|
closeOrder({ marketId, orderId }: {
|
|
87
118
|
marketId: number;
|
|
88
119
|
orderId: number;
|
|
89
120
|
}, options?: RpcOptions): Promise<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Initialize a new question for a market
|
|
123
|
+
* @param marketId - The ID of the market
|
|
124
|
+
* @param question - The question to initialize
|
|
125
|
+
* @param startTime - The start time of the question
|
|
126
|
+
* @param endTime - The end time of the question
|
|
127
|
+
*
|
|
128
|
+
* @param options - RPC options
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
initializeQuestion({ marketId, question, startTime, endTime }: InitializeQuestionArgs, options?: RpcOptions): Promise<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Resolve the current question for a market
|
|
134
|
+
* @param marketId - The ID of the market
|
|
135
|
+
*
|
|
136
|
+
* @param options - RPC options
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
resolveQuestion(marketId: number, options?: RpcOptions): Promise<string>;
|
|
90
140
|
}
|