@triadxyz/triad-protocol 0.4.1-beta → 0.4.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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/ore.d.ts +10 -0
- package/dist/ore.js +40 -0
- package/dist/stake.js +1 -1
- package/dist/test.js +12 -3
- package/dist/types/idl_triad_protocol.json +46 -0
- package/dist/types/triad_protocol.d.ts +46 -0
- package/dist/utils/constants.d.ts +1 -26
- package/dist/utils/constants.js +2 -9
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +6 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,14 @@ import Ticker from './ticker';
|
|
|
5
5
|
import Vault from './vault';
|
|
6
6
|
import Stake from './stake';
|
|
7
7
|
import { CreateUserArgs, RpcOptions } from './types';
|
|
8
|
+
import Ore from './ore';
|
|
8
9
|
export default class TriadProtocolClient {
|
|
9
10
|
program: Program<TriadProtocol>;
|
|
10
11
|
provider: AnchorProvider;
|
|
11
12
|
ticker: Ticker;
|
|
12
13
|
vault: Vault;
|
|
13
14
|
stake: Stake;
|
|
15
|
+
ore: Ore;
|
|
14
16
|
constructor(connection: Connection, wallet: Wallet);
|
|
15
17
|
/**
|
|
16
18
|
* Get User by wallet
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const ticker_1 = __importDefault(require("./ticker"));
|
|
|
19
19
|
const vault_1 = __importDefault(require("./vault"));
|
|
20
20
|
const helpers_1 = require("./utils/helpers");
|
|
21
21
|
const stake_1 = __importDefault(require("./stake"));
|
|
22
|
+
const ore_1 = __importDefault(require("./ore"));
|
|
22
23
|
class TriadProtocolClient {
|
|
23
24
|
constructor(connection, wallet) {
|
|
24
25
|
/**
|
|
@@ -118,6 +119,7 @@ class TriadProtocolClient {
|
|
|
118
119
|
this.ticker = new ticker_1.default(this.program, this.provider);
|
|
119
120
|
this.vault = new vault_1.default(this.program, this.provider);
|
|
120
121
|
this.stake = new stake_1.default(this.program, this.provider);
|
|
122
|
+
this.ore = new ore_1.default(this.program, this.provider);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
exports.default = TriadProtocolClient;
|
package/dist/ore.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { TriadProtocol } from './types/triad_protocol';
|
|
4
|
+
import { RpcOptions } from './types';
|
|
5
|
+
export default class Ore {
|
|
6
|
+
program: Program<TriadProtocol>;
|
|
7
|
+
provider: AnchorProvider;
|
|
8
|
+
constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
|
|
9
|
+
openOre: (user: PublicKey, options?: RpcOptions) => Promise<string>;
|
|
10
|
+
}
|
package/dist/ore.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
13
|
+
const helpers_1 = require("./utils/helpers");
|
|
14
|
+
const constants_1 = require("./utils/constants");
|
|
15
|
+
class Ore {
|
|
16
|
+
constructor(program, provider) {
|
|
17
|
+
this.openOre = (user, options) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const userPDA = (0, helpers_1.getUserAddressSync)(this.program.programId, user);
|
|
19
|
+
const proofInfoPDA = (0, helpers_1.getProofOreAddressSync)(userPDA);
|
|
20
|
+
const method = this.program.methods.openOre().accounts({
|
|
21
|
+
signer: user,
|
|
22
|
+
minerInfo: userPDA,
|
|
23
|
+
proofInfo: proofInfoPDA,
|
|
24
|
+
sysvarHashesInfo: new web3_js_1.PublicKey('SysvarS1otHashes111111111111111111111111111'),
|
|
25
|
+
oreProgram: new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID)
|
|
26
|
+
});
|
|
27
|
+
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
28
|
+
method.postInstructions([
|
|
29
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
30
|
+
microLamports: options.microLamports
|
|
31
|
+
})
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
35
|
+
});
|
|
36
|
+
this.provider = provider;
|
|
37
|
+
this.program = program;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = Ore;
|
package/dist/stake.js
CHANGED
|
@@ -91,7 +91,7 @@ class Stake {
|
|
|
91
91
|
*/
|
|
92
92
|
getStakeByWallet(wallet, stakeVault, collections, ranks) {
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const response = yield this.getStakes(stakeVault);
|
|
94
|
+
const response = (yield this.getStakes(stakeVault)).filter((item) => item.authority === wallet.toBase58());
|
|
95
95
|
const data = [];
|
|
96
96
|
for (const stake of response) {
|
|
97
97
|
const getRank = (0, getRarity_1.getRarityRank)(ranks, stake.mint, stake.name);
|
package/dist/test.js
CHANGED
|
@@ -63,7 +63,7 @@ const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
63
63
|
const response = yield triadProtocol.stake.getStakeVaultByName(constants_1.STAKE_SEASON);
|
|
64
64
|
console.log(response);
|
|
65
65
|
});
|
|
66
|
-
const
|
|
66
|
+
const getStakeByWallet = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
67
|
const response = yield triadProtocol.stake.getStakeByWallet(new web3_js_1.PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'), constants_1.STAKE_SEASON, 1, rarity_json_1.default);
|
|
68
68
|
console.log(response);
|
|
69
69
|
});
|
|
@@ -77,11 +77,20 @@ const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
77
77
|
update.push({ name: stake.name, wallet: stake.authority });
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
console.log(update);
|
|
81
|
+
const updateBoostResponse = yield triadProtocol.stake.updateBoost({
|
|
81
82
|
wallet: wallet.publicKey,
|
|
82
83
|
stakeVault: constants_1.STAKE_SEASON,
|
|
83
84
|
nfts: update,
|
|
84
85
|
boost: true
|
|
85
86
|
});
|
|
86
|
-
console.log(
|
|
87
|
+
console.log(updateBoostResponse);
|
|
87
88
|
});
|
|
89
|
+
const openOre = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const response = yield triadProtocol.ore.openOre(wallet.publicKey, {
|
|
91
|
+
microLamports: 2000,
|
|
92
|
+
skipPreflight: true
|
|
93
|
+
});
|
|
94
|
+
console.log(response);
|
|
95
|
+
});
|
|
96
|
+
openOre();
|
|
@@ -447,6 +447,52 @@
|
|
|
447
447
|
}
|
|
448
448
|
]
|
|
449
449
|
},
|
|
450
|
+
{
|
|
451
|
+
"name": "open_ore",
|
|
452
|
+
"discriminator": [120, 233, 125, 197, 12, 153, 25, 229],
|
|
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": "miner_info",
|
|
477
|
+
"writable": true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"name": "proof_info",
|
|
481
|
+
"writable": true
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
"name": "ore_program"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"name": "sysvar_hashes_info"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"name": "system_program",
|
|
491
|
+
"address": "11111111111111111111111111111111"
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
"args": []
|
|
495
|
+
},
|
|
450
496
|
{
|
|
451
497
|
"name": "open_position",
|
|
452
498
|
"discriminator": [135, 128, 47, 77, 15, 152, 240, 49],
|
|
@@ -426,6 +426,52 @@ export type TriadProtocol = {
|
|
|
426
426
|
}
|
|
427
427
|
];
|
|
428
428
|
},
|
|
429
|
+
{
|
|
430
|
+
name: 'openOre';
|
|
431
|
+
discriminator: [120, 233, 125, 197, 12, 153, 25, 229];
|
|
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: 'minerInfo';
|
|
456
|
+
writable: true;
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: 'proofInfo';
|
|
460
|
+
writable: true;
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: 'oreProgram';
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: 'sysvarHashesInfo';
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
name: 'systemProgram';
|
|
470
|
+
address: '11111111111111111111111111111111';
|
|
471
|
+
}
|
|
472
|
+
];
|
|
473
|
+
args: [];
|
|
474
|
+
},
|
|
429
475
|
{
|
|
430
476
|
name: 'openPosition';
|
|
431
477
|
discriminator: [135, 128, 47, 77, 15, 152, 240, 49];
|
|
@@ -6,29 +6,4 @@ export declare const STAKE_SEASON = "Triad Share 1";
|
|
|
6
6
|
export declare const TTRIAD_DECIMALS = 6;
|
|
7
7
|
export declare const TTRIAD_MINT = "t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV";
|
|
8
8
|
export declare const TTRIAD_FEE = 2;
|
|
9
|
-
export declare const
|
|
10
|
-
mythic: {
|
|
11
|
-
min: number;
|
|
12
|
-
max: number;
|
|
13
|
-
};
|
|
14
|
-
legendary: {
|
|
15
|
-
min: number;
|
|
16
|
-
max: number;
|
|
17
|
-
};
|
|
18
|
-
epic: {
|
|
19
|
-
min: number;
|
|
20
|
-
max: number;
|
|
21
|
-
};
|
|
22
|
-
rare: {
|
|
23
|
-
min: number;
|
|
24
|
-
max: number;
|
|
25
|
-
};
|
|
26
|
-
uncommon: {
|
|
27
|
-
min: number;
|
|
28
|
-
max: number;
|
|
29
|
-
};
|
|
30
|
-
common: {
|
|
31
|
-
min: number;
|
|
32
|
-
max: number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
9
|
+
export declare const ORE_PROGRAM_ID = "oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
|
4
4
|
exports.TRIAD_PROTOCOL_PROGRAM_ID = 'TRDwq3BN4mP3m9KsuNUWSN6QDff93VKGSwE95Jbr9Ss';
|
|
5
5
|
exports.ATA_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
6
6
|
exports.ADMIN = '';
|
|
@@ -9,11 +9,4 @@ exports.STAKE_SEASON = 'Triad Share 1';
|
|
|
9
9
|
exports.TTRIAD_DECIMALS = 6;
|
|
10
10
|
exports.TTRIAD_MINT = 't3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV';
|
|
11
11
|
exports.TTRIAD_FEE = 2;
|
|
12
|
-
exports.
|
|
13
|
-
mythic: { min: 1, max: 18 },
|
|
14
|
-
legendary: { min: 19, max: 91 },
|
|
15
|
-
epic: { min: 92, max: 275 },
|
|
16
|
-
rare: { min: 276, max: 643 },
|
|
17
|
-
uncommon: { min: 644, max: 1103 },
|
|
18
|
-
common: { min: 1104, max: 1839 }
|
|
19
|
-
};
|
|
12
|
+
exports.ORE_PROGRAM_ID = 'oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ';
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const getStakeAddressSync: (programId: PublicKey, wallet: PublicK
|
|
|
12
12
|
export declare const getNFTRewardsAddressSync: (programId: PublicKey, stake: PublicKey) => PublicKey;
|
|
13
13
|
export declare const getATASync: (address: PublicKey, Mint: PublicKey) => PublicKey;
|
|
14
14
|
export declare const getUserAddressSync: (programId: PublicKey, wallet: PublicKey) => PublicKey;
|
|
15
|
+
export declare const getProofOreAddressSync: (wallet: PublicKey) => PublicKey;
|
|
15
16
|
export declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
|
|
16
17
|
export declare const formatStakeVault: (stakeVault: any) => StakeVaultResponse;
|
|
17
18
|
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.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.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"));
|
|
@@ -96,6 +96,11 @@ const getUserAddressSync = (programId, wallet) => {
|
|
|
96
96
|
return StakePDA;
|
|
97
97
|
};
|
|
98
98
|
exports.getUserAddressSync = getUserAddressSync;
|
|
99
|
+
const getProofOreAddressSync = (wallet) => {
|
|
100
|
+
const [ProofPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('proof'), wallet.toBuffer()], new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID));
|
|
101
|
+
return ProofPDA;
|
|
102
|
+
};
|
|
103
|
+
exports.getProofOreAddressSync = getProofOreAddressSync;
|
|
99
104
|
const formatNumber = (number, decimals = 6) => {
|
|
100
105
|
return Number(number.toString()) / Math.pow(10, decimals);
|
|
101
106
|
};
|