@triadxyz/triad-protocol 1.1.5-beta → 1.1.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/trade.d.ts +14 -1
- package/dist/trade.js +40 -0
- package/dist/types/trade.d.ts +15 -0
- package/package.json +1 -1
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 { InitializeQuestionArgs, Market, OpenOrderArgs } from './types/trade';
|
|
4
|
+
import { FeeVault, 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 {
|
|
@@ -13,6 +13,7 @@ export default class Trade {
|
|
|
13
13
|
* Get all Markets
|
|
14
14
|
*/
|
|
15
15
|
getAllMarkets(): Promise<Market[]>;
|
|
16
|
+
getFeeVault(marketId: number): Promise<FeeVault>;
|
|
16
17
|
/**
|
|
17
18
|
* Get Market by ID
|
|
18
19
|
* @param marketId - The ID of the market
|
|
@@ -156,4 +157,16 @@ export default class Trade {
|
|
|
156
157
|
*
|
|
157
158
|
*/
|
|
158
159
|
resolveQuestion(marketId: number, options?: RpcOptions): Promise<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Settle an order
|
|
162
|
+
* @param marketId - The ID of the market
|
|
163
|
+
* @param orderId - The ID of the order to settle
|
|
164
|
+
*
|
|
165
|
+
* @param options - RPC options
|
|
166
|
+
*
|
|
167
|
+
*/
|
|
168
|
+
settleOrder({ marketId, orderId }: {
|
|
169
|
+
marketId: number;
|
|
170
|
+
orderId: number;
|
|
171
|
+
}, options?: RpcOptions): Promise<string>;
|
|
159
172
|
}
|
package/dist/trade.js
CHANGED
|
@@ -35,6 +35,26 @@ class Trade {
|
|
|
35
35
|
.then((markets) => markets.map(({ account, publicKey }) => (0, helpers_1.accountToMarket)(account, publicKey)));
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
getFeeVault(marketId) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const feeVaultPDA = (0, trade_1.getFeeVaultPDA)(this.program.programId, marketId);
|
|
41
|
+
const response = yield this.program.account.feeVault.fetch(feeVaultPDA);
|
|
42
|
+
return {
|
|
43
|
+
bump: response.bump,
|
|
44
|
+
authority: response.authority,
|
|
45
|
+
market: response.market,
|
|
46
|
+
deposited: response.deposited.toString(),
|
|
47
|
+
withdrawn: response.withdrawn.toString(),
|
|
48
|
+
netBalance: response.netBalance.toString(),
|
|
49
|
+
projectAvailable: response.projectAvailable.toString(),
|
|
50
|
+
projectClaimed: response.projectClaimed.toString(),
|
|
51
|
+
nftHoldersAvailable: response.nftHoldersAvailable.toString(),
|
|
52
|
+
nftHoldersClaimed: response.nftHoldersClaimed.toString(),
|
|
53
|
+
marketAvailable: response.marketAvailable.toString(),
|
|
54
|
+
marketClaimed: response.marketClaimed.toString()
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
38
58
|
/**
|
|
39
59
|
* Get Market by ID
|
|
40
60
|
* @param marketId - The ID of the market
|
|
@@ -200,5 +220,25 @@ class Trade {
|
|
|
200
220
|
return (0, sendTransactionWithOptions_1.default)(method, options);
|
|
201
221
|
});
|
|
202
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Settle an order
|
|
225
|
+
* @param marketId - The ID of the market
|
|
226
|
+
* @param orderId - The ID of the order to settle
|
|
227
|
+
*
|
|
228
|
+
* @param options - RPC options
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
settleOrder({ marketId, orderId }, options) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
234
|
+
const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
|
|
235
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods.settleOrder(new bn_js_1.default(orderId)).accounts({
|
|
236
|
+
signer: this.provider.publicKey,
|
|
237
|
+
userTrade: userTradePDA,
|
|
238
|
+
market: marketPDA,
|
|
239
|
+
mint: this.mint
|
|
240
|
+
}), options);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
203
243
|
}
|
|
204
244
|
exports.default = Trade;
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
1
2
|
export type Market = {
|
|
2
3
|
address: string;
|
|
3
4
|
bump: number;
|
|
@@ -75,3 +76,17 @@ export type OpenOrderArgs = {
|
|
|
75
76
|
direction: OrderDirection;
|
|
76
77
|
comment?: string;
|
|
77
78
|
};
|
|
79
|
+
export type FeeVault = {
|
|
80
|
+
bump: number;
|
|
81
|
+
authority: PublicKey;
|
|
82
|
+
market: PublicKey;
|
|
83
|
+
deposited: string;
|
|
84
|
+
withdrawn: string;
|
|
85
|
+
netBalance: string;
|
|
86
|
+
projectAvailable: string;
|
|
87
|
+
projectClaimed: string;
|
|
88
|
+
nftHoldersAvailable: string;
|
|
89
|
+
nftHoldersClaimed: string;
|
|
90
|
+
marketAvailable: string;
|
|
91
|
+
marketClaimed: string;
|
|
92
|
+
};
|