@triadxyz/triad-protocol 3.1.1-beta → 3.1.3-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 +47 -0
- package/dist/claim.js +143 -0
- package/dist/index.d.ts +78 -151
- package/dist/index.js +151 -260
- package/dist/poseidon.d.ts +19 -25
- package/dist/poseidon.js +69 -75
- package/dist/stake.d.ts +27 -36
- package/dist/stake.js +86 -86
- package/dist/types/idl_triad_protocol.json +982 -360
- package/dist/types/index.d.ts +137 -54
- package/dist/types/triad_protocol.d.ts +1356 -596
- package/dist/utils/constants.d.ts +2 -3
- package/dist/utils/constants.js +3 -4
- package/dist/utils/helpers.d.ts +11 -34
- package/dist/utils/helpers.js +63 -34
- package/dist/utils/{pda/index.d.ts → pda.d.ts} +6 -0
- package/dist/utils/{pda/index.js → pda.js} +25 -1
- package/dist/utils/sendVersionedTransaction.js +1 -1
- package/dist/utils/swap.js +3 -3
- package/package.json +2 -1
- package/dist/types/poseidon.d.ts +0 -18
- package/dist/types/poseidon.js +0 -2
- package/dist/types/stake.d.ts +0 -35
- package/dist/types/stake.js +0 -2
- package/dist/utils/pda/poseidon.d.ts +0 -4
- package/dist/utils/pda/poseidon.js +0 -20
- package/dist/utils/pda/stake.d.ts +0 -3
- package/dist/utils/pda/stake.js +0 -12
package/dist/claim.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Program } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { TriadProtocol } from './types/triad_protocol';
|
|
4
|
+
import { RpcOptions, CreateClaimVaultArgs, ClaimTokenArgs, UpdateClaimVaultMerkleRootArgs, UpdateClaimVaultIsActiveArgs } from './types';
|
|
5
|
+
export default class Claim {
|
|
6
|
+
private program;
|
|
7
|
+
private rpcOptions;
|
|
8
|
+
constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Get All Claim Vaults
|
|
11
|
+
*/
|
|
12
|
+
getAllClaimVaults(): Promise<import("./types").ClaimVault[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Get Claim Vault
|
|
15
|
+
* @param name - Name of the claim vault
|
|
16
|
+
*/
|
|
17
|
+
getClaimVault(name: string): Promise<import("./types").ClaimVault>;
|
|
18
|
+
/**
|
|
19
|
+
* Get Claimed User
|
|
20
|
+
* @param claimVault - Claim vault
|
|
21
|
+
* @param user - User
|
|
22
|
+
*/
|
|
23
|
+
getClaimedUser(claimVault: PublicKey, user: PublicKey): Promise<import("./types").ClaimedUser>;
|
|
24
|
+
/**
|
|
25
|
+
* Claim Token
|
|
26
|
+
* @param amount - Amount to claim
|
|
27
|
+
* @param merkleProof - Merkle proof
|
|
28
|
+
*/
|
|
29
|
+
claimToken({ amount, merkleProof, mint, claimVault }: ClaimTokenArgs): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Create Claim Vault
|
|
32
|
+
* @param args - Create Claim Vault Args
|
|
33
|
+
*/
|
|
34
|
+
createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, merkleRoot, mint }: CreateClaimVaultArgs): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Update Claim Vault Is Active
|
|
37
|
+
* @param isActive - Is active
|
|
38
|
+
* @param claimVault - Claim vault
|
|
39
|
+
*/
|
|
40
|
+
updateClaimVaultIsActive({ isActive, claimVault }: UpdateClaimVaultIsActiveArgs): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Update Claim Vault Merkle Root
|
|
43
|
+
* @param merkleRoot - Merkle root
|
|
44
|
+
* @param claimVault - Claim vault
|
|
45
|
+
*/
|
|
46
|
+
updateClaimVaultMerkleRoot({ merkleRoot, claimVault }: UpdateClaimVaultMerkleRootArgs): Promise<string>;
|
|
47
|
+
}
|
package/dist/claim.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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 helpers_1 = require("./utils/helpers");
|
|
17
|
+
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
18
|
+
const pda_1 = require("./utils/pda");
|
|
19
|
+
class Claim {
|
|
20
|
+
constructor(program, rpcOptions) {
|
|
21
|
+
this.program = program;
|
|
22
|
+
this.rpcOptions = rpcOptions;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get All Claim Vaults
|
|
26
|
+
*/
|
|
27
|
+
getAllClaimVaults() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const claimVaults = yield this.program.account.claimVault.all();
|
|
30
|
+
return claimVaults.map(({ account, publicKey }) => (0, helpers_1.formatClaimVault)(account, publicKey));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get Claim Vault
|
|
35
|
+
* @param name - Name of the claim vault
|
|
36
|
+
*/
|
|
37
|
+
getClaimVault(name) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const claimVaultPDA = (0, pda_1.getClaimVaultPDA)(this.program.programId, name);
|
|
40
|
+
const claimVault = yield this.program.account.claimVault.fetch(claimVaultPDA);
|
|
41
|
+
return (0, helpers_1.formatClaimVault)(claimVault, claimVaultPDA);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get Claimed User
|
|
46
|
+
* @param claimVault - Claim vault
|
|
47
|
+
* @param user - User
|
|
48
|
+
*/
|
|
49
|
+
getClaimedUser(claimVault, user) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const claimedUserPDA = (0, pda_1.getClaimedUserPDA)(this.program.programId, claimVault, user);
|
|
52
|
+
const claimedUser = yield this.program.account.claimedUser.fetch(claimedUserPDA);
|
|
53
|
+
return (0, helpers_1.formatClaimedUser)(claimedUser, claimedUserPDA);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Claim Token
|
|
58
|
+
* @param amount - Amount to claim
|
|
59
|
+
* @param merkleProof - Merkle proof
|
|
60
|
+
*/
|
|
61
|
+
claimToken({ amount, merkleProof, mint, claimVault }) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const ixs = [
|
|
64
|
+
yield this.program.methods
|
|
65
|
+
.claimToken({
|
|
66
|
+
amount: new anchor_1.BN(amount),
|
|
67
|
+
merkleProof
|
|
68
|
+
})
|
|
69
|
+
.accounts({
|
|
70
|
+
signer: this.program.provider.publicKey,
|
|
71
|
+
mint,
|
|
72
|
+
claimVault
|
|
73
|
+
})
|
|
74
|
+
.instruction()
|
|
75
|
+
];
|
|
76
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create Claim Vault
|
|
81
|
+
* @param args - Create Claim Vault Args
|
|
82
|
+
*/
|
|
83
|
+
createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, merkleRoot, mint }) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const ixs = [
|
|
86
|
+
yield this.program.methods
|
|
87
|
+
.createClaimVault({
|
|
88
|
+
totalAmount: new anchor_1.BN(totalAmount),
|
|
89
|
+
totalUsers: new anchor_1.BN(totalUsers),
|
|
90
|
+
name,
|
|
91
|
+
isFirstComeFirstServed,
|
|
92
|
+
endTs: new anchor_1.BN(endTs),
|
|
93
|
+
merkleRoot
|
|
94
|
+
})
|
|
95
|
+
.accounts({
|
|
96
|
+
signer: this.program.provider.publicKey,
|
|
97
|
+
mint
|
|
98
|
+
})
|
|
99
|
+
.instruction()
|
|
100
|
+
];
|
|
101
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Update Claim Vault Is Active
|
|
106
|
+
* @param isActive - Is active
|
|
107
|
+
* @param claimVault - Claim vault
|
|
108
|
+
*/
|
|
109
|
+
updateClaimVaultIsActive({ isActive, claimVault }) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const ixs = [
|
|
112
|
+
yield this.program.methods
|
|
113
|
+
.updateClaimVaultIsActive(isActive)
|
|
114
|
+
.accounts({
|
|
115
|
+
signer: this.program.provider.publicKey,
|
|
116
|
+
claimVault
|
|
117
|
+
})
|
|
118
|
+
.instruction()
|
|
119
|
+
];
|
|
120
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Update Claim Vault Merkle Root
|
|
125
|
+
* @param merkleRoot - Merkle root
|
|
126
|
+
* @param claimVault - Claim vault
|
|
127
|
+
*/
|
|
128
|
+
updateClaimVaultMerkleRoot({ merkleRoot, claimVault }) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const ixs = [
|
|
131
|
+
yield this.program.methods
|
|
132
|
+
.updateClaimVaultMerkleRoot(merkleRoot)
|
|
133
|
+
.accounts({
|
|
134
|
+
signer: this.program.provider.publicKey,
|
|
135
|
+
claimVault
|
|
136
|
+
})
|
|
137
|
+
.instruction()
|
|
138
|
+
];
|
|
139
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.default = Claim;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,119 +1,103 @@
|
|
|
1
|
-
import { Connection, PublicKey, TransactionInstruction
|
|
1
|
+
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions,
|
|
5
|
+
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CollectMarketFeeArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection } from './types';
|
|
6
6
|
import Stake from './stake';
|
|
7
7
|
import Poseidon from './poseidon';
|
|
8
8
|
export * from './types';
|
|
9
|
-
export * from './types/stake';
|
|
10
|
-
export * from './types/poseidon';
|
|
11
9
|
export * from './utils/helpers';
|
|
12
10
|
export default class TriadProtocolClient {
|
|
11
|
+
private connection;
|
|
12
|
+
private wallet;
|
|
13
|
+
private rpcOptions;
|
|
13
14
|
program: Program<TriadProtocol>;
|
|
14
15
|
provider: AnchorProvider;
|
|
15
16
|
stake: Stake;
|
|
16
17
|
poseidon: Poseidon;
|
|
17
|
-
|
|
18
|
-
constructor(connection: Connection, wallet: Wallet, commitment?: Commitment);
|
|
18
|
+
constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
|
|
19
19
|
/**
|
|
20
20
|
* Get All Pools
|
|
21
|
-
*
|
|
22
21
|
*/
|
|
23
22
|
getAllPools(): Promise<import("./types").Pool[]>;
|
|
24
23
|
/**
|
|
25
24
|
* Get All Markets
|
|
26
|
-
*
|
|
27
25
|
*/
|
|
28
26
|
getAllMarkets(): Promise<import("./types").Market[]>;
|
|
29
27
|
/**
|
|
30
28
|
* Get My User Trades from a user authority
|
|
31
29
|
* @param wallet - User wallet PublicKey
|
|
32
|
-
*
|
|
33
30
|
*/
|
|
34
31
|
getMyUserTrades(wallet: PublicKey): Promise<UserTrade[]>;
|
|
35
32
|
/**
|
|
36
33
|
* Get User Orders
|
|
37
34
|
* @param wallet - User wallet PublicKey
|
|
38
|
-
*
|
|
39
35
|
*/
|
|
40
36
|
getUserOrders(wallet: PublicKey): Promise<import("./types").Order[]>;
|
|
41
37
|
/**
|
|
42
38
|
* Get User Orders By Market ID
|
|
43
39
|
* @param wallet - User wallet PublicKey
|
|
44
40
|
* @param marketId - The ID of the market
|
|
45
|
-
*
|
|
46
41
|
*/
|
|
47
42
|
getUserOrdersByMarketId(wallet: PublicKey, marketId: number): Promise<import("./types").Order[]>;
|
|
48
43
|
/**
|
|
49
44
|
* Get User Book Orders
|
|
50
|
-
*
|
|
51
45
|
*/
|
|
52
46
|
getUserBookOrders(wallet: PublicKey, marketId: number): Promise<BookOrder[]>;
|
|
53
47
|
/**
|
|
54
48
|
* Get Pool By ID
|
|
55
49
|
* @param poolId - The ID of the pool
|
|
56
|
-
*
|
|
57
50
|
*/
|
|
58
51
|
getPoolById(poolId: number): Promise<import("./types").Pool>;
|
|
59
52
|
/**
|
|
60
53
|
* Get Market By ID
|
|
61
54
|
* @param marketId - The ID of the market
|
|
62
|
-
*
|
|
63
55
|
*/
|
|
64
56
|
getMarketById(marketId: number): Promise<import("./types").Market>;
|
|
65
57
|
/**
|
|
66
58
|
* Get Market By Address
|
|
67
59
|
* @param marketAddress - The address of the market
|
|
68
|
-
*
|
|
69
60
|
*/
|
|
70
61
|
getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
|
|
71
62
|
/**
|
|
72
63
|
* Get Costumer By Wallet Address
|
|
73
64
|
* @param wallet - The wallet address of the customer
|
|
74
|
-
*
|
|
75
65
|
*/
|
|
76
66
|
getCustomerByWallet(wallet: PublicKey): Promise<import("./types").Customer>;
|
|
77
67
|
/**
|
|
78
68
|
* Get Customer By ID
|
|
79
69
|
* @param customerId - The ID of the customer
|
|
80
|
-
*
|
|
81
70
|
*/
|
|
82
71
|
getCustomerById(customerId: number): Promise<import("./types").Customer>;
|
|
83
72
|
/**
|
|
84
73
|
* Get Current Market ID
|
|
85
|
-
*
|
|
86
74
|
*/
|
|
87
75
|
nextMarketId(): Promise<number>;
|
|
88
76
|
/**
|
|
89
77
|
* Get Next Customer ID
|
|
90
|
-
*
|
|
91
78
|
*/
|
|
92
79
|
nextCustomerId(): Promise<number>;
|
|
93
80
|
/**
|
|
94
81
|
* Get Next Pool ID
|
|
95
|
-
*
|
|
96
82
|
*/
|
|
97
83
|
nextPoolId(): Promise<number>;
|
|
98
84
|
/**
|
|
99
85
|
* Get User Trade PDA
|
|
100
86
|
* @param wallet - User wallet PublicKey
|
|
101
87
|
* @param userNonce - The nonce of the user
|
|
102
|
-
*
|
|
103
88
|
*/
|
|
104
89
|
getUserPDA(wallet: PublicKey, userNonce?: number): PublicKey;
|
|
105
90
|
/**
|
|
106
91
|
* Get User Trade
|
|
107
92
|
* @param wallet - User wallet PublicKey
|
|
108
93
|
* @param userNonce - The nonce of the user
|
|
109
|
-
*
|
|
110
94
|
*/
|
|
111
95
|
getUserTrade(wallet: PublicKey, userNonce?: number): Promise<{
|
|
112
96
|
bump: number;
|
|
113
97
|
authority: PublicKey;
|
|
114
|
-
totalDeposits: BN;
|
|
115
|
-
totalWithdraws: BN;
|
|
116
98
|
padding1: number[];
|
|
99
|
+
padding2: number[];
|
|
100
|
+
padding3: number[];
|
|
117
101
|
orders: {
|
|
118
102
|
ts: BN;
|
|
119
103
|
orderId: BN;
|
|
@@ -212,26 +196,24 @@ export default class TriadProtocolClient {
|
|
|
212
196
|
}>;
|
|
213
197
|
/**
|
|
214
198
|
* Create Market
|
|
215
|
-
* @param args.
|
|
216
|
-
* @param args.
|
|
217
|
-
* @param args.
|
|
218
|
-
* @param args.
|
|
219
|
-
* @param args.
|
|
220
|
-
* @param args.
|
|
221
|
-
*
|
|
222
|
-
* @param
|
|
223
|
-
*
|
|
224
|
-
*/
|
|
225
|
-
createMarket({ markets, customer,
|
|
199
|
+
* @param args.markets - Array of markets to create
|
|
200
|
+
* @param args.markets.marketId - Market ID
|
|
201
|
+
* @param args.markets.startTime - start time
|
|
202
|
+
* @param args.markets.endTime - end time
|
|
203
|
+
* @param args.markets.question - question (max 80 characters)
|
|
204
|
+
* @param args.markets.liquidityAtStart - liquidity at start
|
|
205
|
+
* @param args.markets.payoutFee - payout fee (to add affiliate system)
|
|
206
|
+
* @param args.customer - The customer of the market
|
|
207
|
+
* @param args.poolId - The ID of the pool
|
|
208
|
+
*/
|
|
209
|
+
createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string>;
|
|
226
210
|
/**
|
|
227
211
|
* Create Pool
|
|
228
212
|
* @param poolId - The ID of the pool
|
|
229
213
|
* @param question - The question of the pool
|
|
230
214
|
* @param markets - The markets of the pool
|
|
231
|
-
*
|
|
232
|
-
* @param options - RPC options
|
|
233
215
|
*/
|
|
234
|
-
createPool({ poolId, question, markets,
|
|
216
|
+
createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string>;
|
|
235
217
|
/**
|
|
236
218
|
* Open Order
|
|
237
219
|
* @param args.marketId - The ID of the Market
|
|
@@ -239,34 +221,26 @@ export default class TriadProtocolClient {
|
|
|
239
221
|
* @param args.direction - The direction of the Order
|
|
240
222
|
* @param args.mint - The mint of the Order
|
|
241
223
|
* @param args.token - The token to use for the Order
|
|
242
|
-
*
|
|
243
|
-
* @param options - RPC options
|
|
244
|
-
*
|
|
245
224
|
*/
|
|
246
|
-
openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs
|
|
225
|
+
openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs): Promise<string>;
|
|
247
226
|
/**
|
|
248
227
|
* Close Order
|
|
249
228
|
* @param args.marketId - The ID of the Market
|
|
250
229
|
* @param args.orderId - The ID of the Order
|
|
251
230
|
* @param args.userNonce - The nonce of the user
|
|
252
|
-
*
|
|
253
|
-
* @param options - RPC options
|
|
254
|
-
*
|
|
255
231
|
*/
|
|
256
232
|
closeOrder({ marketId, orderId, userNonce }: {
|
|
257
233
|
marketId: number;
|
|
258
234
|
orderId: number;
|
|
259
235
|
userNonce: number;
|
|
260
|
-
}
|
|
236
|
+
}): Promise<string>;
|
|
261
237
|
/**
|
|
262
238
|
* Resolve Market
|
|
263
239
|
* @param args.marketId - The ID of the Market
|
|
240
|
+
* @param args.poolId - The ID of the Pool
|
|
264
241
|
* @param args.winningDirection - The Winning Direction of the Market
|
|
265
|
-
*
|
|
266
|
-
* @param options - RPC options
|
|
267
|
-
*
|
|
268
242
|
*/
|
|
269
|
-
|
|
243
|
+
updateMarketWinningDirection({ marketId, poolId, winningDirection }: {
|
|
270
244
|
marketId: number;
|
|
271
245
|
poolId?: number;
|
|
272
246
|
winningDirection: {
|
|
@@ -278,86 +252,69 @@ export default class TriadProtocolClient {
|
|
|
278
252
|
} | {
|
|
279
253
|
draw: {};
|
|
280
254
|
};
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Collect Remaining Liquidity
|
|
284
|
-
* @param marketId - The ID of the market
|
|
285
|
-
*
|
|
286
|
-
* @param options - RPC options
|
|
287
|
-
*
|
|
288
|
-
*/
|
|
289
|
-
collectRemainingLiquidity(marketId: number, options?: RpcOptions): Promise<string>;
|
|
255
|
+
}): Promise<string>;
|
|
290
256
|
/**
|
|
291
257
|
* Payout Order
|
|
292
258
|
* @param args.marketId - The ID of the Market
|
|
293
259
|
* @param args.orderId - The ID of the Order to Payout
|
|
294
260
|
* @param args.userNonce - The nonce of the user
|
|
295
261
|
* @param args.mint - The mint of the market
|
|
296
|
-
* @param args.shares - The shares of the order
|
|
297
|
-
*
|
|
298
|
-
* @param options - RPC options
|
|
299
|
-
*
|
|
300
262
|
*/
|
|
301
263
|
payoutOrder(orders: {
|
|
302
264
|
marketId: number;
|
|
303
265
|
orderId: number;
|
|
304
266
|
userNonce: number;
|
|
305
267
|
mint: PublicKey;
|
|
306
|
-
|
|
307
|
-
}[], options?: RpcOptions): Promise<string>;
|
|
268
|
+
}[]): Promise<string>;
|
|
308
269
|
/**
|
|
309
|
-
*
|
|
270
|
+
* Update Market Payout
|
|
310
271
|
* @param marketId - The ID of the market
|
|
311
272
|
* @param poolId - The ID of the pool
|
|
312
|
-
*
|
|
313
|
-
* @param options - RPC options
|
|
314
|
-
*
|
|
273
|
+
* @param allowPayout - Whether to allow the market to payout
|
|
315
274
|
*/
|
|
316
|
-
|
|
275
|
+
updateMarketPayout({ marketId, poolId, allowPayout }: {
|
|
317
276
|
marketId: number;
|
|
318
277
|
poolId?: number;
|
|
319
|
-
|
|
278
|
+
allowPayout: boolean;
|
|
279
|
+
}): Promise<string>;
|
|
320
280
|
/**
|
|
321
281
|
* Create Sub User Trade
|
|
322
282
|
* @param user - User PublicKey the main user
|
|
323
|
-
*
|
|
324
|
-
* @param options - RPC options
|
|
325
|
-
*
|
|
326
283
|
*/
|
|
327
|
-
createSubUserTrade(user: PublicKey
|
|
284
|
+
createSubUserTrade(user: PublicKey): Promise<string>;
|
|
328
285
|
/**
|
|
329
|
-
* Update Market
|
|
286
|
+
* Update Market End
|
|
330
287
|
* @param marketId - The ID of the market
|
|
331
288
|
* @param marketEnd - The end time of the market
|
|
332
|
-
*
|
|
333
|
-
* @param options - RPC options
|
|
334
|
-
*
|
|
335
289
|
*/
|
|
336
|
-
|
|
290
|
+
updateMarketEnd({ marketId, marketEnd }: {
|
|
337
291
|
marketId: number;
|
|
338
292
|
marketEnd: number;
|
|
339
|
-
|
|
340
|
-
|
|
293
|
+
}): Promise<string>;
|
|
294
|
+
/**
|
|
295
|
+
* Update Market Question
|
|
296
|
+
* @param marketId - The ID of the market
|
|
297
|
+
* @param question - The question of the market
|
|
298
|
+
*/
|
|
299
|
+
updateMarketQuestion({ marketId, question }: {
|
|
300
|
+
marketId: number;
|
|
301
|
+
question: string;
|
|
302
|
+
}): Promise<string>;
|
|
341
303
|
/**
|
|
342
304
|
* Create Customer
|
|
343
305
|
* @param args.id - The ID of the customer
|
|
344
306
|
* @param args.name - The name of the customer
|
|
345
307
|
* @param args.authority - The authority of the customer
|
|
346
308
|
* @param args.feeRecipient - The fee recipient of the customer
|
|
347
|
-
*
|
|
348
|
-
* @param options - RPC options
|
|
349
|
-
*
|
|
350
309
|
*/
|
|
351
|
-
createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs
|
|
310
|
+
createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string>;
|
|
352
311
|
/**
|
|
353
312
|
* Get User Trade Nonce With Slots
|
|
354
313
|
* @param userTrades - User Trades
|
|
355
|
-
*
|
|
356
314
|
*/
|
|
357
315
|
getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
|
|
358
316
|
/**
|
|
359
317
|
* Get User Trade Ixs
|
|
360
|
-
*
|
|
361
318
|
*/
|
|
362
319
|
getUserTradeIxs(): Promise<{
|
|
363
320
|
userTradePDA: PublicKey;
|
|
@@ -371,85 +328,73 @@ export default class TriadProtocolClient {
|
|
|
371
328
|
/**
|
|
372
329
|
* Get User Trade Nonce
|
|
373
330
|
* @param marketId - The ID of the Market
|
|
374
|
-
* @param
|
|
375
|
-
*
|
|
331
|
+
* @param orderDirection - The direction of the Order
|
|
376
332
|
*/
|
|
377
|
-
getUserTradeNonce(marketId: number,
|
|
333
|
+
getUserTradeNonce(marketId: number, orderDirection: OrderDirection): Promise<{
|
|
378
334
|
userTradePDA: PublicKey;
|
|
379
335
|
userTradeIxs: TransactionInstruction[];
|
|
380
336
|
}>;
|
|
381
337
|
/**
|
|
382
338
|
* Place Bid Order
|
|
383
339
|
* @param args.marketId - The ID of the Market
|
|
384
|
-
* @param args.
|
|
385
|
-
* @param args.
|
|
340
|
+
* @param args.orders - Array of orders to execute
|
|
341
|
+
* @param args.orders.amount - The amount of the Order
|
|
342
|
+
* @param args.orders.price - The price of the Order
|
|
343
|
+
* @param args.orders.orderDirection - The direction of the Order
|
|
386
344
|
* @param args.mint - The mint of the Order
|
|
387
|
-
* @param args.price - The price of the Order
|
|
388
345
|
* @param args.isTrdPayout - Whether to payout in TRD or not
|
|
389
|
-
*
|
|
390
|
-
* @param options - RPC options
|
|
391
346
|
*/
|
|
392
|
-
placeBidOrder({ marketId, orders,
|
|
347
|
+
placeBidOrder({ marketId, orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string>;
|
|
393
348
|
/**
|
|
394
349
|
* Place Ask Order
|
|
395
350
|
* @param args.marketId - The ID of the Market
|
|
396
|
-
* @param args.
|
|
397
|
-
* @param args.
|
|
398
|
-
* @param args.price - The price of the Order
|
|
399
|
-
* @param args.bidOrderId - The ID of the Bid Order
|
|
400
|
-
* @param args.bidNonce - The nonce of the Bid Order
|
|
401
|
-
*
|
|
402
|
-
* @param options - RPC options
|
|
403
|
-
*
|
|
351
|
+
* @param args.orders - Array of orders to execute
|
|
352
|
+
* @param args.orders.amount - The amount of the Order
|
|
353
|
+
* @param args.orders.price - The price of the Order
|
|
354
|
+
* @param args.orders.bidOrderId - The ID of the Bid Order
|
|
355
|
+
* @param args.orders.bidNonce - The nonce of the Bid Order
|
|
404
356
|
*/
|
|
405
|
-
placeAskOrder({ marketId, orders }: PlaceAskOrderArgs
|
|
357
|
+
placeAskOrder({ marketId, orders }: PlaceAskOrderArgs): Promise<string>;
|
|
406
358
|
/**
|
|
407
359
|
* Cancel Bid Order
|
|
408
360
|
* @param args.marketId - The ID of the Market
|
|
409
|
-
* @param args.orderId - The ID of the Order
|
|
410
|
-
* @param args.userNonce - The nonce of the user
|
|
411
|
-
* @param args.
|
|
412
|
-
*
|
|
413
|
-
* @param options - RPC options
|
|
361
|
+
* @param args.orders.orderId - The ID of the Order
|
|
362
|
+
* @param args.orders.userNonce - The nonce of the user
|
|
363
|
+
* @param args.orders.orderDirection - The direction of the Order
|
|
414
364
|
*/
|
|
415
|
-
cancelBidOrder({ marketId, orders
|
|
365
|
+
cancelBidOrder({ marketId, orders }: CancelBidOrderArgs): Promise<string>;
|
|
416
366
|
/**
|
|
417
367
|
* Cancel Ask Order
|
|
418
368
|
* @param args.marketId - The ID of the Market
|
|
419
|
-
* @param args.orderId - The ID of the Order
|
|
420
|
-
* @param args.userNonce - The nonce of the user
|
|
421
|
-
* @param args.
|
|
422
|
-
* @param args.direction - The direction of the Order
|
|
423
|
-
*
|
|
424
|
-
* @param options - RPC options
|
|
369
|
+
* @param args.orders.orderId - The ID of the Order
|
|
370
|
+
* @param args.orders.userNonce - The nonce of the user
|
|
371
|
+
* @param args.orders.orderDirection - The direction of the Order
|
|
425
372
|
*/
|
|
426
|
-
cancelAskOrder({ marketId, orders }: CancelAskOrderArgs
|
|
373
|
+
cancelAskOrder({ marketId, orders }: CancelAskOrderArgs): Promise<string>;
|
|
427
374
|
/**
|
|
428
375
|
* Market Bid Order
|
|
429
376
|
* @param args.marketId - The ID of the Market
|
|
430
377
|
* @param args.amount - The amount of the Order
|
|
431
|
-
* @param args.
|
|
432
|
-
* @param args.mint - The mint of the Order
|
|
378
|
+
* @param args.orderDirection - The direction of the Order
|
|
433
379
|
* @param args.feeBps - The fee in basis points
|
|
434
380
|
* @param args.isTrdPayout - Whether to payout in TRD or not
|
|
435
|
-
*
|
|
436
|
-
* @param options - RPC options
|
|
437
381
|
*/
|
|
438
|
-
marketBidOrder({ marketId, amount,
|
|
382
|
+
marketBidOrder({ marketId, amount, orderDirection, feeBps, isTrdPayout }: MarketBidOrderArgs): Promise<string>;
|
|
439
383
|
/**
|
|
440
384
|
* Market Ask Order
|
|
441
385
|
* @param args.marketId - The ID of the Market
|
|
442
386
|
* @param args.orders - Array of orders to execute
|
|
443
|
-
* @param args.
|
|
387
|
+
* @param args.orders.shares - The amount of shares to sell
|
|
388
|
+
* @param args.orders.bidOrderId - The ID of the Bid Order
|
|
389
|
+
* @param args.orders.userNonce - The nonce of the user
|
|
390
|
+
* @param args.orderDirection - The direction of the Order
|
|
444
391
|
* @param args.isTrdPayout - Whether to payout in TRD or not
|
|
445
|
-
*
|
|
446
|
-
* @param options - RPC options
|
|
392
|
+
* @param args.feeBps - The fee in basis points
|
|
447
393
|
*/
|
|
448
|
-
marketAskOrder({ marketId, orders,
|
|
394
|
+
marketAskOrder({ marketId, orders, orderDirection, isTrdPayout, feeBps }: MarketAskOrderArgs): Promise<string>;
|
|
449
395
|
/**
|
|
450
396
|
* Get Orders By Market ID
|
|
451
|
-
* @param marketId -
|
|
452
|
-
*
|
|
397
|
+
* @param marketId - Market ID
|
|
453
398
|
*/
|
|
454
399
|
getOrderBook(marketId: number): Promise<{
|
|
455
400
|
marketId: number;
|
|
@@ -468,32 +413,14 @@ export default class TriadProtocolClient {
|
|
|
468
413
|
/**
|
|
469
414
|
* Collect Market Fee
|
|
470
415
|
* @param args.markets - The markets to collect the fee from
|
|
471
|
-
* @param args.markets.mint - The mint of the market
|
|
472
416
|
* @param args.markets.marketAddress - The address of the market
|
|
473
417
|
* @param args.markets.customerId - The ID of the customer
|
|
474
418
|
* @param args.markets.customerFeeRecipient - The address of the customer fee recipient
|
|
475
|
-
*
|
|
476
|
-
* @param options - RPC options
|
|
477
419
|
*/
|
|
478
|
-
collectMarketFee(markets:
|
|
479
|
-
mint: PublicKey;
|
|
480
|
-
marketAddress: PublicKey;
|
|
481
|
-
customerId: number;
|
|
482
|
-
customerFeeRecipient: PublicKey;
|
|
483
|
-
}[], options?: RpcOptions): Promise<string>;
|
|
420
|
+
collectMarketFee({ markets }: CollectMarketFeeArgs): Promise<string>;
|
|
484
421
|
/**
|
|
485
422
|
* Close Order Book
|
|
486
|
-
* @param
|
|
487
|
-
*
|
|
488
|
-
* @param options - RPC options
|
|
489
|
-
*/
|
|
490
|
-
closeOrderBook(marketIds: number[], options?: RpcOptions): Promise<string>;
|
|
491
|
-
/**
|
|
492
|
-
* Update Customer Fee
|
|
493
|
-
* @param feeBps - The fee in basis points
|
|
494
|
-
* @param wallet - The wallet of the customer to update the fee for
|
|
495
|
-
*
|
|
496
|
-
* @param options - RPC options
|
|
423
|
+
* @param marketIds - Market IDs
|
|
497
424
|
*/
|
|
498
|
-
|
|
425
|
+
closeOrderBook(marketIds: number[]): Promise<string>;
|
|
499
426
|
}
|