@triadxyz/triad-protocol 0.4.3-beta → 0.4.5-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 -3
- package/dist/index.js +79 -2
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -96
- package/dist/types/idl_triad_protocol.json +84 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/triad_protocol.d.ts +84 -0
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +6 -1
- package/package.json +2 -2
- package/dist/ore.d.ts +0 -10
- package/dist/ore.js +0 -40
- package/dist/utils/stake-season-1/rarity.json +0 -8832
package/dist/index.d.ts
CHANGED
|
@@ -4,15 +4,13 @@ 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';
|
|
8
|
-
import Ore from './ore';
|
|
7
|
+
import { CreateUserArgs, MineOreArgs, OpenOreArgs, RpcOptions } from './types';
|
|
9
8
|
export default class TriadProtocolClient {
|
|
10
9
|
program: Program<TriadProtocol>;
|
|
11
10
|
provider: AnchorProvider;
|
|
12
11
|
ticker: Ticker;
|
|
13
12
|
vault: Vault;
|
|
14
13
|
stake: Stake;
|
|
15
|
-
ore: Ore;
|
|
16
14
|
constructor(connection: Connection, wallet: Wallet);
|
|
17
15
|
/**
|
|
18
16
|
* Get User by wallet
|
|
@@ -43,4 +41,6 @@ export default class TriadProtocolClient {
|
|
|
43
41
|
*
|
|
44
42
|
*/
|
|
45
43
|
createUser: ({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions) => Promise<string>;
|
|
44
|
+
openOre: ({ user, payer, name, referralName }: OpenOreArgs, options?: RpcOptions) => Promise<string>;
|
|
45
|
+
mineOre: ({ user, payer, bus, digest, nonce }: MineOreArgs, options?: RpcOptions) => Promise<string>;
|
|
46
46
|
}
|
package/dist/index.js
CHANGED
|
@@ -19,7 +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
|
|
22
|
+
const constants_1 = require("./utils/constants");
|
|
23
23
|
class TriadProtocolClient {
|
|
24
24
|
constructor(connection, wallet) {
|
|
25
25
|
/**
|
|
@@ -114,12 +114,89 @@ class TriadProtocolClient {
|
|
|
114
114
|
}
|
|
115
115
|
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
116
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
|
+
});
|
|
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(yield this.program.methods
|
|
166
|
+
.mineOre({
|
|
167
|
+
digest,
|
|
168
|
+
nonce
|
|
169
|
+
})
|
|
170
|
+
.accounts({
|
|
171
|
+
signer: user,
|
|
172
|
+
bus,
|
|
173
|
+
configProgram: (0, helpers_1.configOreProgramAddressSync)(),
|
|
174
|
+
proofInfo: proofInfoPDA,
|
|
175
|
+
sysvarHashesInfo: new web3_js_1.PublicKey('SysvarS1otHashes111111111111111111111111111'),
|
|
176
|
+
sysvarInstructionsInfo: new web3_js_1.PublicKey('Sysvar1nstructions1111111111111111111111111'),
|
|
177
|
+
oreProgram: new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID)
|
|
178
|
+
})
|
|
179
|
+
.instruction());
|
|
180
|
+
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
181
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
182
|
+
microLamports: options.microLamports
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
186
|
+
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
187
|
+
instructions: ixs,
|
|
188
|
+
recentBlockhash: blockhash,
|
|
189
|
+
payerKey: payer
|
|
190
|
+
}).compileToV0Message()), [], {
|
|
191
|
+
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
192
|
+
commitment: 'confirmed'
|
|
193
|
+
});
|
|
194
|
+
});
|
|
117
195
|
this.provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
|
|
118
196
|
this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
|
|
119
197
|
this.ticker = new ticker_1.default(this.program, this.provider);
|
|
120
198
|
this.vault = new vault_1.default(this.program, this.provider);
|
|
121
199
|
this.stake = new stake_1.default(this.program, this.provider);
|
|
122
|
-
this.ore = new ore_1.default(this.program, this.provider);
|
|
123
200
|
}
|
|
124
201
|
}
|
|
125
202
|
exports.default = TriadProtocolClient;
|
package/dist/test.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test.js
CHANGED
|
@@ -1,96 +0,0 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
17
|
-
const index_1 = __importDefault(require("./index"));
|
|
18
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
19
|
-
const constants_1 = require("./utils/constants");
|
|
20
|
-
const rarity_json_1 = __importDefault(require("./utils/stake-season-1/rarity.json"));
|
|
21
|
-
const getRarity_1 = require("./utils/getRarity");
|
|
22
|
-
const axios_1 = __importDefault(require("axios"));
|
|
23
|
-
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
|
|
24
|
-
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
25
|
-
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
26
|
-
const connection = new web3_js_1.Connection(rpc_file.toString(), 'confirmed');
|
|
27
|
-
const wallet = new anchor_1.Wallet(keypair);
|
|
28
|
-
const triadProtocol = new index_1.default(connection, wallet);
|
|
29
|
-
const getStake = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const response = yield triadProtocol.stake.getStakes(constants_1.STAKE_SEASON);
|
|
31
|
-
let available = 0;
|
|
32
|
-
let items = 0;
|
|
33
|
-
for (const stake of response) {
|
|
34
|
-
const getRank = (0, getRarity_1.getRarityRank)(rarity_json_1.default, stake.mint, stake.name);
|
|
35
|
-
try {
|
|
36
|
-
available += yield triadProtocol.stake.getStakeRewards({
|
|
37
|
-
wallet: new web3_js_1.PublicKey(stake.authority),
|
|
38
|
-
nftName: stake.name,
|
|
39
|
-
stakeVault: constants_1.STAKE_SEASON,
|
|
40
|
-
rank: getRank,
|
|
41
|
-
collections: 1
|
|
42
|
-
});
|
|
43
|
-
items += 1;
|
|
44
|
-
console.log(items);
|
|
45
|
-
console.log(available);
|
|
46
|
-
}
|
|
47
|
-
catch (e) { }
|
|
48
|
-
}
|
|
49
|
-
console.log(available);
|
|
50
|
-
console.log(items);
|
|
51
|
-
console.log(response.length);
|
|
52
|
-
});
|
|
53
|
-
const deposit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const response = yield triadProtocol.stake.depositStakeRewards({
|
|
55
|
-
wallet: wallet.publicKey,
|
|
56
|
-
stakeVault: constants_1.STAKE_SEASON,
|
|
57
|
-
mint: new web3_js_1.PublicKey(constants_1.TTRIAD_MINT),
|
|
58
|
-
amount: new anchor_1.BN(192388 * Math.pow(10, 6))
|
|
59
|
-
});
|
|
60
|
-
console.log(response);
|
|
61
|
-
});
|
|
62
|
-
const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const response = yield triadProtocol.stake.getStakeVaultByName(constants_1.STAKE_SEASON);
|
|
64
|
-
console.log(response);
|
|
65
|
-
});
|
|
66
|
-
const getStakeByWallet = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
const response = yield triadProtocol.stake.getStakeByWallet(new web3_js_1.PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'), constants_1.STAKE_SEASON, 1, rarity_json_1.default);
|
|
68
|
-
console.log(response);
|
|
69
|
-
});
|
|
70
|
-
const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
const response = (yield axios_1.default.get('https://api.triadfi.co/boost'))
|
|
72
|
-
.data;
|
|
73
|
-
const stakes = yield triadProtocol.stake.getStakes(constants_1.STAKE_SEASON);
|
|
74
|
-
const update = [];
|
|
75
|
-
for (const stake of stakes) {
|
|
76
|
-
if (response.includes(stake.mint) && !stake.boost) {
|
|
77
|
-
update.push({ name: stake.name, wallet: stake.authority });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
console.log(update);
|
|
81
|
-
const updateBoostResponse = yield triadProtocol.stake.updateBoost({
|
|
82
|
-
wallet: wallet.publicKey,
|
|
83
|
-
stakeVault: constants_1.STAKE_SEASON,
|
|
84
|
-
nfts: update,
|
|
85
|
-
boost: true
|
|
86
|
-
});
|
|
87
|
-
console.log(updateBoostResponse);
|
|
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,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": "bus",
|
|
477
|
+
"writable": true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"name": "proof_info",
|
|
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,29 @@
|
|
|
1302
1363
|
]
|
|
1303
1364
|
}
|
|
1304
1365
|
},
|
|
1366
|
+
{
|
|
1367
|
+
"name": "MineArgs",
|
|
1368
|
+
"repr": {
|
|
1369
|
+
"kind": "c"
|
|
1370
|
+
},
|
|
1371
|
+
"type": {
|
|
1372
|
+
"kind": "struct",
|
|
1373
|
+
"fields": [
|
|
1374
|
+
{
|
|
1375
|
+
"name": "digest",
|
|
1376
|
+
"type": {
|
|
1377
|
+
"array": ["u8", 16]
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
"name": "nonce",
|
|
1382
|
+
"type": {
|
|
1383
|
+
"array": ["u8", 8]
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
]
|
|
1387
|
+
}
|
|
1388
|
+
},
|
|
1305
1389
|
{
|
|
1306
1390
|
"name": "OpenPositionArgs",
|
|
1307
1391
|
"type": {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,3 +8,16 @@ export type CreateUserArgs = {
|
|
|
8
8
|
name: string;
|
|
9
9
|
referral?: PublicKey;
|
|
10
10
|
};
|
|
11
|
+
export type OpenOreArgs = {
|
|
12
|
+
user: PublicKey;
|
|
13
|
+
payer: PublicKey;
|
|
14
|
+
name: string;
|
|
15
|
+
referralName: string;
|
|
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: 'bus';
|
|
456
|
+
writable: true;
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: 'proofInfo';
|
|
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,29 @@ export type TriadProtocol = {
|
|
|
1214
1275
|
];
|
|
1215
1276
|
};
|
|
1216
1277
|
},
|
|
1278
|
+
{
|
|
1279
|
+
name: 'mineArgs';
|
|
1280
|
+
repr: {
|
|
1281
|
+
kind: 'c';
|
|
1282
|
+
};
|
|
1283
|
+
type: {
|
|
1284
|
+
kind: 'struct';
|
|
1285
|
+
fields: [
|
|
1286
|
+
{
|
|
1287
|
+
name: 'digest';
|
|
1288
|
+
type: {
|
|
1289
|
+
array: ['u8', 16];
|
|
1290
|
+
};
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
name: 'nonce';
|
|
1294
|
+
type: {
|
|
1295
|
+
array: ['u8', 8];
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
];
|
|
1299
|
+
};
|
|
1300
|
+
},
|
|
1217
1301
|
{
|
|
1218
1302
|
name: 'openPositionArgs';
|
|
1219
1303
|
type: {
|
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.5-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",
|
package/dist/ore.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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;
|