@substrate/api-sidecar 20.12.0 → 20.13.1

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.
Files changed (27) hide show
  1. package/build/package.json +12 -12
  2. package/build/src/controllers/accounts/AccountsVestingInfoController.d.ts +18 -3
  3. package/build/src/controllers/accounts/AccountsVestingInfoController.js +24 -6
  4. package/build/src/controllers/accounts/AccountsVestingInfoController.js.map +1 -1
  5. package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.d.ts +12 -1
  6. package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.js +15 -3
  7. package/build/src/controllers/rc/accounts/RcAccountsVestingInfoController.js.map +1 -1
  8. package/build/src/services/accounts/AccountsVestingInfoService.d.ts +42 -1
  9. package/build/src/services/accounts/AccountsVestingInfoService.js +236 -5
  10. package/build/src/services/accounts/AccountsVestingInfoService.js.map +1 -1
  11. package/build/src/services/paras/ParasInclusionService.d.ts +3 -11
  12. package/build/src/services/paras/ParasInclusionService.js +7 -60
  13. package/build/src/services/paras/ParasInclusionService.js.map +1 -1
  14. package/build/src/types/responses/AccountVestingInfo.d.ts +56 -1
  15. package/build/src/util/relay/getRelayParentNumber.d.ts +80 -0
  16. package/build/src/util/relay/getRelayParentNumber.js +170 -0
  17. package/build/src/util/relay/getRelayParentNumber.js.map +1 -0
  18. package/build/src/util/relay/getRelayParentNumber.spec.d.ts +1 -0
  19. package/build/src/util/relay/getRelayParentNumber.spec.js +201 -0
  20. package/build/src/util/relay/getRelayParentNumber.spec.js.map +1 -0
  21. package/build/src/util/vesting/vestingCalculations.d.ts +87 -0
  22. package/build/src/util/vesting/vestingCalculations.js +141 -0
  23. package/build/src/util/vesting/vestingCalculations.js.map +1 -0
  24. package/build/src/util/vesting/vestingCalculations.spec.d.ts +1 -0
  25. package/build/src/util/vesting/vestingCalculations.spec.js +335 -0
  26. package/build/src/util/vesting/vestingCalculations.spec.js.map +1 -0
  27. package/package.json +12 -12
@@ -0,0 +1,87 @@
1
+ import BN from 'bn.js';
2
+ /**
3
+ * Represents a vesting schedule with the essential fields needed for calculations.
4
+ */
5
+ export interface IVestingSchedule {
6
+ /** Total amount of tokens locked at the start of vesting */
7
+ locked: BN;
8
+ /** Number of tokens that unlock per block */
9
+ perBlock: BN;
10
+ /** Block number when vesting/unlocking begins */
11
+ startingBlock: BN;
12
+ }
13
+ /**
14
+ * Result of vesting calculation for a single schedule.
15
+ */
16
+ export interface IVestingCalculationResult {
17
+ /** Amount that has vested based on time elapsed */
18
+ vested: BN;
19
+ /** Block number when vesting will be complete */
20
+ endBlock: BN;
21
+ }
22
+ /**
23
+ * Calculate the amount that has vested for a single vesting schedule.
24
+ *
25
+ * The calculation follows the formula used in the vesting pallet:
26
+ * - If currentBlock <= startingBlock: nothing is vested yet
27
+ * - Otherwise: vested = min(blocksPassed * perBlock, locked)
28
+ *
29
+ * Note: This is the theoretical vested amount based on time. The actual
30
+ * claimable amount depends on the on-chain lock state (see calculateVestedClaimable).
31
+ *
32
+ * @param currentBlock - The block number to calculate vested amount at
33
+ * @param schedule - The vesting schedule containing locked, perBlock, and startingBlock
34
+ * @returns The amount that has vested at the given block
35
+ */
36
+ export declare const calculateVested: (currentBlock: BN, schedule: IVestingSchedule) => BN;
37
+ /**
38
+ * Calculate the block number when a vesting schedule will be fully vested.
39
+ *
40
+ * The end block is calculated as: startingBlock + (locked / perBlock)
41
+ *
42
+ * @param schedule - The vesting schedule
43
+ * @returns The block number when vesting completes
44
+ */
45
+ export declare const calculateEndBlock: (schedule: IVestingSchedule) => BN;
46
+ /**
47
+ * Calculate the total vested amount across multiple vesting schedules.
48
+ *
49
+ * @param currentBlock - The block number to calculate vested amounts at
50
+ * @param schedules - Array of vesting schedules
51
+ * @returns The total amount that has vested across all schedules (vestedBalance)
52
+ */
53
+ export declare const calculateTotalVested: (currentBlock: BN, schedules: IVestingSchedule[]) => BN;
54
+ /**
55
+ * Calculate the total locked amount across multiple vesting schedules.
56
+ *
57
+ * @param schedules - Array of vesting schedules
58
+ * @returns The total locked amount across all schedules (vestingTotal)
59
+ */
60
+ export declare const calculateVestingTotal: (schedules: IVestingSchedule[]) => BN;
61
+ /**
62
+ * Calculate the actual claimable amount that can be unlocked.
63
+ *
64
+ * This follows the polkadot-js formula:
65
+ * vestedClaimable = vestingLocked - (vestingTotal - vestedBalance)
66
+ *
67
+ * Where:
68
+ * - vestingLocked: actual on-chain lock amount from balances.locks
69
+ * - vestingTotal: sum of all locked amounts from vesting schedules
70
+ * - vestedBalance: sum of all vested amounts from vesting schedules
71
+ *
72
+ * The difference accounts for previous claims that reduced the on-chain lock.
73
+ *
74
+ * @param vestingLocked - The actual on-chain vesting lock amount
75
+ * @param vestingTotal - Total locked across all vesting schedules
76
+ * @param vestedBalance - Total vested across all vesting schedules
77
+ * @returns The amount that can actually be claimed right now
78
+ */
79
+ export declare const calculateVestedClaimable: (vestingLocked: BN, vestingTotal: BN, vestedBalance: BN) => BN;
80
+ /**
81
+ * Calculate vested amounts for multiple schedules, returning per-schedule results.
82
+ *
83
+ * @param currentBlock - The block number to calculate vested amounts at
84
+ * @param schedules - Array of vesting schedules
85
+ * @returns Array of calculation results with vested amount and end block for each schedule
86
+ */
87
+ export declare const calculateVestingDetails: (currentBlock: BN, schedules: IVestingSchedule[]) => IVestingCalculationResult[];
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ // Copyright 2017-2025 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.calculateVestingDetails = exports.calculateVestedClaimable = exports.calculateVestingTotal = exports.calculateTotalVested = exports.calculateEndBlock = exports.calculateVested = void 0;
22
+ const bn_js_1 = __importDefault(require("bn.js"));
23
+ /**
24
+ * Calculate the amount that has vested for a single vesting schedule.
25
+ *
26
+ * The calculation follows the formula used in the vesting pallet:
27
+ * - If currentBlock <= startingBlock: nothing is vested yet
28
+ * - Otherwise: vested = min(blocksPassed * perBlock, locked)
29
+ *
30
+ * Note: This is the theoretical vested amount based on time. The actual
31
+ * claimable amount depends on the on-chain lock state (see calculateVestedClaimable).
32
+ *
33
+ * @param currentBlock - The block number to calculate vested amount at
34
+ * @param schedule - The vesting schedule containing locked, perBlock, and startingBlock
35
+ * @returns The amount that has vested at the given block
36
+ */
37
+ const calculateVested = (currentBlock, schedule) => {
38
+ const { locked, perBlock, startingBlock } = schedule;
39
+ // Vesting hasn't started yet
40
+ if (currentBlock.lte(startingBlock)) {
41
+ return new bn_js_1.default(0);
42
+ }
43
+ // Calculate how many blocks have passed since vesting started
44
+ const blocksPassed = currentBlock.sub(startingBlock);
45
+ // Calculate vested amount: blocksPassed * perBlock
46
+ const vested = blocksPassed.mul(perBlock);
47
+ // Return the minimum of vested and locked (can't vest more than was locked)
48
+ return bn_js_1.default.min(vested, locked);
49
+ };
50
+ exports.calculateVested = calculateVested;
51
+ /**
52
+ * Calculate the block number when a vesting schedule will be fully vested.
53
+ *
54
+ * The end block is calculated as: startingBlock + (locked / perBlock)
55
+ *
56
+ * @param schedule - The vesting schedule
57
+ * @returns The block number when vesting completes
58
+ */
59
+ const calculateEndBlock = (schedule) => {
60
+ const { locked, perBlock, startingBlock } = schedule;
61
+ // Handle edge case where perBlock is 0 (would cause division by zero)
62
+ if (perBlock.isZero()) {
63
+ // If nothing unlocks per block, vesting never ends
64
+ // Return a very large number to indicate "never"
65
+ return new bn_js_1.default(Number.MAX_SAFE_INTEGER);
66
+ }
67
+ // endBlock = startingBlock + ceil(locked / perBlock)
68
+ // Using div for integer division, then add 1 if there's a remainder
69
+ const blocksNeeded = locked.div(perBlock);
70
+ const hasRemainder = !locked.mod(perBlock).isZero();
71
+ return startingBlock.add(blocksNeeded).add(hasRemainder ? new bn_js_1.default(1) : new bn_js_1.default(0));
72
+ };
73
+ exports.calculateEndBlock = calculateEndBlock;
74
+ /**
75
+ * Calculate the total vested amount across multiple vesting schedules.
76
+ *
77
+ * @param currentBlock - The block number to calculate vested amounts at
78
+ * @param schedules - Array of vesting schedules
79
+ * @returns The total amount that has vested across all schedules (vestedBalance)
80
+ */
81
+ const calculateTotalVested = (currentBlock, schedules) => {
82
+ return schedules.reduce((total, schedule) => {
83
+ return total.add((0, exports.calculateVested)(currentBlock, schedule));
84
+ }, new bn_js_1.default(0));
85
+ };
86
+ exports.calculateTotalVested = calculateTotalVested;
87
+ /**
88
+ * Calculate the total locked amount across multiple vesting schedules.
89
+ *
90
+ * @param schedules - Array of vesting schedules
91
+ * @returns The total locked amount across all schedules (vestingTotal)
92
+ */
93
+ const calculateVestingTotal = (schedules) => {
94
+ return schedules.reduce((total, schedule) => {
95
+ return total.add(schedule.locked);
96
+ }, new bn_js_1.default(0));
97
+ };
98
+ exports.calculateVestingTotal = calculateVestingTotal;
99
+ /**
100
+ * Calculate the actual claimable amount that can be unlocked.
101
+ *
102
+ * This follows the polkadot-js formula:
103
+ * vestedClaimable = vestingLocked - (vestingTotal - vestedBalance)
104
+ *
105
+ * Where:
106
+ * - vestingLocked: actual on-chain lock amount from balances.locks
107
+ * - vestingTotal: sum of all locked amounts from vesting schedules
108
+ * - vestedBalance: sum of all vested amounts from vesting schedules
109
+ *
110
+ * The difference accounts for previous claims that reduced the on-chain lock.
111
+ *
112
+ * @param vestingLocked - The actual on-chain vesting lock amount
113
+ * @param vestingTotal - Total locked across all vesting schedules
114
+ * @param vestedBalance - Total vested across all vesting schedules
115
+ * @returns The amount that can actually be claimed right now
116
+ */
117
+ const calculateVestedClaimable = (vestingLocked, vestingTotal, vestedBalance) => {
118
+ // stillLocked = vestingTotal - vestedBalance (what should remain locked according to schedules)
119
+ const stillLocked = vestingTotal.sub(vestedBalance);
120
+ // vestedClaimable = vestingLocked - stillLocked
121
+ // This is the difference between what's actually locked on-chain and what should be locked
122
+ const claimable = vestingLocked.sub(stillLocked);
123
+ // Ensure we don't return negative values
124
+ return bn_js_1.default.max(claimable, new bn_js_1.default(0));
125
+ };
126
+ exports.calculateVestedClaimable = calculateVestedClaimable;
127
+ /**
128
+ * Calculate vested amounts for multiple schedules, returning per-schedule results.
129
+ *
130
+ * @param currentBlock - The block number to calculate vested amounts at
131
+ * @param schedules - Array of vesting schedules
132
+ * @returns Array of calculation results with vested amount and end block for each schedule
133
+ */
134
+ const calculateVestingDetails = (currentBlock, schedules) => {
135
+ return schedules.map((schedule) => ({
136
+ vested: (0, exports.calculateVested)(currentBlock, schedule),
137
+ endBlock: (0, exports.calculateEndBlock)(schedule),
138
+ }));
139
+ };
140
+ exports.calculateVestingDetails = calculateVestingDetails;
141
+ //# sourceMappingURL=vestingCalculations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vestingCalculations.js","sourceRoot":"","sources":["../../../../src/util/vesting/vestingCalculations.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;AAExE,kDAAuB;AAwBvB;;;;;;;;;;;;;GAaG;AACI,MAAM,eAAe,GAAG,CAAC,YAAgB,EAAE,QAA0B,EAAM,EAAE;IACnF,MAAM,EAAE,MAAM,EAAE,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C,CAAC;QACnC,MAAM,EAAE,IAAA,uBAAe,EAAC,YAAY,EAAE,QAAQ,CAAC;QAC/C,QAAQ,EAAE,IAAA,yBAAiB,EAAC,QAAQ,CAAC;KACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,uBAAuB,2BAQlC"}
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+ // Copyright 2017-2025 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const bn_js_1 = __importDefault(require("bn.js"));
22
+ const vestingCalculations_1 = require("./vestingCalculations");
23
+ describe('Vesting Calculations', () => {
24
+ // Sample vesting schedule based on real data from tests
25
+ const sampleSchedule = {
26
+ locked: new bn_js_1.default('1749990000000000'),
27
+ perBlock: new bn_js_1.default('166475460'),
28
+ startingBlock: new bn_js_1.default('4961000'),
29
+ };
30
+ describe('calculateVested', () => {
31
+ it('should return 0 when current block is before starting block', () => {
32
+ const currentBlock = new bn_js_1.default('4960000'); // Before startingBlock
33
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, sampleSchedule);
34
+ expect(result.toString()).toBe('0');
35
+ });
36
+ it('should return 0 when current block equals starting block', () => {
37
+ const currentBlock = new bn_js_1.default('4961000'); // Equal to startingBlock
38
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, sampleSchedule);
39
+ expect(result.toString()).toBe('0');
40
+ });
41
+ it('should return partial amount when vesting is in progress', () => {
42
+ // 1000 blocks after start
43
+ const currentBlock = new bn_js_1.default('4962000');
44
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, sampleSchedule);
45
+ // Expected: 1000 * 166475460 = 166475460000
46
+ const expected = new bn_js_1.default('166475460000');
47
+ expect(result.toString()).toBe(expected.toString());
48
+ });
49
+ it('should return locked amount when fully vested', () => {
50
+ // Far in the future, well past end block
51
+ const currentBlock = new bn_js_1.default('100000000');
52
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, sampleSchedule);
53
+ // Should be capped at locked amount
54
+ expect(result.toString()).toBe(sampleSchedule.locked.toString());
55
+ });
56
+ it('should not exceed locked amount even with large block numbers', () => {
57
+ const currentBlock = new bn_js_1.default('999999999999');
58
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, sampleSchedule);
59
+ expect(result.lte(sampleSchedule.locked)).toBe(true);
60
+ expect(result.toString()).toBe(sampleSchedule.locked.toString());
61
+ });
62
+ it('should handle schedule with small values', () => {
63
+ const smallSchedule = {
64
+ locked: new bn_js_1.default('1000'),
65
+ perBlock: new bn_js_1.default('10'),
66
+ startingBlock: new bn_js_1.default('100'),
67
+ };
68
+ // 50 blocks after start: 50 * 10 = 500
69
+ const currentBlock = new bn_js_1.default('150');
70
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, smallSchedule);
71
+ expect(result.toString()).toBe('500');
72
+ });
73
+ it('should handle schedule where perBlock equals locked', () => {
74
+ const quickVestSchedule = {
75
+ locked: new bn_js_1.default('1000'),
76
+ perBlock: new bn_js_1.default('1000'),
77
+ startingBlock: new bn_js_1.default('100'),
78
+ };
79
+ // 1 block after start should fully vest
80
+ const currentBlock = new bn_js_1.default('101');
81
+ const result = (0, vestingCalculations_1.calculateVested)(currentBlock, quickVestSchedule);
82
+ expect(result.toString()).toBe('1000');
83
+ });
84
+ });
85
+ describe('calculateEndBlock', () => {
86
+ it('should calculate correct end block for sample schedule', () => {
87
+ const result = (0, vestingCalculations_1.calculateEndBlock)(sampleSchedule);
88
+ // endBlock = startingBlock + ceil(locked / perBlock)
89
+ // locked / perBlock = 1749990000000000 / 166475460 = 10511999 remainder 130955460
90
+ // Since there's a remainder, we round up: 10511999 + 1 = 10512000
91
+ // endBlock = 4961000 + 10512000 = 15473000
92
+ const expectedEndBlock = new bn_js_1.default('15473000');
93
+ expect(result.toString()).toBe(expectedEndBlock.toString());
94
+ });
95
+ it('should handle exact division (no remainder)', () => {
96
+ const exactSchedule = {
97
+ locked: new bn_js_1.default('1000'),
98
+ perBlock: new bn_js_1.default('100'),
99
+ startingBlock: new bn_js_1.default('500'),
100
+ };
101
+ // endBlock = 500 + (1000 / 100) = 500 + 10 = 510
102
+ const result = (0, vestingCalculations_1.calculateEndBlock)(exactSchedule);
103
+ expect(result.toString()).toBe('510');
104
+ });
105
+ it('should handle division with remainder (rounds up)', () => {
106
+ const remainderSchedule = {
107
+ locked: new bn_js_1.default('1001'),
108
+ perBlock: new bn_js_1.default('100'),
109
+ startingBlock: new bn_js_1.default('500'),
110
+ };
111
+ // endBlock = 500 + ceil(1001 / 100) = 500 + 11 = 511
112
+ const result = (0, vestingCalculations_1.calculateEndBlock)(remainderSchedule);
113
+ expect(result.toString()).toBe('511');
114
+ });
115
+ it('should handle zero perBlock gracefully', () => {
116
+ const zeroPerBlockSchedule = {
117
+ locked: new bn_js_1.default('1000'),
118
+ perBlock: new bn_js_1.default('0'),
119
+ startingBlock: new bn_js_1.default('500'),
120
+ };
121
+ const result = (0, vestingCalculations_1.calculateEndBlock)(zeroPerBlockSchedule);
122
+ // Should return MAX_SAFE_INTEGER to indicate "never ends"
123
+ expect(result.toString()).toBe(Number.MAX_SAFE_INTEGER.toString());
124
+ });
125
+ });
126
+ describe('calculateTotalVested', () => {
127
+ it('should return 0 for empty schedules array', () => {
128
+ const currentBlock = new bn_js_1.default('5000000');
129
+ const result = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, []);
130
+ expect(result.toString()).toBe('0');
131
+ });
132
+ it('should return correct total for single schedule', () => {
133
+ const currentBlock = new bn_js_1.default('4962000'); // 1000 blocks after start
134
+ const result = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, [sampleSchedule]);
135
+ // Expected: 1000 * 166475460 = 166475460000
136
+ expect(result.toString()).toBe('166475460000');
137
+ });
138
+ it('should sum vested amounts from multiple schedules', () => {
139
+ const schedules = [
140
+ {
141
+ locked: new bn_js_1.default('1000'),
142
+ perBlock: new bn_js_1.default('10'),
143
+ startingBlock: new bn_js_1.default('100'),
144
+ },
145
+ {
146
+ locked: new bn_js_1.default('2000'),
147
+ perBlock: new bn_js_1.default('20'),
148
+ startingBlock: new bn_js_1.default('100'),
149
+ },
150
+ ];
151
+ // At block 150 (50 blocks after start):
152
+ // Schedule 1: 50 * 10 = 500
153
+ // Schedule 2: 50 * 20 = 1000
154
+ // Total: 1500
155
+ const currentBlock = new bn_js_1.default('150');
156
+ const result = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, schedules);
157
+ expect(result.toString()).toBe('1500');
158
+ });
159
+ it('should handle schedules with different starting blocks', () => {
160
+ const schedules = [
161
+ {
162
+ locked: new bn_js_1.default('1000'),
163
+ perBlock: new bn_js_1.default('10'),
164
+ startingBlock: new bn_js_1.default('100'),
165
+ },
166
+ {
167
+ locked: new bn_js_1.default('2000'),
168
+ perBlock: new bn_js_1.default('20'),
169
+ startingBlock: new bn_js_1.default('200'), // Starts later
170
+ },
171
+ ];
172
+ // At block 150:
173
+ // Schedule 1: 50 * 10 = 500 (started at 100)
174
+ // Schedule 2: 0 (hasn't started, starts at 200)
175
+ // Total: 500
176
+ const currentBlock = new bn_js_1.default('150');
177
+ const result = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, schedules);
178
+ expect(result.toString()).toBe('500');
179
+ });
180
+ it('should handle mix of fully vested and in-progress schedules', () => {
181
+ const schedules = [
182
+ {
183
+ locked: new bn_js_1.default('100'),
184
+ perBlock: new bn_js_1.default('100'), // Fully vests in 1 block
185
+ startingBlock: new bn_js_1.default('100'),
186
+ },
187
+ {
188
+ locked: new bn_js_1.default('1000'),
189
+ perBlock: new bn_js_1.default('10'),
190
+ startingBlock: new bn_js_1.default('100'),
191
+ },
192
+ ];
193
+ // At block 150:
194
+ // Schedule 1: min(50 * 100, 100) = 100 (fully vested)
195
+ // Schedule 2: 50 * 10 = 500
196
+ // Total: 600
197
+ const currentBlock = new bn_js_1.default('150');
198
+ const result = (0, vestingCalculations_1.calculateTotalVested)(currentBlock, schedules);
199
+ expect(result.toString()).toBe('600');
200
+ });
201
+ });
202
+ describe('calculateVestingTotal', () => {
203
+ it('should return 0 for empty schedules array', () => {
204
+ const result = (0, vestingCalculations_1.calculateVestingTotal)([]);
205
+ expect(result.toString()).toBe('0');
206
+ });
207
+ it('should return locked amount for single schedule', () => {
208
+ const result = (0, vestingCalculations_1.calculateVestingTotal)([sampleSchedule]);
209
+ expect(result.toString()).toBe(sampleSchedule.locked.toString());
210
+ });
211
+ it('should sum locked amounts from multiple schedules', () => {
212
+ const schedules = [
213
+ {
214
+ locked: new bn_js_1.default('1000'),
215
+ perBlock: new bn_js_1.default('10'),
216
+ startingBlock: new bn_js_1.default('100'),
217
+ },
218
+ {
219
+ locked: new bn_js_1.default('2000'),
220
+ perBlock: new bn_js_1.default('20'),
221
+ startingBlock: new bn_js_1.default('200'),
222
+ },
223
+ ];
224
+ const result = (0, vestingCalculations_1.calculateVestingTotal)(schedules);
225
+ expect(result.toString()).toBe('3000');
226
+ });
227
+ });
228
+ describe('calculateVestedClaimable', () => {
229
+ it('should return 0 when nothing has vested', () => {
230
+ const vestingLocked = new bn_js_1.default('1000');
231
+ const vestingTotal = new bn_js_1.default('1000');
232
+ const vestedBalance = new bn_js_1.default('0');
233
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
234
+ // claimable = 1000 - (1000 - 0) = 0
235
+ expect(result.toString()).toBe('0');
236
+ });
237
+ it('should return correct claimable when partially vested', () => {
238
+ const vestingLocked = new bn_js_1.default('1000');
239
+ const vestingTotal = new bn_js_1.default('1000');
240
+ const vestedBalance = new bn_js_1.default('400');
241
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
242
+ // claimable = 1000 - (1000 - 400) = 1000 - 600 = 400
243
+ expect(result.toString()).toBe('400');
244
+ });
245
+ it('should return correct claimable when some has already been claimed', () => {
246
+ // Example: 1000 locked, 400 vested, user already claimed 100
247
+ const vestingLocked = new bn_js_1.default('900'); // 1000 - 100 already claimed
248
+ const vestingTotal = new bn_js_1.default('1000');
249
+ const vestedBalance = new bn_js_1.default('400');
250
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
251
+ // claimable = 900 - (1000 - 400) = 900 - 600 = 300
252
+ expect(result.toString()).toBe('300');
253
+ });
254
+ it('should return 0 when fully claimed', () => {
255
+ // All vested amount already claimed
256
+ const vestingLocked = new bn_js_1.default('600'); // Original 1000, vested 400, all 400 claimed
257
+ const vestingTotal = new bn_js_1.default('1000');
258
+ const vestedBalance = new bn_js_1.default('400');
259
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
260
+ // claimable = 600 - (1000 - 400) = 600 - 600 = 0
261
+ expect(result.toString()).toBe('0');
262
+ });
263
+ it('should return full amount when fully vested and nothing claimed', () => {
264
+ const vestingLocked = new bn_js_1.default('1000');
265
+ const vestingTotal = new bn_js_1.default('1000');
266
+ const vestedBalance = new bn_js_1.default('1000'); // Fully vested
267
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
268
+ // claimable = 1000 - (1000 - 1000) = 1000 - 0 = 1000
269
+ expect(result.toString()).toBe('1000');
270
+ });
271
+ it('should handle multiple schedules (aggregate values)', () => {
272
+ // Two schedules: 1000 + 2000 = 3000 total locked
273
+ // 400 + 800 = 1200 total vested
274
+ // User claimed 200
275
+ const vestingLocked = new bn_js_1.default('2800'); // 3000 - 200 claimed
276
+ const vestingTotal = new bn_js_1.default('3000');
277
+ const vestedBalance = new bn_js_1.default('1200');
278
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
279
+ // claimable = 2800 - (3000 - 1200) = 2800 - 1800 = 1000
280
+ expect(result.toString()).toBe('1000');
281
+ });
282
+ it('should return 0 for negative result (edge case)', () => {
283
+ // Edge case: vestingLocked is less than stillLocked (shouldn't happen normally)
284
+ const vestingLocked = new bn_js_1.default('500');
285
+ const vestingTotal = new bn_js_1.default('1000');
286
+ const vestedBalance = new bn_js_1.default('400');
287
+ const result = (0, vestingCalculations_1.calculateVestedClaimable)(vestingLocked, vestingTotal, vestedBalance);
288
+ // claimable = 500 - (1000 - 400) = 500 - 600 = -100, capped at 0
289
+ expect(result.toString()).toBe('0');
290
+ });
291
+ });
292
+ describe('calculateVestingDetails', () => {
293
+ it('should return empty array for empty schedules', () => {
294
+ const currentBlock = new bn_js_1.default('5000000');
295
+ const result = (0, vestingCalculations_1.calculateVestingDetails)(currentBlock, []);
296
+ expect(result).toEqual([]);
297
+ });
298
+ it('should return details for single schedule', () => {
299
+ const schedule = {
300
+ locked: new bn_js_1.default('1000'),
301
+ perBlock: new bn_js_1.default('100'),
302
+ startingBlock: new bn_js_1.default('500'),
303
+ };
304
+ const currentBlock = new bn_js_1.default('505'); // 5 blocks after start
305
+ const result = (0, vestingCalculations_1.calculateVestingDetails)(currentBlock, [schedule]);
306
+ expect(result.length).toBe(1);
307
+ expect(result[0].vested.toString()).toBe('500'); // 5 * 100
308
+ expect(result[0].endBlock.toString()).toBe('510'); // 500 + (1000/100)
309
+ });
310
+ it('should return details for multiple schedules', () => {
311
+ const schedules = [
312
+ {
313
+ locked: new bn_js_1.default('1000'),
314
+ perBlock: new bn_js_1.default('100'),
315
+ startingBlock: new bn_js_1.default('500'),
316
+ },
317
+ {
318
+ locked: new bn_js_1.default('2000'),
319
+ perBlock: new bn_js_1.default('200'),
320
+ startingBlock: new bn_js_1.default('600'),
321
+ },
322
+ ];
323
+ const currentBlock = new bn_js_1.default('605'); // 105 blocks after schedule 1, 5 blocks after schedule 2
324
+ const result = (0, vestingCalculations_1.calculateVestingDetails)(currentBlock, schedules);
325
+ expect(result.length).toBe(2);
326
+ // Schedule 1: fully vested (105 * 100 = 10500 > 1000)
327
+ expect(result[0].vested.toString()).toBe('1000');
328
+ expect(result[0].endBlock.toString()).toBe('510');
329
+ // Schedule 2: 5 * 200 = 1000
330
+ expect(result[1].vested.toString()).toBe('1000');
331
+ expect(result[1].endBlock.toString()).toBe('610'); // 600 + (2000/200)
332
+ });
333
+ });
334
+ });
335
+ //# sourceMappingURL=vestingCalculations.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vestingCalculations.spec.js","sourceRoot":"","sources":["../../../../src/util/vesting/vestingCalculations.spec.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;AAExE,kDAAuB;AAEvB,+DAQ+B;AAE/B,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACrC,wDAAwD;IACxD,MAAM,cAAc,GAAqB;QACxC,MAAM,EAAE,IAAI,eAAE,CAAC,kBAAkB,CAAC;QAClC,QAAQ,EAAE,IAAI,eAAE,CAAC,WAAW,CAAC;QAC7B,aAAa,EAAE,IAAI,eAAE,CAAC,SAAS,CAAC;KAChC,CAAC;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,6DAA6D,EAAE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AAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAElD,6BAA6B;YAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB;QACvE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "20.12.0",
2
+ "version": "20.13.1",
3
3
  "name": "@substrate/api-sidecar",
4
4
  "description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
5
5
  "homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
@@ -51,27 +51,27 @@
51
51
  "test:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js"
52
52
  },
53
53
  "dependencies": {
54
- "@polkadot/api": "^16.5.2",
55
- "@polkadot/api-augment": "^16.5.2",
56
- "@polkadot/api-contract": "^16.5.2",
57
- "@polkadot/types": "^16.5.2",
58
- "@polkadot/types-codec": "^16.5.2",
59
- "@polkadot/util": "^13.5.8",
60
- "@polkadot/util-crypto": "^13.5.8",
54
+ "@polkadot/api": "16.5.2",
55
+ "@polkadot/api-augment": "16.5.2",
56
+ "@polkadot/api-contract": "16.5.2",
57
+ "@polkadot/types": "16.5.2",
58
+ "@polkadot/types-codec": "16.5.2",
59
+ "@polkadot/util": "13.5.8",
60
+ "@polkadot/util-crypto": "13.5.8",
61
61
  "@substrate/calc": "0.3.1",
62
62
  "argparse": "^2.0.1",
63
63
  "confmgr": "^1.1.0",
64
- "express": "^5.1.0",
64
+ "express": "^5.2.0",
65
65
  "express-winston": "^4.2.0",
66
66
  "http-errors": "^2.0.1",
67
- "lru-cache": "^11.2.2",
67
+ "lru-cache": "^11.2.4",
68
68
  "prom-client": "^15.1.3",
69
69
  "rxjs": "^7.8.2",
70
- "winston": "^3.18.3",
70
+ "winston": "^3.19.0",
71
71
  "winston-loki": "^6.1.3"
72
72
  },
73
73
  "devDependencies": {
74
- "@acala-network/chopsticks-testing": "^1.2.4",
74
+ "@acala-network/chopsticks-testing": "^1.2.5",
75
75
  "@substrate/dev": "^0.9.0",
76
76
  "@types/argparse": "2.0.17",
77
77
  "@types/express": "^5.0.5",