@triadxyz/triad-protocol 0.4.4-beta → 0.4.6-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 +2 -1
- package/dist/index.js +39 -0
- package/dist/test.js +15 -0
- package/dist/types/idl_triad_protocol.json +81 -0
- package/dist/types/index.d.ts +9 -2
- package/dist/types/triad_protocol.d.ts +81 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +6 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TriadProtocol } from './types/triad_protocol';
|
|
|
4
4
|
import Ticker from './ticker';
|
|
5
5
|
import Vault from './vault';
|
|
6
6
|
import Stake from './stake';
|
|
7
|
-
import { CreateUserArgs, OpenOreArgs, RpcOptions } from './types';
|
|
7
|
+
import { CreateUserArgs, MineOreArgs, OpenOreArgs, RpcOptions } from './types';
|
|
8
8
|
export default class TriadProtocolClient {
|
|
9
9
|
program: Program<TriadProtocol>;
|
|
10
10
|
provider: AnchorProvider;
|
|
@@ -42,4 +42,5 @@ export default class TriadProtocolClient {
|
|
|
42
42
|
*/
|
|
43
43
|
createUser: ({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions) => Promise<string>;
|
|
44
44
|
openOre: ({ user, payer, name, referralName }: OpenOreArgs, options?: RpcOptions) => Promise<string>;
|
|
45
|
+
mineOre: ({ user, payer, bus, digest, nonce }: MineOreArgs, options?: RpcOptions) => Promise<string>;
|
|
45
46
|
}
|
package/dist/index.js
CHANGED
|
@@ -149,6 +149,45 @@ class TriadProtocolClient {
|
|
|
149
149
|
}));
|
|
150
150
|
}
|
|
151
151
|
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
152
|
+
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
153
|
+
instructions: ixs,
|
|
154
|
+
recentBlockhash: blockhash,
|
|
155
|
+
payerKey: payer.publicKey
|
|
156
|
+
}).compileToV0Message()), [payer], {
|
|
157
|
+
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
158
|
+
commitment: 'confirmed'
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
this.mineOre = ({ user, payer, bus, digest, nonce }, options) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
const userPDA = (0, helpers_1.getUserAddressSync)(this.program.programId, user);
|
|
163
|
+
const proofInfoPDA = (0, helpers_1.getProofOreAddressSync)(userPDA);
|
|
164
|
+
const ixs = [];
|
|
165
|
+
ixs.push(new web3_js_1.TransactionInstruction({
|
|
166
|
+
keys: [],
|
|
167
|
+
programId: new web3_js_1.PublicKey(constants_1.NOOP_PROGRAM_ID),
|
|
168
|
+
data: Buffer.from(proofInfoPDA.toBytes())
|
|
169
|
+
}));
|
|
170
|
+
ixs.push(yield this.program.methods
|
|
171
|
+
.mineOre({
|
|
172
|
+
digest,
|
|
173
|
+
nonce
|
|
174
|
+
})
|
|
175
|
+
.accounts({
|
|
176
|
+
signer: user,
|
|
177
|
+
bus,
|
|
178
|
+
configProgram: (0, helpers_1.configOreProgramAddressSync)(),
|
|
179
|
+
proofInfo: proofInfoPDA,
|
|
180
|
+
sysvarHashesInfo: new web3_js_1.PublicKey('SysvarS1otHashes111111111111111111111111111'),
|
|
181
|
+
sysvarInstructionsInfo: new web3_js_1.PublicKey('Sysvar1nstructions1111111111111111111111111'),
|
|
182
|
+
oreProgram: new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID)
|
|
183
|
+
})
|
|
184
|
+
.instruction());
|
|
185
|
+
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
186
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
187
|
+
microLamports: options.microLamports
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
152
191
|
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
153
192
|
instructions: ixs,
|
|
154
193
|
recentBlockhash: blockhash,
|
package/dist/test.js
CHANGED
|
@@ -86,3 +86,18 @@ const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
86
86
|
});
|
|
87
87
|
console.log(updateBoostResponse);
|
|
88
88
|
});
|
|
89
|
+
const mineOre = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const response = yield triadProtocol.mineOre({
|
|
91
|
+
user: wallet.publicKey,
|
|
92
|
+
payer: wallet.publicKey,
|
|
93
|
+
bus: new web3_js_1.PublicKey('BZJ2xppmny6ME3NkAgu2SMZB2mwS5xboX9n6VsSyGYFJ'),
|
|
94
|
+
digest: [
|
|
95
|
+
149, 32, 37, 176, 97, 139, 13, 182, 108, 28, 66, 160, 137, 156, 204, 249
|
|
96
|
+
],
|
|
97
|
+
nonce: [217, 46, 186, 232, 162, 139, 46, 186]
|
|
98
|
+
}, {
|
|
99
|
+
skipPreflight: true,
|
|
100
|
+
microLamports: 10000
|
|
101
|
+
});
|
|
102
|
+
console.log(response);
|
|
103
|
+
});
|
|
@@ -447,6 +447,67 @@
|
|
|
447
447
|
}
|
|
448
448
|
]
|
|
449
449
|
},
|
|
450
|
+
{
|
|
451
|
+
"name": "mine_ore",
|
|
452
|
+
"discriminator": [170, 66, 140, 123, 15, 20, 224, 194],
|
|
453
|
+
"accounts": [
|
|
454
|
+
{
|
|
455
|
+
"name": "signer",
|
|
456
|
+
"writable": true,
|
|
457
|
+
"signer": true
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"name": "user",
|
|
461
|
+
"writable": true,
|
|
462
|
+
"pda": {
|
|
463
|
+
"seeds": [
|
|
464
|
+
{
|
|
465
|
+
"kind": "const",
|
|
466
|
+
"value": [117, 115, 101, 114]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"kind": "account",
|
|
470
|
+
"path": "signer"
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"name": "proof_info",
|
|
477
|
+
"writable": true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"name": "bus",
|
|
481
|
+
"writable": true
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
"name": "ore_program"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"name": "config_program"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"name": "sysvar_hashes_info"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"name": "sysvar_instructions_info"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"name": "system_program",
|
|
497
|
+
"address": "11111111111111111111111111111111"
|
|
498
|
+
}
|
|
499
|
+
],
|
|
500
|
+
"args": [
|
|
501
|
+
{
|
|
502
|
+
"name": "args",
|
|
503
|
+
"type": {
|
|
504
|
+
"defined": {
|
|
505
|
+
"name": "MineArgs"
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
},
|
|
450
511
|
{
|
|
451
512
|
"name": "open_ore",
|
|
452
513
|
"discriminator": [120, 233, 125, 197, 12, 153, 25, 229],
|
|
@@ -1302,6 +1363,26 @@
|
|
|
1302
1363
|
]
|
|
1303
1364
|
}
|
|
1304
1365
|
},
|
|
1366
|
+
{
|
|
1367
|
+
"name": "MineArgs",
|
|
1368
|
+
"type": {
|
|
1369
|
+
"kind": "struct",
|
|
1370
|
+
"fields": [
|
|
1371
|
+
{
|
|
1372
|
+
"name": "digest",
|
|
1373
|
+
"type": {
|
|
1374
|
+
"array": ["u8", 16]
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
"name": "nonce",
|
|
1379
|
+
"type": {
|
|
1380
|
+
"array": ["u8", 8]
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
]
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1305
1386
|
{
|
|
1306
1387
|
"name": "OpenPositionArgs",
|
|
1307
1388
|
"type": {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
2
2
|
export type RpcOptions = {
|
|
3
3
|
skipPreflight?: boolean;
|
|
4
4
|
microLamports?: number;
|
|
@@ -10,7 +10,14 @@ export type CreateUserArgs = {
|
|
|
10
10
|
};
|
|
11
11
|
export type OpenOreArgs = {
|
|
12
12
|
user: PublicKey;
|
|
13
|
-
payer:
|
|
13
|
+
payer: Keypair;
|
|
14
14
|
name: string;
|
|
15
15
|
referralName: string;
|
|
16
16
|
};
|
|
17
|
+
export type MineOreArgs = {
|
|
18
|
+
user: PublicKey;
|
|
19
|
+
payer: PublicKey;
|
|
20
|
+
bus: PublicKey;
|
|
21
|
+
digest: number[];
|
|
22
|
+
nonce: number[];
|
|
23
|
+
};
|
|
@@ -426,6 +426,67 @@ export type TriadProtocol = {
|
|
|
426
426
|
}
|
|
427
427
|
];
|
|
428
428
|
},
|
|
429
|
+
{
|
|
430
|
+
name: 'mineOre';
|
|
431
|
+
discriminator: [170, 66, 140, 123, 15, 20, 224, 194];
|
|
432
|
+
accounts: [
|
|
433
|
+
{
|
|
434
|
+
name: 'signer';
|
|
435
|
+
writable: true;
|
|
436
|
+
signer: true;
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: 'user';
|
|
440
|
+
writable: true;
|
|
441
|
+
pda: {
|
|
442
|
+
seeds: [
|
|
443
|
+
{
|
|
444
|
+
kind: 'const';
|
|
445
|
+
value: [117, 115, 101, 114];
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
kind: 'account';
|
|
449
|
+
path: 'signer';
|
|
450
|
+
}
|
|
451
|
+
];
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: 'proofInfo';
|
|
456
|
+
writable: true;
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: 'bus';
|
|
460
|
+
writable: true;
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: 'oreProgram';
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: 'configProgram';
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
name: 'sysvarHashesInfo';
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: 'sysvarInstructionsInfo';
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: 'systemProgram';
|
|
476
|
+
address: '11111111111111111111111111111111';
|
|
477
|
+
}
|
|
478
|
+
];
|
|
479
|
+
args: [
|
|
480
|
+
{
|
|
481
|
+
name: 'args';
|
|
482
|
+
type: {
|
|
483
|
+
defined: {
|
|
484
|
+
name: 'mineArgs';
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
];
|
|
489
|
+
},
|
|
429
490
|
{
|
|
430
491
|
name: 'openOre';
|
|
431
492
|
discriminator: [120, 233, 125, 197, 12, 153, 25, 229];
|
|
@@ -1214,6 +1275,26 @@ export type TriadProtocol = {
|
|
|
1214
1275
|
];
|
|
1215
1276
|
};
|
|
1216
1277
|
},
|
|
1278
|
+
{
|
|
1279
|
+
name: 'mineArgs';
|
|
1280
|
+
type: {
|
|
1281
|
+
kind: 'struct';
|
|
1282
|
+
fields: [
|
|
1283
|
+
{
|
|
1284
|
+
name: 'digest';
|
|
1285
|
+
type: {
|
|
1286
|
+
array: ['u8', 16];
|
|
1287
|
+
};
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
name: 'nonce';
|
|
1291
|
+
type: {
|
|
1292
|
+
array: ['u8', 8];
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
];
|
|
1296
|
+
};
|
|
1297
|
+
},
|
|
1217
1298
|
{
|
|
1218
1299
|
name: 'openPositionArgs';
|
|
1219
1300
|
type: {
|
|
@@ -7,3 +7,4 @@ export declare const TTRIAD_DECIMALS = 6;
|
|
|
7
7
|
export declare const TTRIAD_MINT = "t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV";
|
|
8
8
|
export declare const TTRIAD_FEE = 2;
|
|
9
9
|
export declare const ORE_PROGRAM_ID = "oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ";
|
|
10
|
+
export declare const NOOP_PROGRAM_ID = "noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ORE_PROGRAM_ID = exports.TTRIAD_FEE = exports.TTRIAD_MINT = exports.TTRIAD_DECIMALS = exports.STAKE_SEASON = exports.VERIFIER = exports.ADMIN = exports.ATA_PROGRAM_ID = exports.TRIAD_PROTOCOL_PROGRAM_ID = void 0;
|
|
3
|
+
exports.NOOP_PROGRAM_ID = exports.ORE_PROGRAM_ID = exports.TTRIAD_FEE = exports.TTRIAD_MINT = exports.TTRIAD_DECIMALS = exports.STAKE_SEASON = exports.VERIFIER = exports.ADMIN = exports.ATA_PROGRAM_ID = exports.TRIAD_PROTOCOL_PROGRAM_ID = void 0;
|
|
4
4
|
exports.TRIAD_PROTOCOL_PROGRAM_ID = 'TRDwq3BN4mP3m9KsuNUWSN6QDff93VKGSwE95Jbr9Ss';
|
|
5
5
|
exports.ATA_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
6
6
|
exports.ADMIN = '';
|
|
@@ -10,3 +10,4 @@ exports.TTRIAD_DECIMALS = 6;
|
|
|
10
10
|
exports.TTRIAD_MINT = 't3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV';
|
|
11
11
|
exports.TTRIAD_FEE = 2;
|
|
12
12
|
exports.ORE_PROGRAM_ID = 'oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ';
|
|
13
|
+
exports.NOOP_PROGRAM_ID = 'noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW';
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const getNFTRewardsAddressSync: (programId: PublicKey, stake: Pub
|
|
|
13
13
|
export declare const getATASync: (address: PublicKey, Mint: PublicKey) => PublicKey;
|
|
14
14
|
export declare const getUserAddressSync: (programId: PublicKey, wallet: PublicKey) => PublicKey;
|
|
15
15
|
export declare const getProofOreAddressSync: (wallet: PublicKey) => PublicKey;
|
|
16
|
+
export declare const configOreProgramAddressSync: () => PublicKey;
|
|
16
17
|
export declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
|
|
17
18
|
export declare const formatStakeVault: (stakeVault: any) => StakeVaultResponse;
|
|
18
19
|
export declare const formatStake: (stake: any) => StakeResponse;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.calculateAPR = exports.calculateTotalMultiplier = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.formatNumber = exports.getProofOreAddressSync = exports.getUserAddressSync = exports.getATASync = exports.getNFTRewardsAddressSync = exports.getStakeAddressSync = exports.getStakeVaultAddressSync = exports.getUserPositionAddressSync = exports.getTokenVaultAddressSync = exports.getVaultAddressSync = exports.decodeString = exports.encodeString = exports.getTickerAddressSync = void 0;
|
|
26
|
+
exports.calculateAPR = exports.calculateTotalMultiplier = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.formatNumber = exports.configOreProgramAddressSync = exports.getProofOreAddressSync = exports.getUserAddressSync = exports.getATASync = exports.getNFTRewardsAddressSync = exports.getStakeAddressSync = exports.getStakeVaultAddressSync = exports.getUserPositionAddressSync = exports.getTokenVaultAddressSync = exports.getVaultAddressSync = exports.decodeString = exports.encodeString = exports.getTickerAddressSync = void 0;
|
|
27
27
|
const stake_1 = require("./../types/stake");
|
|
28
28
|
const web3_js_1 = require("@solana/web3.js");
|
|
29
29
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
@@ -101,6 +101,11 @@ const getProofOreAddressSync = (wallet) => {
|
|
|
101
101
|
return ProofPDA;
|
|
102
102
|
};
|
|
103
103
|
exports.getProofOreAddressSync = getProofOreAddressSync;
|
|
104
|
+
const configOreProgramAddressSync = () => {
|
|
105
|
+
const [ProofPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('config')], new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID));
|
|
106
|
+
return ProofPDA;
|
|
107
|
+
};
|
|
108
|
+
exports.configOreProgramAddressSync = configOreProgramAddressSync;
|
|
104
109
|
const formatNumber = (number, decimals = 6) => {
|
|
105
110
|
return Number(number.toString()) / Math.pow(10, decimals);
|
|
106
111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triadxyz/triad-protocol",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6-beta",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@coral-xyz/anchor": "0.30.0",
|
|
36
|
-
"@solana/spl-token": "0.4.
|
|
36
|
+
"@solana/spl-token": "0.4.1",
|
|
37
37
|
"@solana/web3.js": "1.89.1",
|
|
38
38
|
"axios": "^1.5.1",
|
|
39
39
|
"base64-js": "^1.5.1",
|