@triadxyz/triad-protocol 0.4.2-beta → 0.4.4-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 +45 -0
- package/dist/test.js +3 -3
- package/dist/types/idl_triad_protocol.json +46 -0
- package/dist/types/index.d.ts +6 -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
|
@@ -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, RpcOptions } from './types';
|
|
7
|
+
import { CreateUserArgs, OpenOreArgs, RpcOptions } from './types';
|
|
8
8
|
export default class TriadProtocolClient {
|
|
9
9
|
program: Program<TriadProtocol>;
|
|
10
10
|
provider: AnchorProvider;
|
|
@@ -41,4 +41,5 @@ export default class TriadProtocolClient {
|
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
43
|
createUser: ({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions) => Promise<string>;
|
|
44
|
+
openOre: ({ user, payer, name, referralName }: OpenOreArgs, options?: RpcOptions) => Promise<string>;
|
|
44
45
|
}
|
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 constants_1 = require("./utils/constants");
|
|
22
23
|
class TriadProtocolClient {
|
|
23
24
|
constructor(connection, wallet) {
|
|
24
25
|
/**
|
|
@@ -113,6 +114,50 @@ class TriadProtocolClient {
|
|
|
113
114
|
}
|
|
114
115
|
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
115
116
|
};
|
|
117
|
+
this.openOre = ({ user, payer, name, referralName }, options) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const userPDA = (0, helpers_1.getUserAddressSync)(this.program.programId, user);
|
|
119
|
+
const ixs = [];
|
|
120
|
+
try {
|
|
121
|
+
yield this.program.account.user.fetch(userPDA);
|
|
122
|
+
}
|
|
123
|
+
catch (_d) {
|
|
124
|
+
const referral = yield this.getRefferal(referralName);
|
|
125
|
+
ixs.push(yield this.program.methods
|
|
126
|
+
.createUser({
|
|
127
|
+
name
|
|
128
|
+
})
|
|
129
|
+
.accounts({
|
|
130
|
+
signer: user,
|
|
131
|
+
referral
|
|
132
|
+
})
|
|
133
|
+
.instruction());
|
|
134
|
+
}
|
|
135
|
+
const proofInfoPDA = (0, helpers_1.getProofOreAddressSync)(userPDA);
|
|
136
|
+
ixs.push(yield this.program.methods
|
|
137
|
+
.openOre()
|
|
138
|
+
.accounts({
|
|
139
|
+
signer: user,
|
|
140
|
+
minerInfo: userPDA,
|
|
141
|
+
proofInfo: proofInfoPDA,
|
|
142
|
+
sysvarHashesInfo: new web3_js_1.PublicKey('SysvarS1otHashes111111111111111111111111111'),
|
|
143
|
+
oreProgram: new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID)
|
|
144
|
+
})
|
|
145
|
+
.instruction());
|
|
146
|
+
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
147
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
148
|
+
microLamports: options.microLamports
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
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
|
|
156
|
+
}).compileToV0Message()), [], {
|
|
157
|
+
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
158
|
+
commitment: 'confirmed'
|
|
159
|
+
});
|
|
160
|
+
});
|
|
116
161
|
this.provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
|
|
117
162
|
this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
|
|
118
163
|
this.ticker = new ticker_1.default(this.program, this.provider);
|
package/dist/test.js
CHANGED
|
@@ -67,7 +67,6 @@ 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
|
});
|
|
70
|
-
getStakeByWallet();
|
|
71
70
|
const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
71
|
const response = (yield axios_1.default.get('https://api.triadfi.co/boost'))
|
|
73
72
|
.data;
|
|
@@ -78,11 +77,12 @@ const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
78
77
|
update.push({ name: stake.name, wallet: stake.authority });
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
console.log(update);
|
|
81
|
+
const updateBoostResponse = yield triadProtocol.stake.updateBoost({
|
|
82
82
|
wallet: wallet.publicKey,
|
|
83
83
|
stakeVault: constants_1.STAKE_SEASON,
|
|
84
84
|
nfts: update,
|
|
85
85
|
boost: true
|
|
86
86
|
});
|
|
87
|
-
console.log(
|
|
87
|
+
console.log(updateBoostResponse);
|
|
88
88
|
});
|
|
@@ -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],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
};
|