@triadxyz/triad-protocol 3.1.6-beta → 3.1.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.
- package/dist/claim.d.ts +15 -6
- package/dist/claim.js +34 -8
- package/dist/index.d.ts +17 -151
- package/dist/index.js +78 -419
- package/dist/market.d.ts +129 -0
- package/dist/market.js +377 -0
- package/dist/poseidon.d.ts +6 -5
- package/dist/stake.d.ts +7 -6
- package/dist/types/idl_triad_protocol.json +218 -0
- package/dist/types/index.d.ts +22 -12
- package/dist/types/triad_protocol.d.ts +276 -0
- package/dist/utils/helpers.js +3 -1
- package/dist/utils/sendVersionedTransaction.d.ts +2 -2
- package/dist/utils/sendVersionedTransaction.js +8 -0
- package/package.json +1 -1
package/dist/market.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
2
|
+
import { Program } from '@coral-xyz/anchor';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
+
import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs } from './types';
|
|
6
|
+
export default class Market {
|
|
7
|
+
private program;
|
|
8
|
+
private rpcOptions;
|
|
9
|
+
constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Get All Pools
|
|
12
|
+
*/
|
|
13
|
+
getAllPools(): Promise<import("./types").Pool[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get All Markets
|
|
16
|
+
*/
|
|
17
|
+
getAllMarkets(): Promise<import("./types").Market[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get Pool By ID
|
|
20
|
+
* @param poolId - The ID of the pool
|
|
21
|
+
*/
|
|
22
|
+
getPoolById(poolId: number): Promise<import("./types").Pool>;
|
|
23
|
+
/**
|
|
24
|
+
* Get Market By ID
|
|
25
|
+
* @param marketId - The ID of the market
|
|
26
|
+
*/
|
|
27
|
+
getMarketById(marketId: number): Promise<import("./types").Market>;
|
|
28
|
+
/**
|
|
29
|
+
* Get Market By Address
|
|
30
|
+
* @param marketAddress - The address of the market
|
|
31
|
+
*/
|
|
32
|
+
getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
|
|
33
|
+
/**
|
|
34
|
+
* Get Current Market ID
|
|
35
|
+
*/
|
|
36
|
+
nextMarketId(): Promise<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Get Next Customer ID
|
|
39
|
+
*/
|
|
40
|
+
nextCustomerId(): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Get Next Pool ID
|
|
43
|
+
*/
|
|
44
|
+
nextPoolId(): Promise<number>;
|
|
45
|
+
/**
|
|
46
|
+
* Create Market
|
|
47
|
+
* @param args.markets - Array of markets to create
|
|
48
|
+
* @param args.markets.marketId - Market ID
|
|
49
|
+
* @param args.markets.startTime - start time
|
|
50
|
+
* @param args.markets.endTime - end time
|
|
51
|
+
* @param args.markets.question - question (max 80 characters)
|
|
52
|
+
* @param args.markets.liquidityAtStart - liquidity at start
|
|
53
|
+
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
54
|
+
* @param args.customer - The customer of the market
|
|
55
|
+
* @param args.poolId - The ID of the pool
|
|
56
|
+
*/
|
|
57
|
+
createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
58
|
+
/**
|
|
59
|
+
* Create Pool
|
|
60
|
+
* @param poolId - The ID of the pool
|
|
61
|
+
* @param question - The question of the pool
|
|
62
|
+
* @param markets - The markets of the pool
|
|
63
|
+
*/
|
|
64
|
+
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
65
|
+
/**
|
|
66
|
+
* Resolve Market
|
|
67
|
+
* @param args.marketId - The ID of the Market
|
|
68
|
+
* @param args.poolId - The ID of the Pool
|
|
69
|
+
* @param args.winningDirection - The Winning Direction of the Market
|
|
70
|
+
*/
|
|
71
|
+
updateMarketWinningDirection({ marketId, poolId, winningDirection }: UpdateMarketWinningDirectionArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
72
|
+
/**
|
|
73
|
+
* Update Market Payout
|
|
74
|
+
* @param marketId - The ID of the market
|
|
75
|
+
* @param poolId - The ID of the pool
|
|
76
|
+
* @param allowPayout - Whether to allow the market to payout
|
|
77
|
+
*/
|
|
78
|
+
updateMarketPayout({ marketId, poolId, allowPayout }: {
|
|
79
|
+
marketId: number;
|
|
80
|
+
poolId?: number;
|
|
81
|
+
allowPayout: boolean;
|
|
82
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
83
|
+
/**
|
|
84
|
+
* Update Market End
|
|
85
|
+
* @param marketId - The ID of the market
|
|
86
|
+
* @param marketEnd - The end time of the market
|
|
87
|
+
*/
|
|
88
|
+
updateMarketEnd({ marketId, marketEnd }: {
|
|
89
|
+
marketId: number;
|
|
90
|
+
marketEnd: number;
|
|
91
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
92
|
+
/**
|
|
93
|
+
* Update Market Question
|
|
94
|
+
* @param marketId - The ID of the market
|
|
95
|
+
* @param question - The question of the market
|
|
96
|
+
*/
|
|
97
|
+
updateMarketQuestion({ marketId, question }: {
|
|
98
|
+
marketId: number;
|
|
99
|
+
question: string;
|
|
100
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
101
|
+
/**
|
|
102
|
+
* Collect Market Fee
|
|
103
|
+
* @param args.markets - The markets to collect the fee from
|
|
104
|
+
* @param args.markets.marketAddress - The address of the market
|
|
105
|
+
* @param args.markets.customerId - The ID of the customer
|
|
106
|
+
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
107
|
+
*/
|
|
108
|
+
collectMarketFee(markets: {
|
|
109
|
+
marketAddress: PublicKey;
|
|
110
|
+
customerId: number;
|
|
111
|
+
customerFeeRecipient: PublicKey;
|
|
112
|
+
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
113
|
+
/**
|
|
114
|
+
* Collect Market Order Fee
|
|
115
|
+
* @param marketAddress - The address of the market
|
|
116
|
+
*/
|
|
117
|
+
collectMarketOrderFee(marketAddress: PublicKey[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
118
|
+
/**
|
|
119
|
+
* Close Order Book
|
|
120
|
+
* @param marketIds - Market IDs
|
|
121
|
+
*/
|
|
122
|
+
closeOrderBook(marketIds: number[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
123
|
+
/**
|
|
124
|
+
* Update Pool Question
|
|
125
|
+
* @param poolId - Pool ID
|
|
126
|
+
* @param question - Question
|
|
127
|
+
*/
|
|
128
|
+
updatePoolQuestion(poolId: number, question: string): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
129
|
+
}
|
package/dist/market.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
17
|
+
const helpers_1 = require("./utils/helpers");
|
|
18
|
+
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
19
|
+
const pda_1 = require("./utils/pda");
|
|
20
|
+
class Market {
|
|
21
|
+
constructor(program, rpcOptions) {
|
|
22
|
+
this.program = program;
|
|
23
|
+
this.rpcOptions = rpcOptions;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get All Pools
|
|
27
|
+
*/
|
|
28
|
+
getAllPools() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const pool = yield this.program.account.pool.all();
|
|
31
|
+
return pool.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get All Markets
|
|
36
|
+
*/
|
|
37
|
+
getAllMarkets() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const marketV2 = yield this.program.account.marketV2.all();
|
|
40
|
+
return marketV2.map(({ account, publicKey }) => (0, helpers_1.formatMarket)(account, publicKey));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get Pool By ID
|
|
45
|
+
* @param poolId - The ID of the pool
|
|
46
|
+
*/
|
|
47
|
+
getPoolById(poolId) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
50
|
+
const response = yield this.program.account.pool.fetch(poolPDA);
|
|
51
|
+
return (0, helpers_1.formatPool)(response, poolPDA);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get Market By ID
|
|
56
|
+
* @param marketId - The ID of the market
|
|
57
|
+
*/
|
|
58
|
+
getMarketById(marketId) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
61
|
+
const response = yield this.program.account.marketV2.fetch(marketPDA);
|
|
62
|
+
return (0, helpers_1.formatMarket)(response, marketPDA);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get Market By Address
|
|
67
|
+
* @param marketAddress - The address of the market
|
|
68
|
+
*/
|
|
69
|
+
getMarketByAddress(marketAddress) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const account = yield this.program.account.marketV2.fetch(marketAddress);
|
|
72
|
+
return (0, helpers_1.formatMarket)(account, marketAddress);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get Current Market ID
|
|
77
|
+
*/
|
|
78
|
+
nextMarketId() {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const markets = yield this.program.account.marketV2.all();
|
|
81
|
+
return markets.length + 10;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get Next Customer ID
|
|
86
|
+
*/
|
|
87
|
+
nextCustomerId() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const customers = yield this.program.account.customer.all();
|
|
90
|
+
return customers.length + 1;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get Next Pool ID
|
|
95
|
+
*/
|
|
96
|
+
nextPoolId() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const pools = yield this.program.account.pool.all();
|
|
99
|
+
return pools.length + 1;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create Market
|
|
104
|
+
* @param args.markets - Array of markets to create
|
|
105
|
+
* @param args.markets.marketId - Market ID
|
|
106
|
+
* @param args.markets.startTime - start time
|
|
107
|
+
* @param args.markets.endTime - end time
|
|
108
|
+
* @param args.markets.question - question (max 80 characters)
|
|
109
|
+
* @param args.markets.liquidityAtStart - liquidity at start
|
|
110
|
+
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
111
|
+
* @param args.customer - The customer of the market
|
|
112
|
+
* @param args.poolId - The ID of the pool
|
|
113
|
+
*/
|
|
114
|
+
createMarket({ markets, customer, poolId }) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const ixs = [];
|
|
117
|
+
let poolPDA = null;
|
|
118
|
+
if (poolId) {
|
|
119
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
120
|
+
}
|
|
121
|
+
for (const market of markets) {
|
|
122
|
+
if (market.question.length > 80) {
|
|
123
|
+
throw new Error('Question must be less than 80 characters');
|
|
124
|
+
}
|
|
125
|
+
ixs.push(yield this.program.methods
|
|
126
|
+
.createMarket({
|
|
127
|
+
marketId: new anchor_1.BN(market.marketId),
|
|
128
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
129
|
+
marketStart: new anchor_1.BN(market.startTime),
|
|
130
|
+
marketEnd: new anchor_1.BN(market.endTime),
|
|
131
|
+
feeBps: market.feeBps,
|
|
132
|
+
payoutFee: market.payoutFee
|
|
133
|
+
})
|
|
134
|
+
.accounts({
|
|
135
|
+
signer: this.program.provider.publicKey,
|
|
136
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
137
|
+
pool: poolPDA,
|
|
138
|
+
customer
|
|
139
|
+
})
|
|
140
|
+
.instruction());
|
|
141
|
+
ixs.push(yield this.program.methods
|
|
142
|
+
.createOrderBook(new anchor_1.BN(market.marketId))
|
|
143
|
+
.accounts({
|
|
144
|
+
signer: this.program.provider.publicKey,
|
|
145
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
146
|
+
})
|
|
147
|
+
.instruction());
|
|
148
|
+
}
|
|
149
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create Pool
|
|
154
|
+
* @param poolId - The ID of the pool
|
|
155
|
+
* @param question - The question of the pool
|
|
156
|
+
* @param markets - The markets of the pool
|
|
157
|
+
*/
|
|
158
|
+
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
if (question.length > 80) {
|
|
161
|
+
throw new Error('Pool question must be less than 80 characters');
|
|
162
|
+
}
|
|
163
|
+
const ixs = [];
|
|
164
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
165
|
+
ixs.push(yield this.program.methods
|
|
166
|
+
.createPool({
|
|
167
|
+
poolId: new anchor_1.BN(poolId),
|
|
168
|
+
question: (0, helpers_1.encodeString)(question, 80),
|
|
169
|
+
isFast
|
|
170
|
+
})
|
|
171
|
+
.accounts({
|
|
172
|
+
signer: this.program.provider.publicKey,
|
|
173
|
+
customer
|
|
174
|
+
})
|
|
175
|
+
.instruction());
|
|
176
|
+
for (const market of markets) {
|
|
177
|
+
if (market.question.length > 80) {
|
|
178
|
+
throw new Error('Market question must be less than 80 characters');
|
|
179
|
+
}
|
|
180
|
+
ixs.push(yield this.program.methods
|
|
181
|
+
.createMarket({
|
|
182
|
+
marketId: new anchor_1.BN(market.marketId),
|
|
183
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
184
|
+
marketStart: new anchor_1.BN(startTime),
|
|
185
|
+
marketEnd: new anchor_1.BN(endTime),
|
|
186
|
+
feeBps,
|
|
187
|
+
payoutFee
|
|
188
|
+
})
|
|
189
|
+
.accounts({
|
|
190
|
+
signer: this.program.provider.publicKey,
|
|
191
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
192
|
+
pool: poolPDA,
|
|
193
|
+
customer
|
|
194
|
+
})
|
|
195
|
+
.instruction());
|
|
196
|
+
ixs.push(yield this.program.methods
|
|
197
|
+
.createOrderBook(new anchor_1.BN(market.marketId))
|
|
198
|
+
.accounts({
|
|
199
|
+
signer: this.program.provider.publicKey,
|
|
200
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
201
|
+
})
|
|
202
|
+
.instruction());
|
|
203
|
+
}
|
|
204
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Resolve Market
|
|
209
|
+
* @param args.marketId - The ID of the Market
|
|
210
|
+
* @param args.poolId - The ID of the Pool
|
|
211
|
+
* @param args.winningDirection - The Winning Direction of the Market
|
|
212
|
+
*/
|
|
213
|
+
updateMarketWinningDirection({ marketId, poolId, winningDirection }) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
let poolPDA = null;
|
|
216
|
+
if (poolId) {
|
|
217
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
218
|
+
}
|
|
219
|
+
const ixs = [
|
|
220
|
+
yield this.program.methods
|
|
221
|
+
.updateMarketWinningDirection(winningDirection)
|
|
222
|
+
.accounts({
|
|
223
|
+
signer: this.program.provider.publicKey,
|
|
224
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
225
|
+
pool: poolPDA
|
|
226
|
+
})
|
|
227
|
+
.instruction()
|
|
228
|
+
];
|
|
229
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Update Market Payout
|
|
234
|
+
* @param marketId - The ID of the market
|
|
235
|
+
* @param poolId - The ID of the pool
|
|
236
|
+
* @param allowPayout - Whether to allow the market to payout
|
|
237
|
+
*/
|
|
238
|
+
updateMarketPayout({ marketId, poolId, allowPayout }) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
let poolPDA = null;
|
|
241
|
+
if (poolId) {
|
|
242
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
243
|
+
}
|
|
244
|
+
const ixs = [
|
|
245
|
+
yield this.program.methods
|
|
246
|
+
.updateMarketPayout(allowPayout)
|
|
247
|
+
.accounts({
|
|
248
|
+
signer: this.program.provider.publicKey,
|
|
249
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
250
|
+
})
|
|
251
|
+
.instruction()
|
|
252
|
+
];
|
|
253
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Update Market End
|
|
258
|
+
* @param marketId - The ID of the market
|
|
259
|
+
* @param marketEnd - The end time of the market
|
|
260
|
+
*/
|
|
261
|
+
updateMarketEnd({ marketId, marketEnd }) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
const ixs = [
|
|
264
|
+
yield this.program.methods
|
|
265
|
+
.updateMarketEnd(new anchor_1.BN(marketEnd))
|
|
266
|
+
.accounts({
|
|
267
|
+
signer: this.program.provider.publicKey,
|
|
268
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
269
|
+
})
|
|
270
|
+
.instruction()
|
|
271
|
+
];
|
|
272
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Update Market Question
|
|
277
|
+
* @param marketId - The ID of the market
|
|
278
|
+
* @param question - The question of the market
|
|
279
|
+
*/
|
|
280
|
+
updateMarketQuestion({ marketId, question }) {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
const ixs = [
|
|
283
|
+
yield this.program.methods
|
|
284
|
+
.updateMarketQuestion((0, helpers_1.encodeString)(question, 80))
|
|
285
|
+
.accounts({
|
|
286
|
+
signer: this.program.provider.publicKey,
|
|
287
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
288
|
+
})
|
|
289
|
+
.instruction()
|
|
290
|
+
];
|
|
291
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Collect Market Fee
|
|
296
|
+
* @param args.markets - The markets to collect the fee from
|
|
297
|
+
* @param args.markets.marketAddress - The address of the market
|
|
298
|
+
* @param args.markets.customerId - The ID of the customer
|
|
299
|
+
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
300
|
+
*/
|
|
301
|
+
collectMarketFee(markets) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
const ixs = [];
|
|
304
|
+
for (const market of markets) {
|
|
305
|
+
ixs.push(yield this.program.methods
|
|
306
|
+
.collectMarketFee()
|
|
307
|
+
.accounts({
|
|
308
|
+
signer: this.program.provider.publicKey,
|
|
309
|
+
market: market.marketAddress,
|
|
310
|
+
customer: (0, pda_1.getCustomerPDA)(this.program.programId, market.customerId),
|
|
311
|
+
customerFeeRecipient: market.customerFeeRecipient
|
|
312
|
+
})
|
|
313
|
+
.instruction());
|
|
314
|
+
}
|
|
315
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Collect Market Order Fee
|
|
320
|
+
* @param marketAddress - The address of the market
|
|
321
|
+
*/
|
|
322
|
+
collectMarketOrderFee(marketAddress) {
|
|
323
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
324
|
+
const ixs = [];
|
|
325
|
+
for (const market of marketAddress) {
|
|
326
|
+
ixs.push(yield this.program.methods
|
|
327
|
+
.collectMarketOrderFee()
|
|
328
|
+
.accounts({
|
|
329
|
+
signer: this.program.provider.publicKey,
|
|
330
|
+
market: market
|
|
331
|
+
})
|
|
332
|
+
.instruction());
|
|
333
|
+
}
|
|
334
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Close Order Book
|
|
339
|
+
* @param marketIds - Market IDs
|
|
340
|
+
*/
|
|
341
|
+
closeOrderBook(marketIds) {
|
|
342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
const ixs = [];
|
|
344
|
+
for (const marketId of marketIds) {
|
|
345
|
+
ixs.push(yield this.program.methods
|
|
346
|
+
.closeOrderBook()
|
|
347
|
+
.accounts({
|
|
348
|
+
signer: this.program.provider.publicKey,
|
|
349
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
350
|
+
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId)
|
|
351
|
+
})
|
|
352
|
+
.instruction());
|
|
353
|
+
}
|
|
354
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Update Pool Question
|
|
359
|
+
* @param poolId - Pool ID
|
|
360
|
+
* @param question - Question
|
|
361
|
+
*/
|
|
362
|
+
updatePoolQuestion(poolId, question) {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
+
const ixs = [
|
|
365
|
+
yield this.program.methods
|
|
366
|
+
.updatePoolQuestion((0, helpers_1.encodeString)(question, 80))
|
|
367
|
+
.accounts({
|
|
368
|
+
signer: this.program.provider.publicKey,
|
|
369
|
+
pool: (0, pda_1.getPoolPDA)(this.program.programId, poolId)
|
|
370
|
+
})
|
|
371
|
+
.instruction()
|
|
372
|
+
];
|
|
373
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
exports.default = Market;
|
package/dist/poseidon.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
1
2
|
import { Program } from '@coral-xyz/anchor';
|
|
2
3
|
import { PublicKey } from '@solana/web3.js';
|
|
3
4
|
import { TriadProtocol } from './types/triad_protocol';
|
|
@@ -16,28 +17,28 @@ export default class Poseidon {
|
|
|
16
17
|
poseidonAsset: PublicKey;
|
|
17
18
|
ticketAsset: PublicKey;
|
|
18
19
|
ticketNumber: number;
|
|
19
|
-
}[]): Promise<string>;
|
|
20
|
+
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
20
21
|
/**
|
|
21
22
|
* Withdraw Poseidon
|
|
22
23
|
* @param poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
23
24
|
* @param nft - NFT Poseidon Number
|
|
24
25
|
*/
|
|
25
|
-
withdrawPoseidon(poseidonAsset: PublicKey, nft: number): Promise<string>;
|
|
26
|
+
withdrawPoseidon(poseidonAsset: PublicKey, nft: number): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
26
27
|
/**
|
|
27
28
|
* Collect Royalty
|
|
28
29
|
* @param collectionSymbol - Collection Symbol
|
|
29
30
|
*/
|
|
30
|
-
collectRoyalty(collectionSymbol: string): Promise<string>;
|
|
31
|
+
collectRoyalty(collectionSymbol: string): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
31
32
|
/**
|
|
32
33
|
* Add Trader Poseidon
|
|
33
34
|
* @param user - User Public Key
|
|
34
35
|
* @param poseidonAsset - Poseidon Asset
|
|
35
36
|
*/
|
|
36
|
-
addTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string>;
|
|
37
|
+
addTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
37
38
|
/**
|
|
38
39
|
* Remove Trader Poseidon
|
|
39
40
|
* @param user - User Public Key
|
|
40
41
|
* @param poseidonAsset - Poseidon Asset
|
|
41
42
|
*/
|
|
42
|
-
removeTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string>;
|
|
43
|
+
removeTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
43
44
|
}
|
package/dist/stake.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
1
2
|
import { Program } from '@coral-xyz/anchor';
|
|
2
3
|
import { PublicKey } from '@solana/web3.js';
|
|
3
4
|
import { TriadProtocol } from './types/triad_protocol';
|
|
@@ -38,29 +39,29 @@ export default class Stake {
|
|
|
38
39
|
* Stake Token
|
|
39
40
|
* @param amount - Amount to stake
|
|
40
41
|
*/
|
|
41
|
-
stakeToken(amount: number): Promise<string>;
|
|
42
|
+
stakeToken(amount: number): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
42
43
|
/**
|
|
43
44
|
* Update Stake Vault
|
|
44
45
|
* @param amount - Reward amount to deposit
|
|
45
46
|
*/
|
|
46
|
-
addStakeVaultRewards(amount: number): Promise<string>;
|
|
47
|
+
addStakeVaultRewards(amount: number): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
47
48
|
/**
|
|
48
49
|
* Update Stake Vault Is Locked
|
|
49
50
|
* @param isLocked - Whether the stake vault is locked
|
|
50
51
|
*/
|
|
51
|
-
updateStakeVaultIsLocked(isLocked: boolean): Promise<string>;
|
|
52
|
+
updateStakeVaultIsLocked(isLocked: boolean): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
52
53
|
/**
|
|
53
54
|
* Request Unstake
|
|
54
55
|
* @param amount - Amount to unstake
|
|
55
56
|
*/
|
|
56
|
-
requestUnstake(amount: number): Promise<string>;
|
|
57
|
+
requestUnstake(amount: number): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
57
58
|
/**
|
|
58
59
|
* Unstake Token
|
|
59
60
|
* @param unstakePDA - Unstake Public Key
|
|
60
61
|
*/
|
|
61
|
-
unstakeToken(unstakePDA: PublicKey): Promise<string>;
|
|
62
|
+
unstakeToken(unstakePDA: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
62
63
|
/**
|
|
63
64
|
* Claim Stake Rewards
|
|
64
65
|
*/
|
|
65
|
-
claimStakeRewards(): Promise<string>;
|
|
66
|
+
claimStakeRewards(): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
66
67
|
}
|