@triadxyz/triad-protocol 3.5.2-beta → 4.0.0

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.
@@ -2,19 +2,19 @@
2
2
  * Calculate dynamic fee based on price
3
3
  * Returns fee in basis points (bps)
4
4
  */
5
- export declare function calculateDynamicFeeBps(price: number): number;
5
+ export declare function calculateDynamicFeeBps(price: number, feeBps: number): number;
6
6
  /**
7
7
  * Apply dynamic fee to price for buy orders (adds fee)
8
8
  */
9
- export declare function applyBuyFee(price: number): number;
9
+ export declare function applyBuyFee(price: number, feeBps: number): number;
10
10
  /**
11
11
  * Apply dynamic fee to price for sell orders (subtracts fee)
12
12
  */
13
- export declare function applySellFee(price: number): number;
13
+ export declare function applySellFee(price: number, feeBps: number): number;
14
14
  /**
15
15
  * Simulate a buy order with given amount and price
16
16
  */
17
- export declare function simulateBuyOrder(amount: number, price: number): {
17
+ export declare function simulateBuyOrder(amount: number, price: number, feeBps: number): {
18
18
  entryPrice: number;
19
19
  effectivePrice: number;
20
20
  sharesReceived: number;
@@ -24,18 +24,10 @@ export declare function simulateBuyOrder(amount: number, price: number): {
24
24
  /**
25
25
  * Simulate a sell order with given shares and price
26
26
  */
27
- export declare function simulateSellOrder(shares: number, price: number): {
27
+ export declare function simulateSellOrder(shares: number, price: number, feeBps: number): {
28
28
  entryPrice: number;
29
29
  effectivePrice: number;
30
30
  sharesReceived: number;
31
31
  feeAmount: number;
32
32
  feePercentage: number;
33
33
  };
34
- /**
35
- * Generate fee curve data for visualization
36
- */
37
- export declare function generateFeeCurve(step?: number): Array<{
38
- price: number;
39
- feeBps: number;
40
- feePercentage: number;
41
- }>;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateFeeCurve = exports.simulateSellOrder = exports.simulateBuyOrder = exports.applySellFee = exports.applyBuyFee = exports.calculateDynamicFeeBps = void 0;
3
+ exports.simulateSellOrder = exports.simulateBuyOrder = exports.applySellFee = exports.applyBuyFee = exports.calculateDynamicFeeBps = void 0;
4
4
  /**
5
5
  * Calculate dynamic fee based on price
6
6
  * Returns fee in basis points (bps)
7
7
  */
8
- function calculateDynamicFeeBps(price) {
8
+ function calculateDynamicFeeBps(price, feeBps) {
9
9
  const internalPrice = price * Math.pow(10, 6);
10
10
  if (internalPrice <= 900000) {
11
- return 380;
11
+ return feeBps;
12
12
  }
13
13
  return Math.floor(((990000 - internalPrice) * 1900) / price);
14
14
  }
@@ -16,10 +16,10 @@ exports.calculateDynamicFeeBps = calculateDynamicFeeBps;
16
16
  /**
17
17
  * Apply dynamic fee to price for buy orders (adds fee)
18
18
  */
19
- function applyBuyFee(price) {
20
- const feeBps = calculateDynamicFeeBps(price);
19
+ function applyBuyFee(price, feeBps) {
20
+ const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps);
21
21
  const internalPrice = Math.floor(price * 1000000);
22
- const effectiveInternalPrice = Math.floor((internalPrice * (10000 + feeBps)) / 10000);
22
+ const effectiveInternalPrice = Math.floor((internalPrice * (10000 + dynamicFeeBps)) / 10000);
23
23
  const clampedPrice = Math.min(effectiveInternalPrice, 999999);
24
24
  return clampedPrice / 1000000;
25
25
  }
@@ -27,10 +27,10 @@ exports.applyBuyFee = applyBuyFee;
27
27
  /**
28
28
  * Apply dynamic fee to price for sell orders (subtracts fee)
29
29
  */
30
- function applySellFee(price) {
31
- const feeBps = calculateDynamicFeeBps(price);
30
+ function applySellFee(price, feeBps) {
31
+ const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps);
32
32
  const internalPrice = Math.floor(price * 1000000);
33
- const effectiveInternalPrice = Math.floor((internalPrice * (10000 - feeBps)) / 10000);
33
+ const effectiveInternalPrice = Math.floor((internalPrice * (10000 - dynamicFeeBps)) / 10000);
34
34
  const clampedPrice = Math.max(effectiveInternalPrice, 1);
35
35
  return clampedPrice / 1000000;
36
36
  }
@@ -38,8 +38,8 @@ exports.applySellFee = applySellFee;
38
38
  /**
39
39
  * Simulate a buy order with given amount and price
40
40
  */
41
- function simulateBuyOrder(amount, price) {
42
- const effectivePrice = applyBuyFee(price);
41
+ function simulateBuyOrder(amount, price, feeBps) {
42
+ const effectivePrice = applyBuyFee(price, feeBps);
43
43
  const sharesReceived = amount / effectivePrice;
44
44
  const valueAtOriginalPrice = sharesReceived * price;
45
45
  const feeAmount = amount - valueAtOriginalPrice;
@@ -56,8 +56,8 @@ exports.simulateBuyOrder = simulateBuyOrder;
56
56
  /**
57
57
  * Simulate a sell order with given shares and price
58
58
  */
59
- function simulateSellOrder(shares, price) {
60
- const effectivePrice = applySellFee(price);
59
+ function simulateSellOrder(shares, price, feeBps) {
60
+ const effectivePrice = applySellFee(price, feeBps);
61
61
  const amountReceived = shares * effectivePrice;
62
62
  const valueAtOriginalPrice = shares * price;
63
63
  const feeAmount = valueAtOriginalPrice - amountReceived;
@@ -71,19 +71,3 @@ function simulateSellOrder(shares, price) {
71
71
  };
72
72
  }
73
73
  exports.simulateSellOrder = simulateSellOrder;
74
- /**
75
- * Generate fee curve data for visualization
76
- */
77
- function generateFeeCurve(step = 0.01) {
78
- const curve = [];
79
- for (let price = 0.01; price <= 0.99; price += step) {
80
- const feeBps = calculateDynamicFeeBps(price);
81
- curve.push({
82
- price: Math.round(price * 100) / 100,
83
- feeBps,
84
- feePercentage: feeBps / 100
85
- });
86
- }
87
- return curve;
88
- }
89
- exports.generateFeeCurve = generateFeeCurve;
@@ -1,19 +1,17 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
2
  import { IdlAccounts } from '@coral-xyz/anchor';
3
- import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Stake, StakeVault, Unstake, Pool, BookOrder, Customer, ClaimVault, ClaimedUser } from '../types';
3
+ import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Stake, StakeVault, Unstake, Pool, BookOrder, Customer } from '../types';
4
4
  import { TriadProtocol } from '../types/triad_protocol';
5
5
  export declare const encodeString: (value: string, alloc?: number) => number[];
6
6
  export declare const decodeString: (bytes: number[]) => string;
7
7
  export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
8
- export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3']) => Stake;
8
+ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3'], address: PublicKey) => Stake;
9
9
  export declare const formatUnstake: (unstake: IdlAccounts<TriadProtocol>['unstake'], address: PublicKey) => Unstake;
10
10
  export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
11
11
  export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
12
12
  export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['orderV2'], address: PublicKey) => Order;
13
13
  export declare const formatBookOrder: (order: IdlAccounts<TriadProtocol>['orderBook']['hypeOrders'][number] | IdlAccounts<TriadProtocol>['orderBook']['flopOrders'][number], marketId: number) => BookOrder;
14
14
  export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
15
- export declare const formatClaimVault: (account: IdlAccounts<TriadProtocol>['claimVault'], address: PublicKey) => ClaimVault;
16
- export declare const formatClaimedUser: (account: IdlAccounts<TriadProtocol>['claimedUser'], address: PublicKey) => ClaimedUser;
17
15
  export declare const calculateStakeRewards: (stake: Stake) => number;
18
16
  export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
19
17
  export declare const getOrderDirection: (orderDirection: OrderDirectionEncoded) => OrderDirection;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatClaimedUser = exports.formatClaimVault = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const types_1 = require("../types");
@@ -34,8 +34,9 @@ const formatStakeVault = (stakeVault) => {
34
34
  };
35
35
  };
36
36
  exports.formatStakeVault = formatStakeVault;
37
- const formatStake = (stake) => {
37
+ const formatStake = (stake, address) => {
38
38
  return {
39
+ address: address.toBase58(),
39
40
  authority: stake.authority.toBase58(),
40
41
  initTs: stake.initTs.toNumber(),
41
42
  checkedTs: stake.checkedTs.toNumber(),
@@ -62,9 +63,7 @@ const formatPool = (account, address) => {
62
63
  address: address.toString(),
63
64
  id: account.id.toNumber(),
64
65
  question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
65
- authority: account.authority.toString(),
66
- isFast: account.isFast,
67
- isFastMarketActive: account.isFastMarketActive
66
+ authority: account.authority.toString()
68
67
  };
69
68
  };
70
69
  exports.formatPool = formatPool;
@@ -146,36 +145,6 @@ const formatCustomer = (account, publicKey) => {
146
145
  };
147
146
  };
148
147
  exports.formatCustomer = formatCustomer;
149
- const formatClaimVault = (account, address) => {
150
- return {
151
- address: address.toString(),
152
- authority: account.authority.toString(),
153
- initTs: account.initTs.toNumber(),
154
- endTs: account.endTs.toNumber(),
155
- totalAmount: account.totalAmount.toNumber() / Math.pow(10, 6),
156
- totalClaimed: account.totalClaimed.toNumber() / Math.pow(10, 6),
157
- totalUsers: account.totalUsers.toNumber(),
158
- claimedUsers: account.claimedUsers.toNumber(),
159
- tokenPerUser: account.tokenPerUser.toNumber() / Math.pow(10, 6),
160
- mint: account.mint.toBase58(),
161
- isActive: account.isActive,
162
- name: account.name,
163
- isFirstComeFirstServed: account.isFirstComeFirstServed,
164
- merkleRoot: account.merkleRoot,
165
- ts: account.ts.toNumber()
166
- };
167
- };
168
- exports.formatClaimVault = formatClaimVault;
169
- const formatClaimedUser = (account, address) => {
170
- return {
171
- user: address.toString(),
172
- address: account.user.toString(),
173
- claimVault: account.claimVault.toString(),
174
- amount: account.amount.toNumber() / Math.pow(10, 6),
175
- ts: account.ts.toNumber()
176
- };
177
- };
178
- exports.formatClaimedUser = formatClaimedUser;
179
148
  const calculateStakeRewards = (stake) => {
180
149
  const maxRank = 1633;
181
150
  const rank = 369;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "3.5.2-beta",
3
+ "version": "4.0.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/dist/claim.d.ts DELETED
@@ -1,59 +0,0 @@
1
- /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
- import { Program } from '@coral-xyz/anchor';
3
- import { PublicKey } from '@solana/web3.js';
4
- import { TriadProtocol } from './types/triad_protocol';
5
- import { RpcOptions, CreateClaimVaultArgs, ClaimTokenArgs, UpdateClaimVaultIsActiveArgs, UpdateClaimVaultAmountArgs, UpdateClaimVaultEndTsArgs } from './types';
6
- export default class Claim {
7
- private program;
8
- private rpcOptions;
9
- constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
10
- /**
11
- * Get All Claim Vaults
12
- */
13
- getAllClaimVaults(): Promise<import("./types").ClaimVault[]>;
14
- /**
15
- * Get Claim Vault
16
- * @param name - Name of the claim vault
17
- */
18
- getClaimVault(name: string): Promise<import("./types").ClaimVault>;
19
- /**
20
- * Get Claimed User
21
- * @param claimVault - Claim vault
22
- * @param user - User
23
- */
24
- getClaimedUser(claimVault: PublicKey, user: PublicKey): Promise<import("./types").ClaimedUser>;
25
- /**
26
- * Claim Token
27
- * @param claimData - Claim data
28
- * @param claimVaultName - Vault name
29
- * @param payer - Payer
30
- * @param mint - Mint
31
- * @param amount - Amount to claim
32
- */
33
- claimToken({ mint, claimVaultName, claimData, amount, isFirstComeFirstServed }: ClaimTokenArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
34
- /**
35
- * Create Claim Vault
36
- * @param args - Create Claim Vault Args
37
- */
38
- createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, claimData, mint }: CreateClaimVaultArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
39
- /**
40
- * Update Claim Vault Is Active
41
- * @param isActive - Is active
42
- * @param claimVault - Claim vault
43
- */
44
- updateClaimVaultIsActive({ isActive, claimVaultName }: UpdateClaimVaultIsActiveArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
45
- /**
46
- * Update Claim Vault Amount
47
- * @param amount - Amount to add
48
- * @param newUsers - New users to add
49
- * @param claimVaultName - Claim vault name
50
- * @param mint - Mint
51
- */
52
- updateClaimVaultAmount({ amount, newUsers, claimVaultName, mint, claimData }: UpdateClaimVaultAmountArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
53
- /**
54
- * Update Claim Vault End Ts
55
- * @param endTs - End ts
56
- * @param claimVaultName - Claim vault name
57
- */
58
- updateClaimVaultEndTs({ endTs, claimVaultName }: UpdateClaimVaultEndTsArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
59
- }
package/dist/claim.js DELETED
@@ -1,193 +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 anchor_1 = require("@coral-xyz/anchor");
16
- const helpers_1 = require("./utils/helpers");
17
- const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
18
- const pda_1 = require("./utils/pda");
19
- const merkle_1 = require("./utils/merkle");
20
- class Claim {
21
- constructor(program, rpcOptions) {
22
- this.program = program;
23
- this.rpcOptions = rpcOptions;
24
- }
25
- /**
26
- * Get All Claim Vaults
27
- */
28
- getAllClaimVaults() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const claimVaults = yield this.program.account.claimVault.all();
31
- return claimVaults.map(({ account, publicKey }) => (0, helpers_1.formatClaimVault)(account, publicKey));
32
- });
33
- }
34
- /**
35
- * Get Claim Vault
36
- * @param name - Name of the claim vault
37
- */
38
- getClaimVault(name) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const claimVaultPDA = (0, pda_1.getClaimVaultPDA)(this.program.programId, name);
41
- const claimVault = yield this.program.account.claimVault.fetch(claimVaultPDA);
42
- return (0, helpers_1.formatClaimVault)(claimVault, claimVaultPDA);
43
- });
44
- }
45
- /**
46
- * Get Claimed User
47
- * @param claimVault - Claim vault
48
- * @param user - User
49
- */
50
- getClaimedUser(claimVault, user) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const claimedUserPDA = (0, pda_1.getClaimedUserPDA)(this.program.programId, claimVault, user);
53
- const claimedUser = yield this.program.account.claimedUser.fetch(claimedUserPDA);
54
- return (0, helpers_1.formatClaimedUser)(claimedUser, claimedUserPDA);
55
- });
56
- }
57
- /**
58
- * Claim Token
59
- * @param claimData - Claim data
60
- * @param claimVaultName - Vault name
61
- * @param payer - Payer
62
- * @param mint - Mint
63
- * @param amount - Amount to claim
64
- */
65
- claimToken({ mint, claimVaultName, claimData, amount, isFirstComeFirstServed }) {
66
- var _a;
67
- return __awaiter(this, void 0, void 0, function* () {
68
- let proof = [];
69
- if (!isFirstComeFirstServed) {
70
- const { proofs } = (0, merkle_1.generateMerkleTree)(claimData);
71
- proof = (_a = proofs.find((p) => p.user.toBase58() === this.program.provider.publicKey.toBase58())) === null || _a === void 0 ? void 0 : _a.proof;
72
- }
73
- const ixs = [
74
- yield this.program.methods
75
- .claimToken({
76
- amount: new anchor_1.BN(amount * Math.pow(10, 6)),
77
- merkleProof: proof
78
- })
79
- .accounts({
80
- signer: this.program.provider.publicKey,
81
- payer: this.rpcOptions.payer,
82
- mint,
83
- claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName),
84
- tokenProgram: (0, helpers_1.getTokenProgram)(mint)
85
- })
86
- .instruction()
87
- ];
88
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
89
- });
90
- }
91
- /**
92
- * Create Claim Vault
93
- * @param args - Create Claim Vault Args
94
- */
95
- createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, claimData, mint }) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- let merkleRoot = null;
98
- if (claimData) {
99
- const { merkleRoot: root } = (0, merkle_1.generateMerkleTree)(claimData);
100
- merkleRoot = root;
101
- }
102
- const ixs = [
103
- yield this.program.methods
104
- .createClaimVault({
105
- totalAmount: new anchor_1.BN(totalAmount * Math.pow(10, 6)),
106
- totalUsers: new anchor_1.BN(totalUsers),
107
- name,
108
- isFirstComeFirstServed,
109
- endTs: new anchor_1.BN(endTs),
110
- merkleRoot
111
- })
112
- .accounts({
113
- signer: this.program.provider.publicKey,
114
- mint,
115
- tokenProgram: (0, helpers_1.getTokenProgram)(mint)
116
- })
117
- .instruction()
118
- ];
119
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
120
- });
121
- }
122
- /**
123
- * Update Claim Vault Is Active
124
- * @param isActive - Is active
125
- * @param claimVault - Claim vault
126
- */
127
- updateClaimVaultIsActive({ isActive, claimVaultName }) {
128
- return __awaiter(this, void 0, void 0, function* () {
129
- const ixs = [
130
- yield this.program.methods
131
- .updateClaimVaultIsActive(isActive)
132
- .accounts({
133
- signer: this.program.provider.publicKey,
134
- claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
135
- })
136
- .instruction()
137
- ];
138
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
139
- });
140
- }
141
- /**
142
- * Update Claim Vault Amount
143
- * @param amount - Amount to add
144
- * @param newUsers - New users to add
145
- * @param claimVaultName - Claim vault name
146
- * @param mint - Mint
147
- */
148
- updateClaimVaultAmount({ amount, newUsers, claimVaultName, mint, claimData }) {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- let merkleRoot = null;
151
- if (claimData) {
152
- const { merkleRoot: root } = (0, merkle_1.generateMerkleTree)(claimData);
153
- merkleRoot = root;
154
- }
155
- const ixs = [
156
- yield this.program.methods
157
- .updateClaimVaultAmount({
158
- amount: new anchor_1.BN(amount * Math.pow(10, 6)),
159
- newUsers: new anchor_1.BN(newUsers),
160
- merkleRoot
161
- })
162
- .accounts({
163
- signer: this.program.provider.publicKey,
164
- mint,
165
- tokenProgram: (0, helpers_1.getTokenProgram)(mint),
166
- claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
167
- })
168
- .instruction()
169
- ];
170
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
171
- });
172
- }
173
- /**
174
- * Update Claim Vault End Ts
175
- * @param endTs - End ts
176
- * @param claimVaultName - Claim vault name
177
- */
178
- updateClaimVaultEndTs({ endTs, claimVaultName }) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- const ixs = [
181
- yield this.program.methods
182
- .updateClaimVaultEndTs(new anchor_1.BN(endTs))
183
- .accounts({
184
- signer: this.program.provider.publicKey,
185
- claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
186
- })
187
- .instruction()
188
- ];
189
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
190
- });
191
- }
192
- }
193
- exports.default = Claim;
@@ -1,35 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import { ClaimData, MerkleProof } from '../types';
3
- export declare class MerkleTree {
4
- private leaves;
5
- private tree;
6
- private claimData;
7
- constructor(claimData: ClaimData[]);
8
- private generateLeaves;
9
- private buildTree;
10
- getRoot(): number[];
11
- getProof(userPubkey: PublicKey, amount: number): number[][];
12
- getAllProofs(): MerkleProof[];
13
- verifyProof(userPubkey: PublicKey, amount: number, proof: number[][]): boolean;
14
- }
15
- export declare function generateMerkleTree(claimData: ClaimData[]): {
16
- merkleRoot: number[];
17
- proofs: MerkleProof[];
18
- };
19
- export declare function createClaimData(data: {
20
- user: string;
21
- amount: number;
22
- }[]): ClaimData[];
23
- export declare function debugMerkleProof(userPubkey: PublicKey, amount: number, merkleProof: number[][], merkleRoot: number[]): {
24
- isValid: boolean;
25
- steps: Array<{
26
- step: number;
27
- currentHash: string;
28
- proofElement: string;
29
- isCurrentSmaller: boolean;
30
- combined: string;
31
- newHash: string;
32
- }>;
33
- finalHash: string;
34
- expectedRoot: string;
35
- };