@autonomys/auto-consensus 1.5.0 → 1.5.2

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/domain.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Api } from '@autonomys/auto-utils';
2
2
  import { ConfirmedDomainBlock, DomainRegistry, DomainStakingSummary } from './types';
3
3
  export declare const domains: (api: Api) => Promise<DomainRegistry[]>;
4
- export declare const domainStakingSummary: (api: Api) => Promise<DomainStakingSummary[]>;
4
+ export declare function domainStakingSummary(api: Api): Promise<DomainStakingSummary[]>;
5
+ export declare function domainStakingSummary(api: Api, domainId: string | number | bigint): Promise<DomainStakingSummary | undefined>;
5
6
  export declare const latestConfirmedDomainBlock: (api: Api) => Promise<ConfirmedDomainBlock[]>;
6
7
  //# sourceMappingURL=domain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGpF,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,cAAc,EAAE,CAQhE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,oBAAoB,EAAE,CAQnF,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,oBAAoB,EAAE,CAWzF,CAAA"}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGpF,eAAO,MAAM,OAAO,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,cAAc,EAAE,CAQhE,CAAA;AAGD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAA;AACrF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;AAoC5C,eAAO,MAAM,0BAA0B,GAAU,KAAK,GAAG,KAAG,OAAO,CAAC,oBAAoB,EAAE,CAWzF,CAAA"}
package/dist/domain.js CHANGED
@@ -10,7 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.latestConfirmedDomainBlock = exports.domainStakingSummary = exports.domains = void 0;
13
+ exports.latestConfirmedDomainBlock = exports.domains = void 0;
14
+ exports.domainStakingSummary = domainStakingSummary;
14
15
  const parse_1 = require("./utils/parse");
15
16
  const domains = (api) => __awaiter(void 0, void 0, void 0, function* () {
16
17
  try {
@@ -23,17 +24,29 @@ const domains = (api) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  }
24
25
  });
25
26
  exports.domains = domains;
26
- const domainStakingSummary = (api) => __awaiter(void 0, void 0, void 0, function* () {
27
- try {
28
- const _domainStakingSummary = yield api.query.domains.domainStakingSummary.entries();
29
- return _domainStakingSummary.map((domain) => domain[1].toJSON());
30
- }
31
- catch (error) {
32
- console.error('error', error);
33
- throw new Error('Error querying domains staking summary list.' + error);
34
- }
35
- });
36
- exports.domainStakingSummary = domainStakingSummary;
27
+ // Implementation function
28
+ function domainStakingSummary(api, domainId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ try {
31
+ if (domainId !== undefined) {
32
+ // Query specific domain
33
+ const _domainStakingSummary = yield api.query.domains.domainStakingSummary(domainId.toString());
34
+ if (_domainStakingSummary.isEmpty) {
35
+ return undefined;
36
+ }
37
+ return Object.assign({ domainId: domainId.toString() }, _domainStakingSummary.toJSON());
38
+ }
39
+ else {
40
+ const _domainStakingSummary = yield api.query.domains.domainStakingSummary.entries();
41
+ return _domainStakingSummary.map((domain) => (Object.assign({ domainId: domain[0].toHuman()[0] }, domain[1].toJSON())));
42
+ }
43
+ }
44
+ catch (error) {
45
+ console.error('error', error);
46
+ throw new Error('Error querying domains staking summary list.' + error);
47
+ }
48
+ });
49
+ }
37
50
  const latestConfirmedDomainBlock = (api) => __awaiter(void 0, void 0, void 0, function* () {
38
51
  try {
39
52
  const _latestConfirmedDomainBlock = yield api.query.domains.latestConfirmedDomainBlock.entries();
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './balances';
3
3
  export * from './batch';
4
4
  export * from './domain';
5
5
  export * from './info';
6
+ export * from './position';
6
7
  export * from './remark';
7
8
  export * from './staking';
8
9
  export * from './transfer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAE1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAE1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ __exportStar(require("./balances"), exports);
20
20
  __exportStar(require("./batch"), exports);
21
21
  __exportStar(require("./domain"), exports);
22
22
  __exportStar(require("./info"), exports);
23
+ __exportStar(require("./position"), exports);
23
24
  __exportStar(require("./remark"), exports);
24
25
  __exportStar(require("./staking"), exports);
25
26
  __exportStar(require("./transfer"), exports);
@@ -0,0 +1,7 @@
1
+ import type { Api } from '@autonomys/auto-utils';
2
+ import type { NominatorPosition } from '../types/position';
3
+ /**
4
+ * High-level helper that returns the staking/storage position of a nominator inside an operator pool
5
+ */
6
+ export declare const nominatorPosition: (api: Api, operatorId: string | number | bigint, nominatorAccountId: string) => Promise<NominatorPosition>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/position/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAI1D;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,GAAG,EACR,YAAY,MAAM,GAAG,MAAM,GAAG,MAAM,EACpC,oBAAoB,MAAM,KACzB,OAAO,CAAC,iBAAiB,CAuI3B,CAAA"}
@@ -0,0 +1,123 @@
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
+ exports.nominatorPosition = void 0;
13
+ const domain_1 = require("../domain");
14
+ const staking_1 = require("../staking");
15
+ const price_1 = require("./price");
16
+ const utils_1 = require("./utils");
17
+ /**
18
+ * High-level helper that returns the staking/storage position of a nominator inside an operator pool
19
+ */
20
+ const nominatorPosition = (api, operatorId, nominatorAccountId) => __awaiter(void 0, void 0, void 0, function* () {
21
+ var _a, _b;
22
+ try {
23
+ const operatorData = yield (0, staking_1.operator)(api, operatorId);
24
+ // Step 1: Get deposits, withdrawals, and domain staking summary
25
+ const [depositsData, withdrawalsData, stakingSummary] = yield Promise.all([
26
+ (0, staking_1.deposits)(api, operatorId, nominatorAccountId),
27
+ (0, staking_1.withdrawals)(api, operatorId, nominatorAccountId),
28
+ (0, domain_1.domainStakingSummary)(api, operatorData.currentDomainId),
29
+ ]);
30
+ if (!stakingSummary) {
31
+ throw new Error('Domain staking summary not found');
32
+ }
33
+ const depositData = depositsData.length > 0 ? depositsData[0] : null;
34
+ if (!depositData) {
35
+ return {
36
+ knownValue: BigInt(0),
37
+ pendingDeposits: [],
38
+ pendingWithdrawals: [],
39
+ storageFeeDeposit: BigInt(0),
40
+ };
41
+ }
42
+ const currentEpochIndex = stakingSummary.currentEpochIndex;
43
+ let totalShares = depositData.known.shares;
44
+ let totalStorageFeeDeposit = depositData.known.storageFeeDeposit + ((_b = (_a = depositData.pending) === null || _a === void 0 ? void 0 : _a.storageFeeDeposit) !== null && _b !== void 0 ? _b : BigInt(0));
45
+ const pendingDeposits = [];
46
+ if (depositData.pending) {
47
+ const { effectiveDomainEpoch, amount, storageFeeDeposit: pendingStorageFee, } = depositData.pending;
48
+ if (effectiveDomainEpoch <= currentEpochIndex) {
49
+ // Epoch has passed - convert pending amount to shares using epoch share price
50
+ try {
51
+ const epochSharePrice = yield (0, price_1.operatorEpochSharePrice)(api, operatorId, effectiveDomainEpoch, 0);
52
+ if (epochSharePrice !== undefined) {
53
+ // Convert pending amount to shares and add to total
54
+ const pendingShares = (0, utils_1.stakeToShare)(amount, epochSharePrice);
55
+ totalShares += pendingShares;
56
+ console.log(`Converted pending deposit: ${amount} tokens at epoch ${effectiveDomainEpoch} (price: ${epochSharePrice}) = ${pendingShares} shares`);
57
+ }
58
+ else {
59
+ // Fallback: if no epoch price available, assume 1:1 conversion
60
+ console.warn(`No epoch share price found for epoch ${effectiveDomainEpoch}, using pending amount as shares`);
61
+ totalShares += amount;
62
+ }
63
+ // Add pending storage fee to total
64
+ totalStorageFeeDeposit += pendingStorageFee;
65
+ }
66
+ catch (error) {
67
+ console.warn(`Error getting epoch share price for epoch ${effectiveDomainEpoch}, treating as still pending:`, error);
68
+ // Keep as pending if we can't get the epoch price
69
+ pendingDeposits.push({
70
+ amount: amount,
71
+ effectiveEpoch: effectiveDomainEpoch,
72
+ });
73
+ }
74
+ }
75
+ else {
76
+ // Epoch hasn't passed yet - keep as pending
77
+ pendingDeposits.push({
78
+ amount: amount,
79
+ effectiveEpoch: effectiveDomainEpoch,
80
+ });
81
+ }
82
+ }
83
+ // Step 3: Calculate current position value using instant share price
84
+ const currentSharePrice = yield (0, price_1.instantSharePrice)(api, operatorId);
85
+ const knownValue = (0, utils_1.shareToStake)(totalShares, currentSharePrice);
86
+ // Step 4: Process pending withdrawals
87
+ const pendingWithdrawals = [];
88
+ if (withdrawalsData.length > 0) {
89
+ for (const withdrawal of withdrawalsData) {
90
+ // Process regular withdrawals
91
+ for (const w of withdrawal.withdrawals) {
92
+ pendingWithdrawals.push({
93
+ amount: w.amountToUnlock,
94
+ unlockAtBlock: w.unlockAtConfirmedDomainBlockNumber,
95
+ });
96
+ }
97
+ // Process withdrawal in shares
98
+ if (withdrawal.withdrawalInShares) {
99
+ const sharePrice = yield (0, price_1.operatorEpochSharePrice)(api, operatorId, withdrawal.withdrawalInShares.domainEpoch[1], // epoch index
100
+ withdrawal.withdrawalInShares.domainEpoch[0]);
101
+ const withdrawalAmount = sharePrice
102
+ ? (0, utils_1.shareToStake)(withdrawal.withdrawalInShares.shares, sharePrice)
103
+ : BigInt(0); // fallback to 0 if no price available
104
+ pendingWithdrawals.push({
105
+ amount: withdrawalAmount,
106
+ unlockAtBlock: withdrawal.withdrawalInShares.unlockAtConfirmedDomainBlockNumber,
107
+ });
108
+ }
109
+ }
110
+ }
111
+ return {
112
+ knownValue,
113
+ pendingDeposits,
114
+ pendingWithdrawals,
115
+ storageFeeDeposit: totalStorageFeeDeposit,
116
+ };
117
+ }
118
+ catch (error) {
119
+ console.error('Error calculating nominator position:', error);
120
+ throw new Error(`Error calculating position for nominator ${nominatorAccountId} in operator ${operatorId}: ${error}`);
121
+ }
122
+ });
123
+ exports.nominatorPosition = nominatorPosition;
@@ -0,0 +1,12 @@
1
+ import type { Api } from '@autonomys/auto-utils';
2
+ /**
3
+ * Fetch the stored share price (18-dec Perbill) for a given (operatorId, domainEpoch) tuple
4
+ * Returns undefined if no price is stored for that epoch (i.e. no staking activity)
5
+ */
6
+ export declare const operatorEpochSharePrice: (api: Api, operatorId: string | number | bigint, domainEpoch: string | number | bigint, domainId?: string | number | bigint) => Promise<bigint | undefined>;
7
+ /**
8
+ * Compute the on-the-fly share price for the operator in the current domain epoch
9
+ * Formula: (currentTotalStake + currentEpochReward * (1 - nominationTax)) / currentTotalShares
10
+ */
11
+ export declare const instantSharePrice: (api: Api, operatorId: string | number | bigint) => Promise<bigint>;
12
+ //# sourceMappingURL=price.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/position/price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAKhD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,GAAG,EACR,YAAY,MAAM,GAAG,MAAM,GAAG,MAAM,EACpC,aAAa,MAAM,GAAG,MAAM,GAAG,MAAM,EACrC,WAAU,MAAM,GAAG,MAAM,GAAG,MAAU,KACrC,OAAO,CAAC,MAAM,GAAG,SAAS,CAmC5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,GAAG,EACR,YAAY,MAAM,GAAG,MAAM,GAAG,MAAM,KACnC,OAAO,CAAC,MAAM,CAiChB,CAAA"}
@@ -0,0 +1,80 @@
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
+ exports.instantSharePrice = exports.operatorEpochSharePrice = void 0;
13
+ const domain_1 = require("../domain");
14
+ const staking_1 = require("../staking");
15
+ const parse_1 = require("../utils/parse");
16
+ /**
17
+ * Fetch the stored share price (18-dec Perbill) for a given (operatorId, domainEpoch) tuple
18
+ * Returns undefined if no price is stored for that epoch (i.e. no staking activity)
19
+ */
20
+ const operatorEpochSharePrice = (api_1, operatorId_1, domainEpoch_1, ...args_1) => __awaiter(void 0, [api_1, operatorId_1, domainEpoch_1, ...args_1], void 0, function* (api, operatorId, domainEpoch, domainId = 0) {
21
+ try {
22
+ // Create domain epoch tuple [domainId, epochIndex]
23
+ const domainEpochTuple = [(0, parse_1.parseString)(domainId), (0, parse_1.parseString)(domainEpoch)];
24
+ const sharePrice = yield api.query.domains.operatorEpochSharePrice((0, parse_1.parseString)(operatorId), domainEpochTuple);
25
+ if (sharePrice.isEmpty) {
26
+ return undefined;
27
+ }
28
+ // The response is a direct Perbill value, not an object
29
+ const priceValue = sharePrice.toJSON();
30
+ if (priceValue === null || priceValue === undefined) {
31
+ return undefined;
32
+ }
33
+ // Convert to bigint - the value is already in Perbill format but needs to be scaled to 18 decimals
34
+ // The raw value from chain is in parts per billion (9 decimals), we need 18 decimals
35
+ const perbillValue = BigInt(priceValue.toString());
36
+ const scaledPrice = perbillValue * BigInt(Math.pow(10, 9)); // Scale from 9 to 18 decimals
37
+ // Invert the share price: if API returns 0.5601 (shares worth 56% of original),
38
+ // we need 1/0.5601 ≈ 1.785 for stakeToShare conversion
39
+ const oneInPerbill = BigInt(Math.pow(10, 18));
40
+ return (oneInPerbill * oneInPerbill) / scaledPrice;
41
+ }
42
+ catch (error) {
43
+ console.error('Error fetching operator epoch share price:', error);
44
+ throw new Error(`Error fetching share price for operator ${operatorId} at epoch ${domainEpoch}: ${error}`);
45
+ }
46
+ });
47
+ exports.operatorEpochSharePrice = operatorEpochSharePrice;
48
+ /**
49
+ * Compute the on-the-fly share price for the operator in the current domain epoch
50
+ * Formula: (currentTotalStake + currentEpochReward * (1 - nominationTax)) / currentTotalShares
51
+ */
52
+ const instantSharePrice = (api, operatorId) => __awaiter(void 0, void 0, void 0, function* () {
53
+ try {
54
+ // Get operator details
55
+ const operatorDetails = yield (0, staking_1.operator)(api, operatorId);
56
+ const { currentTotalStake, currentTotalShares, nominationTax, currentDomainId } = operatorDetails;
57
+ // Get domain staking summary to find current epoch rewards
58
+ const domainSummary = yield (0, domain_1.domainStakingSummary)(api, currentDomainId);
59
+ if (!domainSummary) {
60
+ throw new Error(`No staking summary found for domain ${currentDomainId}`);
61
+ }
62
+ // Get current epoch reward for this operator
63
+ const currentEpochReward = domainSummary.currentEpochRewards[(0, parse_1.parseString)(operatorId)];
64
+ const rewardBigInt = currentEpochReward ? BigInt(currentEpochReward) : BigInt(0);
65
+ // Calculate effective stake: currentTotalStake + currentEpochReward * (1 - nominationTax)
66
+ const rewardAfterTax = (rewardBigInt * BigInt(100 - nominationTax)) / BigInt(100);
67
+ const effectiveStake = currentTotalStake + rewardAfterTax;
68
+ // Avoid division by zero
69
+ if (currentTotalShares === BigInt(0)) {
70
+ return BigInt(Math.pow(10, 18)); // Return 1.0 in Perbill format
71
+ }
72
+ // Return price in 18-decimal Perbill format
73
+ return (effectiveStake * BigInt(Math.pow(10, 18))) / currentTotalShares;
74
+ }
75
+ catch (error) {
76
+ console.error('Error computing instant share price:', error);
77
+ throw new Error(`Error computing instant share price for operator ${operatorId}: ${error}`);
78
+ }
79
+ });
80
+ exports.instantSharePrice = instantSharePrice;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Convert shares to stake using an 18-decimal Perbill price
3
+ * Formula: shares * price / 10^18
4
+ */
5
+ export declare const shareToStake: (shares: bigint, price: bigint) => bigint;
6
+ /**
7
+ * Convert stake to shares using an 18-decimal Perbill price
8
+ * Formula: stake * 10^18 / price
9
+ */
10
+ export declare const stakeToShare: (stake: bigint, price: bigint) => bigint;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/position/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAE5D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MAK3D,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stakeToShare = exports.shareToStake = void 0;
4
+ /**
5
+ * Convert shares to stake using an 18-decimal Perbill price
6
+ * Formula: shares * price / 10^18
7
+ */
8
+ const shareToStake = (shares, price) => {
9
+ return (shares * price) / BigInt(Math.pow(10, 18));
10
+ };
11
+ exports.shareToStake = shareToStake;
12
+ /**
13
+ * Convert stake to shares using an 18-decimal Perbill price
14
+ * Formula: stake * 10^18 / price
15
+ */
16
+ const stakeToShare = (stake, price) => {
17
+ if (price === BigInt(0)) {
18
+ throw new Error('Price cannot be zero for stake to share conversion');
19
+ }
20
+ return (stake * BigInt(Math.pow(10, 18))) / price;
21
+ };
22
+ exports.stakeToShare = stakeToShare;
@@ -0,0 +1,4 @@
1
+ export * from './position/index';
2
+ export * from './position/price';
3
+ export * from './position/utils';
4
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // file: src/position.ts
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./position/index"), exports);
19
+ __exportStar(require("./position/price"), exports);
20
+ __exportStar(require("./position/utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EAOJ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AASxB,eAAO,MAAM,SAAS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G,SAAqB,oDAkBxC,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAmB9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,sBAAsB,wHAS9D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,QAAQ,mBAAmB,wHAmBxD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,aAAa,wHASvD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAQ,aAAa,wHAShD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,wHASpD,CAAA"}
package/dist/staking.js CHANGED
@@ -37,8 +37,16 @@ const operator = (api, operatorId) => __awaiter(void 0, void 0, void 0, function
37
37
  exports.operator = operator;
38
38
  const deposits = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, operatorId_1, ...args_1], void 0, function* (api, operatorId, account = undefined) {
39
39
  try {
40
- const _deposits = yield api.query.domains.deposits.entries((0, parse_1.parseString)(operatorId), account);
41
- return _deposits.map((o) => (0, parse_1.parseDeposit)(o));
40
+ if (account) {
41
+ // For specific account, query all deposits for operator and filter
42
+ const _deposits = yield api.query.domains.deposits.entries((0, parse_1.parseString)(operatorId));
43
+ return _deposits.map((o) => (0, parse_1.parseDeposit)(o)).filter((deposit) => deposit.account === account);
44
+ }
45
+ else {
46
+ // Query all deposits for operator
47
+ const _deposits = yield api.query.domains.deposits.entries((0, parse_1.parseString)(operatorId));
48
+ return _deposits.map((o) => (0, parse_1.parseDeposit)(o));
49
+ }
42
50
  }
43
51
  catch (error) {
44
52
  console.error('error', error);
@@ -48,8 +56,18 @@ const deposits = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, o
48
56
  exports.deposits = deposits;
49
57
  const withdrawals = (api_1, operatorId_1, ...args_1) => __awaiter(void 0, [api_1, operatorId_1, ...args_1], void 0, function* (api, operatorId, account = undefined) {
50
58
  try {
51
- const _withdrawals = yield api.query.domains.withdrawals.entries((0, parse_1.parseString)(operatorId), account);
52
- return _withdrawals.map((o) => (0, parse_1.parseWithdrawal)(o));
59
+ if (account) {
60
+ // For specific account, query all withdrawals for operator and filter
61
+ const _withdrawals = yield api.query.domains.withdrawals.entries((0, parse_1.parseString)(operatorId));
62
+ return _withdrawals
63
+ .map((o) => (0, parse_1.parseWithdrawal)(o))
64
+ .filter((withdrawal) => withdrawal.account === account);
65
+ }
66
+ else {
67
+ // Query all withdrawals for operator
68
+ const _withdrawals = yield api.query.domains.withdrawals.entries((0, parse_1.parseString)(operatorId));
69
+ return _withdrawals.map((o) => (0, parse_1.parseWithdrawal)(o));
70
+ }
53
71
  }
54
72
  catch (error) {
55
73
  console.error('error', error);
@@ -19,6 +19,7 @@ export type DomainRegistry = {
19
19
  };
20
20
  };
21
21
  export type DomainStakingSummary = {
22
+ domainId: string;
22
23
  currentEpochIndex: number;
23
24
  currentTotalStake: string;
24
25
  currentOperators: {
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../src/types/domain.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,EAAE;QACZ,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,YAAY,EAAE,MAAM,CAAA;QACpB,cAAc,EAAE;YACd,OAAO,EAAE,MAAM,CAAA;YACf,SAAS,EAAE,MAAM,CAAA;SAClB,CAAA;QACD,qBAAqB,EAAE,MAAM,EAAE,CAAA;QAC/B,qBAAqB,EAAE,MAAM,CAAA;QAC7B,iBAAiB,EAAE;YACjB,SAAS,EAAE,MAAM,EAAE,CAAA;SACpB,CAAA;KACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,MA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AE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IACD,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,mBAAmB,EAAE;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,sBAAsB,EAAE,MAAM,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA"}
@@ -3,5 +3,6 @@ export * from './balance';
3
3
  export * from './domain';
4
4
  export * from './events';
5
5
  export * from './extrinsic';
6
+ export * from './position';
6
7
  export * from './staking';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
@@ -20,4 +20,5 @@ __exportStar(require("./balance"), exports);
20
20
  __exportStar(require("./domain"), exports);
21
21
  __exportStar(require("./events"), exports);
22
22
  __exportStar(require("./extrinsic"), exports);
23
+ __exportStar(require("./position"), exports);
23
24
  __exportStar(require("./staking"), exports);
@@ -0,0 +1,13 @@
1
+ export type NominatorPosition = {
2
+ knownValue: bigint;
3
+ pendingDeposits: {
4
+ amount: bigint;
5
+ effectiveEpoch: number;
6
+ }[];
7
+ pendingWithdrawals: {
8
+ amount: bigint;
9
+ unlockAtBlock: number;
10
+ }[];
11
+ storageFeeDeposit: bigint;
12
+ };
13
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/types/position.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,EAAE,MAAM,CAAA;KACvB,EAAE,CAAA;IACH,kBAAkB,EAAE;QAClB,MAAM,EAAE,MAAM,CAAA;QACd,aAAa,EAAE,MAAM,CAAA;KACtB,EAAE,CAAA;IACH,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -74,13 +74,13 @@ export type RawWithdrawal = {
74
74
  unlockAtConfirmedDomainBlockNumber: number;
75
75
  amountToUnlock: string;
76
76
  storageFeeRefund: string;
77
- }[];
77
+ }[] | null;
78
78
  withdrawalInShares: {
79
79
  domainEpoch: number[];
80
80
  unlockAtConfirmedDomainBlockNumber: number;
81
81
  shares: string;
82
82
  storageFeeRefund: string;
83
- };
83
+ } | null;
84
84
  };
85
85
  export type WithdrawalUnlock = {
86
86
  domainId: number;
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../../src/types/staking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,MAAM,aAAa,GAAG,MAAM,EAAE,CAAA;AAEpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAA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12,7 @@ export declare const parseDomain: (domain: [StorageKey<AnyTuple>, Codec]) => Dom
12
12
  export declare const parseOperatorDetails: (operatorDetails: Codec) => OperatorDetails;
13
13
  export declare const parseOperator: (operator: [StorageKey<AnyTuple>, Codec]) => Operator;
14
14
  export declare const parseDeposit: (deposit: [StorageKey<AnyTuple>, Codec]) => Deposit;
15
- export declare const parseWithdrawalInShares: (withdrawalInShares: RawWithdrawal["withdrawalInShares"]) => WithdrawalInShares;
15
+ export declare const parseWithdrawalInShares: (withdrawalInShares: NonNullable<RawWithdrawal["withdrawalInShares"]>) => WithdrawalInShares;
16
16
  export declare const parseWithdrawal: (withdrawal: [StorageKey<AnyTuple>, Codec]) => Withdrawal;
17
17
  export declare const parseString: (operatorId: StringNumberOrBigInt) => string;
18
18
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,eAAe,EAKf,aAAa,EAEb,oBAAoB,EACpB,UAAU,EACV,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,OAAO,GAAI,OAAO,EAAE,KAAG,MAAkC,CAAA;AAEtE,eAAO,MAAM,YAAY,GAAI,MAAM,cAAc,KAAG,WAYnD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,WAAW,KAAK,KAAG,SAuBjD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,OAAO,WAAW,K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OAAO,EAAE,KAAG,MAAkC,CAAA;AAEtE,eAAO,MAAM,YAAY,GAAI,MAAM,cAAc,KAAG,WAYnD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,WAAW,KAAK,KAAG,SAuBjD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,OAAO,WAAW,KAAG,SAAS,EAGlE,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,WAAW,KAAG,SAAS,EAWjE,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,cAMnE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,KAAK,KAAG,eAe7D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,QAKvE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,OAuBrE,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,oBAAoB,WAAW,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,KACnE,kBAKD,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,UAuB3E,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,YAAY,oBAAoB,KAAG,MACM,CAAA"}
@@ -119,13 +119,15 @@ const parseWithdrawal = (withdrawal) => {
119
119
  ? (0, exports.parseWithdrawalInShares)(parsedWithdrawal.withdrawalInShares)
120
120
  : null,
121
121
  withdrawals: parsedWithdrawal.withdrawals &&
122
- parsedWithdrawal.withdrawals.length > 0 &&
123
- parsedWithdrawal.withdrawals.map((w) => ({
122
+ Array.isArray(parsedWithdrawal.withdrawals) &&
123
+ parsedWithdrawal.withdrawals.length > 0
124
+ ? parsedWithdrawal.withdrawals.map((w) => ({
124
125
  domainId: w.domainId,
125
126
  unlockAtConfirmedDomainBlockNumber: w.unlockAtConfirmedDomainBlockNumber,
126
127
  amountToUnlock: BigInt(w.amountToUnlock),
127
128
  storageFeeRefund: BigInt(w.storageFeeRefund),
128
- })),
129
+ }))
130
+ : [],
129
131
  };
130
132
  };
131
133
  exports.parseWithdrawal = parseWithdrawal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonomys/auto-consensus",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@autonomys/auto-utils": "^1.5.0"
28
+ "@autonomys/auto-utils": "^1.5.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jest": "^29.5.14",
@@ -35,5 +35,5 @@
35
35
  "ts-jest": "^29.3.1",
36
36
  "typescript": "^5.8.3"
37
37
  },
38
- "gitHead": "27ce75d189f2a9b0f3459cf19cc05dc07ff16100"
38
+ "gitHead": "caa444d14e4f81e9aa408098fe0192dc2131953a"
39
39
  }