@triadxyz/triad-protocol 2.2.0-beta → 2.2.2-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 +3 -51
- package/dist/index.js +2 -128
- package/dist/poseidon.d.ts +88 -0
- package/dist/poseidon.js +222 -0
- package/dist/trade.d.ts +1 -1
- package/dist/trade.js +6 -2
- package/dist/types/idl_triad_protocol.json +720 -75
- package/dist/types/poseidon.d.ts +15 -0
- package/dist/types/poseidon.js +2 -0
- package/dist/types/trade.d.ts +7 -6
- package/dist/types/triad_protocol.d.ts +1031 -96
- package/dist/utils/pda/poseidon.d.ts +1 -0
- package/dist/utils/pda/poseidon.js +5 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,62 +1,14 @@
|
|
|
1
1
|
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
|
|
2
|
-
import { Connection
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
3
|
import { TriadProtocol } from './types/triad_protocol';
|
|
4
4
|
import Trade from './trade';
|
|
5
5
|
import Stake from './stake';
|
|
6
|
-
import
|
|
6
|
+
import Poseidon from './poseidon';
|
|
7
7
|
export default class TriadProtocolClient {
|
|
8
8
|
program: Program<TriadProtocol>;
|
|
9
9
|
provider: AnchorProvider;
|
|
10
10
|
trade: Trade;
|
|
11
11
|
stake: Stake;
|
|
12
|
+
poseidon: Poseidon;
|
|
12
13
|
constructor(connection: Connection, wallet: Wallet);
|
|
13
|
-
/**
|
|
14
|
-
* Transfer Poseidon
|
|
15
|
-
* @param args.poseidonAsset - Poseidon Asset
|
|
16
|
-
* @param args.ticketAsset - Ticket Asset
|
|
17
|
-
* @param args.ticketNumber - Ticket Number
|
|
18
|
-
*
|
|
19
|
-
* @param options - RPC options
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
transferPoseidon(args: TransferPoseidonArgs[], options?: RpcOptions): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Withdraw Poseidon
|
|
25
|
-
* @param args.poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
26
|
-
* @param args.nft - NFT Poseidon Number
|
|
27
|
-
*
|
|
28
|
-
* @param options - RPC options
|
|
29
|
-
*/
|
|
30
|
-
withdrawPoseidon({ poseidonAsset, nft }: {
|
|
31
|
-
poseidonAsset: PublicKey;
|
|
32
|
-
nft: number;
|
|
33
|
-
}, options?: RpcOptions): Promise<string>;
|
|
34
|
-
/**
|
|
35
|
-
* Collect Royalty
|
|
36
|
-
* @param collection - Collection Symbol
|
|
37
|
-
*
|
|
38
|
-
* @param options - RPC options
|
|
39
|
-
*/
|
|
40
|
-
collectRoyalty(collection: string, options?: RpcOptions): Promise<string>;
|
|
41
|
-
/**
|
|
42
|
-
* Add Trader Poseidon
|
|
43
|
-
* @param user - User
|
|
44
|
-
* @param poseidonAsset - Poseidon Asset
|
|
45
|
-
*
|
|
46
|
-
* @param options - RPC options
|
|
47
|
-
*/
|
|
48
|
-
addTraderPoseidon({ user, poseidonAsset }: {
|
|
49
|
-
user: PublicKey;
|
|
50
|
-
poseidonAsset: PublicKey;
|
|
51
|
-
}, options?: RpcOptions): Promise<string>;
|
|
52
|
-
/**
|
|
53
|
-
* Remove Trader Poseidon
|
|
54
|
-
* @param user - User
|
|
55
|
-
*
|
|
56
|
-
* @param options - RPC options
|
|
57
|
-
*/
|
|
58
|
-
removeTraderPoseidon({ user, poseidonAsset }: {
|
|
59
|
-
user: PublicKey;
|
|
60
|
-
poseidonAsset: PublicKey;
|
|
61
|
-
}, options?: RpcOptions): Promise<string>;
|
|
62
14
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
7
|
const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
|
|
17
8
|
const trade_1 = __importDefault(require("./trade"));
|
|
18
|
-
const poseidon_1 = require("./utils/pda/poseidon");
|
|
19
9
|
const stake_1 = __importDefault(require("./stake"));
|
|
20
|
-
const
|
|
21
|
-
const constants_1 = require("./utils/constants");
|
|
22
|
-
const pda_1 = require("./utils/pda");
|
|
10
|
+
const poseidon_1 = __importDefault(require("./poseidon"));
|
|
23
11
|
class TriadProtocolClient {
|
|
24
12
|
constructor(connection, wallet) {
|
|
25
13
|
this.provider = new anchor_1.AnchorProvider(connection, wallet, {
|
|
@@ -28,121 +16,7 @@ class TriadProtocolClient {
|
|
|
28
16
|
this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
|
|
29
17
|
this.trade = new trade_1.default(this.program);
|
|
30
18
|
this.stake = new stake_1.default(this.program);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Transfer Poseidon
|
|
34
|
-
* @param args.poseidonAsset - Poseidon Asset
|
|
35
|
-
* @param args.ticketAsset - Ticket Asset
|
|
36
|
-
* @param args.ticketNumber - Ticket Number
|
|
37
|
-
*
|
|
38
|
-
* @param options - RPC options
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
transferPoseidon(args, options) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const ixs = [];
|
|
44
|
-
for (const arg of args) {
|
|
45
|
-
ixs.push(yield this.program.methods
|
|
46
|
-
.transferPoseidon()
|
|
47
|
-
.accounts({
|
|
48
|
-
signer: this.provider.wallet.publicKey,
|
|
49
|
-
nft: (0, poseidon_1.getNftPDA)(this.program.programId, arg.ticketNumber),
|
|
50
|
-
poseidonAsset: arg.poseidonAsset,
|
|
51
|
-
ticketAsset: arg.ticketAsset,
|
|
52
|
-
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
53
|
-
ticketCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.TICKET_COLLECTION_SYMBOL),
|
|
54
|
-
coreTicketCollection: constants_1.TICKET_CORE_COLLECTION,
|
|
55
|
-
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
56
|
-
})
|
|
57
|
-
.instruction());
|
|
58
|
-
}
|
|
59
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Withdraw Poseidon
|
|
64
|
-
* @param args.poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
65
|
-
* @param args.nft - NFT Poseidon Number
|
|
66
|
-
*
|
|
67
|
-
* @param options - RPC options
|
|
68
|
-
*/
|
|
69
|
-
withdrawPoseidon({ poseidonAsset, nft }, options) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const ixs = [];
|
|
72
|
-
ixs.push(yield this.program.methods
|
|
73
|
-
.withdrawPoseidon()
|
|
74
|
-
.accounts({
|
|
75
|
-
signer: this.provider.wallet.publicKey,
|
|
76
|
-
nft: (0, poseidon_1.getPoseidonPDA)(this.program.programId, nft),
|
|
77
|
-
poseidonAsset,
|
|
78
|
-
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
79
|
-
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
80
|
-
})
|
|
81
|
-
.instruction());
|
|
82
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Collect Royalty
|
|
87
|
-
* @param collection - Collection Symbol
|
|
88
|
-
*
|
|
89
|
-
* @param options - RPC options
|
|
90
|
-
*/
|
|
91
|
-
collectRoyalty(collection, options) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const ixs = [];
|
|
94
|
-
ixs.push(yield this.program.methods
|
|
95
|
-
.collectRoyalty()
|
|
96
|
-
.accounts({
|
|
97
|
-
signer: this.provider.wallet.publicKey,
|
|
98
|
-
collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
|
|
99
|
-
})
|
|
100
|
-
.instruction());
|
|
101
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Add Trader Poseidon
|
|
106
|
-
* @param user - User
|
|
107
|
-
* @param poseidonAsset - Poseidon Asset
|
|
108
|
-
*
|
|
109
|
-
* @param options - RPC options
|
|
110
|
-
*/
|
|
111
|
-
addTraderPoseidon({ user, poseidonAsset }, options) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const ixs = [];
|
|
114
|
-
ixs.push(yield this.program.methods
|
|
115
|
-
.addTraderPoseidon()
|
|
116
|
-
.accounts({
|
|
117
|
-
poseidonAsset,
|
|
118
|
-
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
119
|
-
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
120
|
-
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
121
|
-
})
|
|
122
|
-
.instruction());
|
|
123
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Remove Trader Poseidon
|
|
128
|
-
* @param user - User
|
|
129
|
-
*
|
|
130
|
-
* @param options - RPC options
|
|
131
|
-
*/
|
|
132
|
-
removeTraderPoseidon({ user, poseidonAsset }, options) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
const ixs = [];
|
|
135
|
-
ixs.push(yield this.program.methods
|
|
136
|
-
.removeTraderPoseidon()
|
|
137
|
-
.accounts({
|
|
138
|
-
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
139
|
-
poseidonAsset,
|
|
140
|
-
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
141
|
-
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
142
|
-
})
|
|
143
|
-
.instruction());
|
|
144
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
145
|
-
});
|
|
19
|
+
this.poseidon = new poseidon_1.default(this.program);
|
|
146
20
|
}
|
|
147
21
|
}
|
|
148
22
|
exports.default = TriadProtocolClient;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Program } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { TriadProtocol } from './types/triad_protocol';
|
|
4
|
+
import { RpcOptions, TransferPoseidonArgs } from './types';
|
|
5
|
+
import { CreateChestArgs, BidChestArgs, BuyChestTokenArgs } from './types/poseidon';
|
|
6
|
+
export default class Poseidon {
|
|
7
|
+
private program;
|
|
8
|
+
constructor(program: Program<TriadProtocol>);
|
|
9
|
+
/**
|
|
10
|
+
* Transfer Poseidon
|
|
11
|
+
* @param args.poseidonAsset - Poseidon Asset
|
|
12
|
+
* @param args.ticketAsset - Ticket Asset
|
|
13
|
+
* @param args.ticketNumber - Ticket Number
|
|
14
|
+
*
|
|
15
|
+
* @param options - RPC options
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
transferPoseidon(args: TransferPoseidonArgs[], options?: RpcOptions): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Withdraw Poseidon
|
|
21
|
+
* @param args.poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
22
|
+
* @param args.nft - NFT Poseidon Number
|
|
23
|
+
*
|
|
24
|
+
* @param options - RPC options
|
|
25
|
+
*/
|
|
26
|
+
withdrawPoseidon({ poseidonAsset, nft }: {
|
|
27
|
+
poseidonAsset: PublicKey;
|
|
28
|
+
nft: number;
|
|
29
|
+
}, options?: RpcOptions): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Collect Royalty
|
|
32
|
+
* @param collection - Collection Symbol
|
|
33
|
+
*
|
|
34
|
+
* @param options - RPC options
|
|
35
|
+
*/
|
|
36
|
+
collectRoyalty(collection: string, options?: RpcOptions): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Add Trader Poseidon
|
|
39
|
+
* @param user - User
|
|
40
|
+
* @param poseidonAsset - Poseidon Asset
|
|
41
|
+
*
|
|
42
|
+
* @param options - RPC options
|
|
43
|
+
*/
|
|
44
|
+
addTraderPoseidon({ user, poseidonAsset }: {
|
|
45
|
+
user: PublicKey;
|
|
46
|
+
poseidonAsset: PublicKey;
|
|
47
|
+
}, options?: RpcOptions): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Remove Trader Poseidon
|
|
50
|
+
* @param user - User
|
|
51
|
+
*
|
|
52
|
+
* @param options - RPC options
|
|
53
|
+
*/
|
|
54
|
+
removeTraderPoseidon({ user, poseidonAsset }: {
|
|
55
|
+
user: PublicKey;
|
|
56
|
+
poseidonAsset: PublicKey;
|
|
57
|
+
}, options?: RpcOptions): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Create Chest
|
|
60
|
+
* @param args.id - Chest ID
|
|
61
|
+
* @param args.initialPrizePool - Initial Prize Pool
|
|
62
|
+
*
|
|
63
|
+
* @param options - RPC options
|
|
64
|
+
*/
|
|
65
|
+
createChest({ id, initialPrizePool }: CreateChestArgs, options?: RpcOptions): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Bid Chest
|
|
68
|
+
* @param args.id - Chest ID
|
|
69
|
+
* @param args.amount - Amount
|
|
70
|
+
*
|
|
71
|
+
* @param options - RPC options
|
|
72
|
+
*/
|
|
73
|
+
bidChest(args: BidChestArgs, options?: RpcOptions): Promise<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Buy Chest Token
|
|
76
|
+
* @param args.id - Chest ID
|
|
77
|
+
* @param args.amount - Amount
|
|
78
|
+
*
|
|
79
|
+
* @param options - RPC options
|
|
80
|
+
*/
|
|
81
|
+
buyChestToken(args: BuyChestTokenArgs, options?: RpcOptions): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Collect Chest Token
|
|
84
|
+
*
|
|
85
|
+
* @param options - RPC options
|
|
86
|
+
*/
|
|
87
|
+
collectChestToken(id: number, options?: RpcOptions): Promise<string>;
|
|
88
|
+
}
|
package/dist/poseidon.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
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 constants_1 = require("./utils/constants");
|
|
17
|
+
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
18
|
+
const poseidon_1 = require("./utils/pda/poseidon");
|
|
19
|
+
const pda_1 = require("./utils/pda");
|
|
20
|
+
class Poseidon {
|
|
21
|
+
constructor(program) {
|
|
22
|
+
this.program = program;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Transfer Poseidon
|
|
26
|
+
* @param args.poseidonAsset - Poseidon Asset
|
|
27
|
+
* @param args.ticketAsset - Ticket Asset
|
|
28
|
+
* @param args.ticketNumber - Ticket Number
|
|
29
|
+
*
|
|
30
|
+
* @param options - RPC options
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
transferPoseidon(args, options) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const ixs = [];
|
|
36
|
+
for (const arg of args) {
|
|
37
|
+
ixs.push(yield this.program.methods
|
|
38
|
+
.transferPoseidon()
|
|
39
|
+
.accounts({
|
|
40
|
+
signer: this.program.provider.publicKey,
|
|
41
|
+
nft: (0, poseidon_1.getNftPDA)(this.program.programId, arg.ticketNumber),
|
|
42
|
+
poseidonAsset: arg.poseidonAsset,
|
|
43
|
+
ticketAsset: arg.ticketAsset,
|
|
44
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
45
|
+
ticketCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.TICKET_COLLECTION_SYMBOL),
|
|
46
|
+
coreTicketCollection: constants_1.TICKET_CORE_COLLECTION,
|
|
47
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
48
|
+
})
|
|
49
|
+
.instruction());
|
|
50
|
+
}
|
|
51
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Withdraw Poseidon
|
|
56
|
+
* @param args.poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
57
|
+
* @param args.nft - NFT Poseidon Number
|
|
58
|
+
*
|
|
59
|
+
* @param options - RPC options
|
|
60
|
+
*/
|
|
61
|
+
withdrawPoseidon({ poseidonAsset, nft }, options) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const ixs = [];
|
|
64
|
+
ixs.push(yield this.program.methods
|
|
65
|
+
.withdrawPoseidon()
|
|
66
|
+
.accounts({
|
|
67
|
+
signer: this.program.provider.publicKey,
|
|
68
|
+
nft: (0, poseidon_1.getPoseidonPDA)(this.program.programId, nft),
|
|
69
|
+
poseidonAsset,
|
|
70
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
71
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
72
|
+
})
|
|
73
|
+
.instruction());
|
|
74
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Collect Royalty
|
|
79
|
+
* @param collection - Collection Symbol
|
|
80
|
+
*
|
|
81
|
+
* @param options - RPC options
|
|
82
|
+
*/
|
|
83
|
+
collectRoyalty(collection, options) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const ixs = [];
|
|
86
|
+
ixs.push(yield this.program.methods
|
|
87
|
+
.collectRoyalty()
|
|
88
|
+
.accounts({
|
|
89
|
+
signer: this.program.provider.publicKey,
|
|
90
|
+
collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
|
|
91
|
+
})
|
|
92
|
+
.instruction());
|
|
93
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Add Trader Poseidon
|
|
98
|
+
* @param user - User
|
|
99
|
+
* @param poseidonAsset - Poseidon Asset
|
|
100
|
+
*
|
|
101
|
+
* @param options - RPC options
|
|
102
|
+
*/
|
|
103
|
+
addTraderPoseidon({ user, poseidonAsset }, options) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const ixs = [];
|
|
106
|
+
ixs.push(yield this.program.methods
|
|
107
|
+
.addTraderPoseidon()
|
|
108
|
+
.accounts({
|
|
109
|
+
poseidonAsset,
|
|
110
|
+
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
111
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
112
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
113
|
+
})
|
|
114
|
+
.instruction());
|
|
115
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Remove Trader Poseidon
|
|
120
|
+
* @param user - User
|
|
121
|
+
*
|
|
122
|
+
* @param options - RPC options
|
|
123
|
+
*/
|
|
124
|
+
removeTraderPoseidon({ user, poseidonAsset }, options) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const ixs = [];
|
|
127
|
+
ixs.push(yield this.program.methods
|
|
128
|
+
.removeTraderPoseidon()
|
|
129
|
+
.accounts({
|
|
130
|
+
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
131
|
+
poseidonAsset,
|
|
132
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
133
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
134
|
+
})
|
|
135
|
+
.instruction());
|
|
136
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create Chest
|
|
141
|
+
* @param args.id - Chest ID
|
|
142
|
+
* @param args.initialPrizePool - Initial Prize Pool
|
|
143
|
+
*
|
|
144
|
+
* @param options - RPC options
|
|
145
|
+
*/
|
|
146
|
+
createChest({ id, initialPrizePool }, options) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const ixs = [];
|
|
149
|
+
ixs.push(yield this.program.methods
|
|
150
|
+
.createChest({
|
|
151
|
+
id: new anchor_1.BN(id),
|
|
152
|
+
initialPrizePool: new anchor_1.BN(initialPrizePool)
|
|
153
|
+
})
|
|
154
|
+
.accounts({
|
|
155
|
+
signer: this.program.provider.publicKey
|
|
156
|
+
})
|
|
157
|
+
.instruction());
|
|
158
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Bid Chest
|
|
163
|
+
* @param args.id - Chest ID
|
|
164
|
+
* @param args.amount - Amount
|
|
165
|
+
*
|
|
166
|
+
* @param options - RPC options
|
|
167
|
+
*/
|
|
168
|
+
bidChest(args, options) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const ixs = [];
|
|
171
|
+
ixs.push(yield this.program.methods
|
|
172
|
+
.bidChest({
|
|
173
|
+
id: new anchor_1.BN(args.id),
|
|
174
|
+
amount: new anchor_1.BN(args.amount)
|
|
175
|
+
})
|
|
176
|
+
.accounts({
|
|
177
|
+
signer: this.program.provider.publicKey
|
|
178
|
+
})
|
|
179
|
+
.instruction());
|
|
180
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Buy Chest Token
|
|
185
|
+
* @param args.id - Chest ID
|
|
186
|
+
* @param args.amount - Amount
|
|
187
|
+
*
|
|
188
|
+
* @param options - RPC options
|
|
189
|
+
*/
|
|
190
|
+
buyChestToken(args, options) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const ixs = [];
|
|
193
|
+
ixs.push(yield this.program.methods
|
|
194
|
+
.buyChestToken({
|
|
195
|
+
id: new anchor_1.BN(args.id),
|
|
196
|
+
amount: new anchor_1.BN(args.amount)
|
|
197
|
+
})
|
|
198
|
+
.accounts({
|
|
199
|
+
signer: this.program.provider.publicKey
|
|
200
|
+
})
|
|
201
|
+
.instruction());
|
|
202
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Collect Chest Token
|
|
207
|
+
*
|
|
208
|
+
* @param options - RPC options
|
|
209
|
+
*/
|
|
210
|
+
collectChestToken(id, options) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
const ixs = [];
|
|
213
|
+
const chestPDA = (0, poseidon_1.getChestPDA)(this.program.programId, id);
|
|
214
|
+
ixs.push(yield this.program.methods
|
|
215
|
+
.collectChestToken()
|
|
216
|
+
.accounts({ signer: this.program.provider.publicKey, chest: chestPDA })
|
|
217
|
+
.instruction());
|
|
218
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.default = Poseidon;
|
package/dist/trade.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ export default class Trade {
|
|
|
156
156
|
* @param options - RPC options
|
|
157
157
|
*
|
|
158
158
|
*/
|
|
159
|
-
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
159
|
+
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
160
160
|
/**
|
|
161
161
|
* Create Pool
|
|
162
162
|
* @param poolId - The ID of the pool
|
package/dist/trade.js
CHANGED
|
@@ -117,12 +117,16 @@ class Trade {
|
|
|
117
117
|
* @param options - RPC options
|
|
118
118
|
*
|
|
119
119
|
*/
|
|
120
|
-
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }, options) {
|
|
120
|
+
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }, options) {
|
|
121
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
122
|
if (question.length > 80) {
|
|
123
123
|
throw new Error('Question must be less than 80 characters');
|
|
124
124
|
}
|
|
125
125
|
const ixs = [];
|
|
126
|
+
let poolPDA = null;
|
|
127
|
+
if (poolId) {
|
|
128
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
129
|
+
}
|
|
126
130
|
ixs.push(yield this.program.methods
|
|
127
131
|
.createMarket({
|
|
128
132
|
marketId: new bn_js_1.default(marketId),
|
|
@@ -137,7 +141,7 @@ class Trade {
|
|
|
137
141
|
mint,
|
|
138
142
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
139
143
|
customer,
|
|
140
|
-
pool:
|
|
144
|
+
pool: poolPDA
|
|
141
145
|
})
|
|
142
146
|
.instruction());
|
|
143
147
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|