@triadxyz/triad-protocol 0.1.3-alpha.2 → 0.1.3-alpha.4

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/stake.d.ts CHANGED
@@ -112,7 +112,7 @@ export default class Stake {
112
112
  };
113
113
  }): Promise<string>;
114
114
  /**
115
- * Update a ticker's price
115
+ * Initialize Stake Vault
116
116
  * @param name - The ticker's name
117
117
  * @param amount - Reward amount
118
118
  * @param slots - Amount available to users joining the vault
package/dist/stake.js CHANGED
@@ -34,7 +34,10 @@ class Stake {
34
34
  */
35
35
  stake({ name, wallet, mint, collections, rarity }) {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
+ const stakeVaultName = 'Triad Share 1';
37
38
  const FromAta = (0, helpers_1.getATASync)(wallet, mint);
39
+ const StakeVault = (0, helpers_1.getStakeVaultAddressSync)(this.program.programId, stakeVaultName);
40
+ const ToAta = (0, helpers_1.getATASync)(StakeVault, mint);
38
41
  let items = [];
39
42
  Object.keys(collections).forEach((key) => {
40
43
  if (collections[key]) {
@@ -45,18 +48,22 @@ class Stake {
45
48
  .stake({
46
49
  name,
47
50
  collections: items,
48
- collection: 'Triad',
49
- rarity
51
+ rarity,
52
+ stakeVault: stakeVaultName
50
53
  })
51
54
  .accounts({
52
55
  signer: wallet,
53
- fromAta: FromAta
56
+ fromAta: FromAta,
57
+ toAta: ToAta,
58
+ mint: mint
54
59
  })
55
- .rpc();
60
+ .rpc({
61
+ skipPreflight: true
62
+ });
56
63
  });
57
64
  }
58
65
  /**
59
- * Update a ticker's price
66
+ * Initialize Stake Vault
60
67
  * @param name - The ticker's name
61
68
  * @param amount - Reward amount
62
69
  * @param slots - Amount available to users joining the vault
package/dist/test.js CHANGED
@@ -26,7 +26,7 @@ class Test {
26
26
  this.init = () => __awaiter(this, void 0, void 0, function* () { });
27
27
  this.initializeStakeVault = () => __awaiter(this, void 0, void 0, function* () {
28
28
  const reponse = yield this.triadProtocol.stake.initializeStakeVault({
29
- name: 'Rev Share 1',
29
+ name: 'Rev 1',
30
30
  collection: 'Triad',
31
31
  slots: new anchor_1.BN(1939),
32
32
  amount: new anchor_1.BN(1000000000)
@@ -35,7 +35,7 @@ class Test {
35
35
  });
36
36
  this.stakeNFT = () => __awaiter(this, void 0, void 0, function* () {
37
37
  const reponse = yield this.triadProtocol.stake.stake({
38
- name: 'Rev Share 1',
38
+ name: 'Triad 2',
39
39
  wallet: this.wallet.publicKey,
40
40
  collections: { alligators: true, coleta: true, undead: true, pyth: true },
41
41
  mint: new web3_js_1.PublicKey('DQ3Uq6GDX6HA99jVBaErtZcvhm1AsCpkB421a2MEDJ7B'),
@@ -394,7 +394,7 @@
394
394
  },
395
395
  {
396
396
  "kind": "arg",
397
- "path": "args.collection"
397
+ "path": "args.stake_vault"
398
398
  }
399
399
  ]
400
400
  }
@@ -409,31 +409,15 @@
409
409
  "value": [115, 116, 97, 107, 101]
410
410
  },
411
411
  {
412
- "kind": "account",
413
- "path": "signer"
414
- },
415
- {
416
- "kind": "account",
417
- "path": "mint"
412
+ "kind": "arg",
413
+ "path": "args.name"
418
414
  }
419
415
  ]
420
416
  }
421
417
  },
422
418
  {
423
419
  "name": "mint",
424
- "writable": true,
425
- "pda": {
426
- "seeds": [
427
- {
428
- "kind": "const",
429
- "value": [109, 105, 110, 116]
430
- },
431
- {
432
- "kind": "arg",
433
- "path": "args.name"
434
- }
435
- ]
436
- }
420
+ "writable": true
437
421
  },
438
422
  {
439
423
  "name": "from_ata",
@@ -441,26 +425,7 @@
441
425
  },
442
426
  {
443
427
  "name": "to_ata",
444
- "writable": true,
445
- "pda": {
446
- "seeds": [
447
- {
448
- "kind": "const",
449
- "value": [
450
- 115, 116, 97, 107, 101, 95, 118, 97, 117, 108, 116, 95, 116,
451
- 111, 107, 101, 110, 95, 97, 99, 99, 111, 117, 110, 116
452
- ]
453
- },
454
- {
455
- "kind": "account",
456
- "path": "mint"
457
- },
458
- {
459
- "kind": "account",
460
- "path": "stake_vault"
461
- }
462
- ]
463
- }
428
+ "writable": true
464
429
  },
465
430
  {
466
431
  "name": "token_program",
@@ -1046,7 +1011,7 @@
1046
1011
  }
1047
1012
  },
1048
1013
  {
1049
- "name": "collection",
1014
+ "name": "stake_vault",
1050
1015
  "type": "string"
1051
1016
  },
1052
1017
  {
@@ -446,7 +446,7 @@ export type TriadProtocol = {
446
446
  },
447
447
  {
448
448
  kind: 'arg';
449
- path: 'args.collection';
449
+ path: 'args.stake_vault';
450
450
  }
451
451
  ];
452
452
  };
@@ -461,12 +461,8 @@ export type TriadProtocol = {
461
461
  value: [115, 116, 97, 107, 101];
462
462
  },
463
463
  {
464
- kind: 'account';
465
- path: 'signer';
466
- },
467
- {
468
- kind: 'account';
469
- path: 'mint';
464
+ kind: 'arg';
465
+ path: 'args.name';
470
466
  }
471
467
  ];
472
468
  };
@@ -474,18 +470,6 @@ export type TriadProtocol = {
474
470
  {
475
471
  name: 'mint';
476
472
  writable: true;
477
- pda: {
478
- seeds: [
479
- {
480
- kind: 'const';
481
- value: [109, 105, 110, 116];
482
- },
483
- {
484
- kind: 'arg';
485
- path: 'args.name';
486
- }
487
- ];
488
- };
489
473
  },
490
474
  {
491
475
  name: 'fromAta';
@@ -494,48 +478,6 @@ export type TriadProtocol = {
494
478
  {
495
479
  name: 'toAta';
496
480
  writable: true;
497
- pda: {
498
- seeds: [
499
- {
500
- kind: 'const';
501
- value: [
502
- 115,
503
- 116,
504
- 97,
505
- 107,
506
- 101,
507
- 95,
508
- 118,
509
- 97,
510
- 117,
511
- 108,
512
- 116,
513
- 95,
514
- 116,
515
- 111,
516
- 107,
517
- 101,
518
- 110,
519
- 95,
520
- 97,
521
- 99,
522
- 99,
523
- 111,
524
- 117,
525
- 110,
526
- 116
527
- ];
528
- },
529
- {
530
- kind: 'account';
531
- path: 'mint';
532
- },
533
- {
534
- kind: 'account';
535
- path: 'stakeVault';
536
- }
537
- ];
538
- };
539
481
  },
540
482
  {
541
483
  name: 'tokenProgram';
@@ -1121,7 +1063,7 @@ export type TriadProtocol = {
1121
1063
  };
1122
1064
  },
1123
1065
  {
1124
- name: 'collection';
1066
+ name: 'stakeVault';
1125
1067
  type: 'string';
1126
1068
  },
1127
1069
  {
@@ -6,5 +6,6 @@ export declare const decodeString: (bytes: number[]) => string;
6
6
  export declare const getVaultAddressSync: (programId: PublicKey, tickerAddress: PublicKey) => PublicKey;
7
7
  export declare const getTokenVaultAddressSync: (programId: PublicKey, vault: PublicKey) => PublicKey;
8
8
  export declare function getUserPositionAddressSync(programId: PublicKey, authority: PublicKey, ticker: PublicKey): PublicKey;
9
+ export declare const getStakeVaultAddressSync: (programId: PublicKey, vaultName: string) => PublicKey;
9
10
  export declare const getATASync: (address: PublicKey, Mint: PublicKey) => PublicKey;
10
11
  export declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
@@ -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.formatNumber = exports.getATASync = exports.getUserPositionAddressSync = exports.getTokenVaultAddressSync = exports.getVaultAddressSync = exports.decodeString = exports.encodeString = exports.getTickerAddressSync = void 0;
26
+ exports.formatNumber = exports.getATASync = exports.getStakeVaultAddressSync = exports.getUserPositionAddressSync = exports.getTokenVaultAddressSync = exports.getVaultAddressSync = exports.decodeString = exports.encodeString = exports.getTickerAddressSync = void 0;
27
27
  const web3_js_1 = require("@solana/web3.js");
28
28
  const anchor = __importStar(require("@coral-xyz/anchor"));
29
29
  const spl_token_1 = require("@solana/spl-token");
@@ -70,6 +70,11 @@ function getUserPositionAddressSync(programId, authority, ticker) {
70
70
  return UserPositionPDA;
71
71
  }
72
72
  exports.getUserPositionAddressSync = getUserPositionAddressSync;
73
+ const getStakeVaultAddressSync = (programId, vaultName) => {
74
+ const [StakeVaultPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('stake_vault'), Buffer.from(vaultName)], programId);
75
+ return StakeVaultPDA;
76
+ };
77
+ exports.getStakeVaultAddressSync = getStakeVaultAddressSync;
73
78
  const getATASync = (address, Mint) => {
74
79
  const [ATA] = web3_js_1.PublicKey.findProgramAddressSync([address.toBytes(), spl_token_1.TOKEN_2022_PROGRAM_ID.toBytes(), Mint.toBytes()], constants_1.ATA_PROGRAM_ID);
75
80
  return ATA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.1.3-alpha.2",
3
+ "version": "0.1.3-alpha.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",