@augustdigital/sdk 4.25.0-alpha.0 → 4.25.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.
- package/lib/adapters/solana/getters.d.ts +2 -2
- package/lib/adapters/solana/getters.js +34 -102
- package/lib/adapters/solana/getters.js.map +1 -1
- package/lib/adapters/solana/index.d.ts +2 -2
- package/lib/adapters/solana/utils.d.ts +2 -2
- package/lib/adapters/solana/utils.js +1 -8
- package/lib/adapters/solana/utils.js.map +1 -1
- package/lib/adapters/stellar/actions.d.ts +3 -0
- package/lib/adapters/stellar/actions.js +43 -0
- package/lib/adapters/stellar/actions.js.map +1 -0
- package/lib/adapters/stellar/constants.d.ts +15 -0
- package/lib/adapters/stellar/constants.js +22 -0
- package/lib/adapters/stellar/constants.js.map +1 -0
- package/lib/adapters/stellar/getters.d.ts +6 -0
- package/lib/adapters/stellar/getters.js +193 -0
- package/lib/adapters/stellar/getters.js.map +1 -0
- package/lib/adapters/stellar/index.d.ts +29 -0
- package/lib/adapters/stellar/index.js +85 -0
- package/lib/adapters/stellar/index.js.map +1 -0
- package/lib/adapters/stellar/soroban.d.ts +11 -0
- package/lib/adapters/stellar/soroban.js +106 -0
- package/lib/adapters/stellar/soroban.js.map +1 -0
- package/lib/adapters/stellar/submit.d.ts +2 -0
- package/lib/adapters/stellar/submit.js +50 -0
- package/lib/adapters/stellar/submit.js.map +1 -0
- package/lib/adapters/stellar/types.d.ts +19 -0
- package/lib/adapters/stellar/types.js +3 -0
- package/lib/adapters/stellar/types.js.map +1 -0
- package/lib/adapters/stellar/utils.d.ts +13 -0
- package/lib/adapters/stellar/utils.js +32 -0
- package/lib/adapters/stellar/utils.js.map +1 -0
- package/lib/adapters/sui/transformer.js +4 -9
- package/lib/adapters/sui/transformer.js.map +1 -1
- package/lib/core/base.class.d.ts +3 -2
- package/lib/core/base.class.js +14 -7
- package/lib/core/base.class.js.map +1 -1
- package/lib/core/constants/core.d.ts +7 -3
- package/lib/core/constants/core.js +4 -0
- package/lib/core/constants/core.js.map +1 -1
- package/lib/core/constants/vaults.d.ts +2 -1
- package/lib/core/constants/vaults.js +4 -1
- package/lib/core/constants/vaults.js.map +1 -1
- package/lib/core/constants/web3.d.ts +5 -0
- package/lib/core/constants/web3.js +9 -0
- package/lib/core/constants/web3.js.map +1 -1
- package/lib/core/fetcher.d.ts +5 -4
- package/lib/core/fetcher.js +23 -2
- package/lib/core/fetcher.js.map +1 -1
- package/lib/core/helpers/vaults.js +42 -29
- package/lib/core/helpers/vaults.js.map +1 -1
- package/lib/core/helpers/web3.js +3 -3
- package/lib/core/helpers/web3.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +3 -0
- package/lib/main.js +3 -2
- package/lib/main.js.map +1 -1
- package/lib/modules/vaults/getters.d.ts +11 -3
- package/lib/modules/vaults/getters.js +368 -33
- package/lib/modules/vaults/getters.js.map +1 -1
- package/lib/modules/vaults/main.d.ts +11 -1
- package/lib/modules/vaults/main.js +111 -40
- package/lib/modules/vaults/main.js.map +1 -1
- package/lib/modules/vaults/types.d.ts +1 -0
- package/lib/modules/vaults/utils.d.ts +2 -0
- package/lib/modules/vaults/utils.js +119 -1
- package/lib/modules/vaults/utils.js.map +1 -1
- package/lib/modules/vaults/write.actions.js +16 -2
- package/lib/modules/vaults/write.actions.js.map +1 -1
- package/lib/services/layerzero/deposits.d.ts +6 -0
- package/lib/services/layerzero/deposits.js +20 -2
- package/lib/services/layerzero/deposits.js.map +1 -1
- package/lib/services/layerzero/redeems.js +2 -2
- package/lib/services/layerzero/redeems.js.map +1 -1
- package/lib/services/subgraph/vaults.js +110 -50
- package/lib/services/subgraph/vaults.js.map +1 -1
- package/lib/types/vaults.d.ts +40 -8
- package/lib/types/vaults.js.map +1 -1
- package/lib/types/web3.d.ts +5 -0
- package/lib/types/web3.js +10 -0
- package/lib/types/web3.js.map +1 -1
- package/lib/types/webserver.d.ts +12 -2
- package/package.json +15 -12
- package/lib/modules/vaults/utils/callDataDecoder.d.ts +0 -14
- package/lib/modules/vaults/utils/callDataDecoder.js +0 -138
- package/lib/modules/vaults/utils/callDataDecoder.js.map +0 -1
- package/lib/modules/vaults/utils/dateUtils.d.ts +0 -11
- package/lib/modules/vaults/utils/dateUtils.js +0 -39
- package/lib/modules/vaults/utils/dateUtils.js.map +0 -1
- package/lib/modules/vaults/utils/index.d.ts +0 -2
- package/lib/modules/vaults/utils/index.js +0 -19
- package/lib/modules/vaults/utils/index.js.map +0 -1
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getVault = getVault;
|
|
40
40
|
exports.getVaultLoans = getVaultLoans;
|
|
41
|
+
exports.getVaultSubaccountLoans = getVaultSubaccountLoans;
|
|
41
42
|
exports.getVaultAllocations = getVaultAllocations;
|
|
42
43
|
exports.getVaultAvailableRedemptions = getVaultAvailableRedemptions;
|
|
43
44
|
exports.getVaultRedemptionHistory = getVaultRedemptionHistory;
|
|
@@ -57,18 +58,23 @@ exports.getVaultHistoricalTimeseries = getVaultHistoricalTimeseries;
|
|
|
57
58
|
exports.getVaultAnnualizedApy = getVaultAnnualizedApy;
|
|
58
59
|
exports.getVaultSummary = getVaultSummary;
|
|
59
60
|
exports.getVaultWithdrawals = getVaultWithdrawals;
|
|
61
|
+
exports.getVaultPendingRedemptions = getVaultPendingRedemptions;
|
|
60
62
|
exports.getPreviewRedemption = getPreviewRedemption;
|
|
61
63
|
exports.getWithdrawalRequestsWithStatus = getWithdrawalRequestsWithStatus;
|
|
62
64
|
const abis_1 = require("../../abis");
|
|
63
65
|
const types_1 = require("../../types");
|
|
64
66
|
const core_1 = require("../../core");
|
|
65
67
|
const ethers_1 = require("ethers");
|
|
68
|
+
const utils_1 = require("./utils");
|
|
66
69
|
const subgraph_1 = require("../../services/subgraph");
|
|
67
70
|
const vaults_1 = require("../../services/subgraph/vaults");
|
|
68
71
|
const debank_1 = require("../../services/debank");
|
|
69
|
-
const
|
|
72
|
+
const utils_2 = require("../../adapters/solana/utils");
|
|
70
73
|
const SolanaGetters = __importStar(require("../../adapters/solana/getters"));
|
|
71
74
|
const SolanaConstants = __importStar(require("../../adapters/solana/constants"));
|
|
75
|
+
const StellarGetters = __importStar(require("../../adapters/stellar/getters"));
|
|
76
|
+
const utils_3 = require("../../adapters/stellar/utils");
|
|
77
|
+
const constants_1 = require("../../adapters/stellar/constants");
|
|
72
78
|
const EVM = __importStar(require("../../adapters/evm"));
|
|
73
79
|
const TokenizedVaultV2_1 = require("../../abis/TokenizedVaultV2");
|
|
74
80
|
const TokenizedVaultV2Receipt_1 = require("../../abis/TokenizedVaultV2Receipt");
|
|
@@ -76,6 +82,8 @@ const ethereum_block_by_date_1 = __importDefault(require("ethereum-block-by-date
|
|
|
76
82
|
const octavfi_1 = require("../../services/octavfi");
|
|
77
83
|
const date_utils_1 = require("./utils/date-utils");
|
|
78
84
|
const call_data_decoder_1 = require("./utils/call-data-decoder");
|
|
85
|
+
const deposits_1 = require("../../services/layerzero/deposits");
|
|
86
|
+
const redeems_1 = require("../../services/layerzero/redeems");
|
|
79
87
|
async function getVault({ vault, loans = false, allocations = false, options, loadSubaccounts, loadSnapshots, }) {
|
|
80
88
|
let returnedVault;
|
|
81
89
|
try {
|
|
@@ -84,7 +92,12 @@ async function getVault({ vault, loans = false, allocations = false, options, lo
|
|
|
84
92
|
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
85
93
|
switch (vaultVersion) {
|
|
86
94
|
case 'sol-0': {
|
|
87
|
-
|
|
95
|
+
returnedVault = await SolanaGetters.getSolanaVault(tokenizedVault, options);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'stellar-0': {
|
|
99
|
+
returnedVault = await StellarGetters.getStellarVault(tokenizedVault, options);
|
|
100
|
+
break;
|
|
88
101
|
}
|
|
89
102
|
case 'evm-2': {
|
|
90
103
|
returnedVault = await EVM.getEvmVaultV2(tokenizedVault, options);
|
|
@@ -103,7 +116,13 @@ async function getVault({ vault, loans = false, allocations = false, options, lo
|
|
|
103
116
|
core_1.Logger.log.error('getVault', err, { vault });
|
|
104
117
|
throw new Error(`#getVault::${vault}: ${err?.message}`);
|
|
105
118
|
}
|
|
106
|
-
|
|
119
|
+
const isEvmVault = returnedVault.version !== 'sol-0' &&
|
|
120
|
+
returnedVault.version !== 'stellar-0' &&
|
|
121
|
+
returnedVault.version !== 'sui-0';
|
|
122
|
+
if (!isEvmVault && (loans || allocations)) {
|
|
123
|
+
core_1.Logger.log.warn('getVault', 'Loans/allocations enrichment is not supported for non-EVM vaults — skipping', { vault, version: returnedVault.version });
|
|
124
|
+
}
|
|
125
|
+
if (isEvmVault && !(0, core_1.isBadVault)(vault)) {
|
|
107
126
|
if (loans) {
|
|
108
127
|
try {
|
|
109
128
|
returnedVault = {
|
|
@@ -203,6 +222,74 @@ async function getVaultLoans(vault, options) {
|
|
|
203
222
|
throw new Error(`#getVaultLoans::${vault}:${e?.message}`);
|
|
204
223
|
}
|
|
205
224
|
}
|
|
225
|
+
async function getVaultSubaccountLoans(vault, options) {
|
|
226
|
+
const vaultAddress = typeof vault === 'string' ? vault : vault.address;
|
|
227
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vaultAddress))?.[0];
|
|
228
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
229
|
+
if (vaultVersion !== 'evm-0')
|
|
230
|
+
return [];
|
|
231
|
+
try {
|
|
232
|
+
let poolTotalSupply;
|
|
233
|
+
let poolDecimals;
|
|
234
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vaultAddress, options?.headers))?.[0];
|
|
235
|
+
const chainId = options?.chainId || tokenizedVault?.chain;
|
|
236
|
+
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
237
|
+
const tokenizedVaultLoans = await (0, core_1.fetchTokenizedVaultSubaccountLoans)(vaultAddress, chainId);
|
|
238
|
+
if (typeof vault === 'string') {
|
|
239
|
+
const poolContract = (0, core_1.createContract)({
|
|
240
|
+
provider,
|
|
241
|
+
address: vaultAddress,
|
|
242
|
+
abi: abis_1.ABI_LENDING_POOL_V2,
|
|
243
|
+
});
|
|
244
|
+
[poolTotalSupply, poolDecimals] = await Promise.all([
|
|
245
|
+
poolContract.totalSupply(),
|
|
246
|
+
(0, core_1.getDecimals)(provider, vaultAddress),
|
|
247
|
+
]);
|
|
248
|
+
poolTotalSupply = BigInt(poolTotalSupply).toString();
|
|
249
|
+
poolDecimals = Number(poolDecimals);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
poolTotalSupply = vault.totalSupply.raw;
|
|
253
|
+
poolDecimals = vault.decimals;
|
|
254
|
+
}
|
|
255
|
+
const newLoans = (await Promise.all((Array.isArray(tokenizedVaultLoans) ? tokenizedVaultLoans : [])?.map(async (l) => {
|
|
256
|
+
const borrower = l.borrower;
|
|
257
|
+
const allocation = l.principal_amount /
|
|
258
|
+
Number((0, ethers_1.formatUnits)(poolTotalSupply, poolDecimals));
|
|
259
|
+
const loanFeeRate = await (0, core_1.getLoanOracleFeeRate)(provider, 'LOAN.REPAY.INTERESTS', l.address, chainId);
|
|
260
|
+
const loanApr = Number(l.apr || 0) / 100;
|
|
261
|
+
const loanAprAfterFees = loanApr * (1 - loanFeeRate / 100);
|
|
262
|
+
const isIdleCapital = core_1.IDLE_CAPITAL_BORROWER_ADDRESS.includes(borrower);
|
|
263
|
+
const newLoanObj = {
|
|
264
|
+
vault: vaultAddress,
|
|
265
|
+
address: l.address,
|
|
266
|
+
lender: l.lender,
|
|
267
|
+
borrower: l.borrower,
|
|
268
|
+
state: l.state,
|
|
269
|
+
totalRepaid: l.total_repaid,
|
|
270
|
+
principalToken: l.principal_token,
|
|
271
|
+
principalAmount: l.principal_amount,
|
|
272
|
+
interestAmount: l.interest_amount,
|
|
273
|
+
upcomingPayment: {
|
|
274
|
+
amount: l.upcoming_payment.amount,
|
|
275
|
+
dueDate: l.upcoming_payment.due_date,
|
|
276
|
+
},
|
|
277
|
+
apr: loanAprAfterFees,
|
|
278
|
+
initialPrincipalAmount: l.initial_principal_amount,
|
|
279
|
+
deployedDate: l.deployed_date,
|
|
280
|
+
isIdleCapital,
|
|
281
|
+
paymentInterval: l.payment_interval,
|
|
282
|
+
allocation,
|
|
283
|
+
};
|
|
284
|
+
return newLoanObj;
|
|
285
|
+
}))).filter((l) => l !== undefined);
|
|
286
|
+
return newLoans;
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
core_1.Logger.log.error('getVaultSubaccountLoans', e, { vault });
|
|
290
|
+
throw new Error(`#getVaultSubaccountLoans::${vault}:${e?.message}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
206
293
|
async function getVaultAllocations(vault, options) {
|
|
207
294
|
const protocolExposure = [];
|
|
208
295
|
const tokenExposure = [];
|
|
@@ -324,7 +411,10 @@ async function getVaultAllocations(vault, options) {
|
|
|
324
411
|
try {
|
|
325
412
|
const cefiResponse = await (0, core_1.fetchAugustWithKey)(options.augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.cefi(borrower), { headers: options?.headers });
|
|
326
413
|
if (cefiResponse.status !== 200) {
|
|
327
|
-
|
|
414
|
+
core_1.Logger.log.error('getVaultAllocations:cefi', cefiResponse.statusText, {
|
|
415
|
+
borrower,
|
|
416
|
+
status: cefiResponse.status,
|
|
417
|
+
});
|
|
328
418
|
}
|
|
329
419
|
if (cefiResponse.status === 200) {
|
|
330
420
|
const cefiRes = (await cefiResponse.json());
|
|
@@ -332,12 +422,15 @@ async function getVaultAllocations(vault, options) {
|
|
|
332
422
|
}
|
|
333
423
|
}
|
|
334
424
|
catch (e) {
|
|
335
|
-
|
|
425
|
+
core_1.Logger.log.error('getVaultAllocations:cefi', e, { borrower });
|
|
336
426
|
}
|
|
337
427
|
try {
|
|
338
428
|
const otcResponse = await (0, core_1.fetchAugustWithKey)(options.augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.otc_positions(borrower), { headers: options?.headers });
|
|
339
429
|
if (otcResponse.status !== 200) {
|
|
340
|
-
|
|
430
|
+
core_1.Logger.log.error('getVaultAllocations:otc', otcResponse.statusText, {
|
|
431
|
+
borrower,
|
|
432
|
+
status: otcResponse.status,
|
|
433
|
+
});
|
|
341
434
|
}
|
|
342
435
|
if (otcResponse.status === 200) {
|
|
343
436
|
const otcRes = (await otcResponse.json());
|
|
@@ -345,7 +438,7 @@ async function getVaultAllocations(vault, options) {
|
|
|
345
438
|
}
|
|
346
439
|
}
|
|
347
440
|
catch (e) {
|
|
348
|
-
|
|
441
|
+
core_1.Logger.log.error('getVaultAllocations:otc', e, { borrower });
|
|
349
442
|
}
|
|
350
443
|
}
|
|
351
444
|
}
|
|
@@ -372,6 +465,17 @@ async function getVaultAllocations(vault, options) {
|
|
|
372
465
|
}
|
|
373
466
|
async function getVaultAvailableRedemptions({ vault, wallet, options, }) {
|
|
374
467
|
try {
|
|
468
|
+
if ((0, utils_3.isStellarAddress)(vault)) {
|
|
469
|
+
core_1.Logger.log.warn('getVaultAvailableRedemptions', `Available redemptions is not yet supported for Stellar vaults: ${vault}`);
|
|
470
|
+
return {
|
|
471
|
+
availableRedemptions: [],
|
|
472
|
+
pendingRedemptions: [],
|
|
473
|
+
...(options.verbose && {
|
|
474
|
+
processedWithdrawals: [],
|
|
475
|
+
requestedWithdrawals: [],
|
|
476
|
+
}),
|
|
477
|
+
};
|
|
478
|
+
}
|
|
375
479
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
376
480
|
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault, options?.headers, false, false))?.[0];
|
|
377
481
|
if (!tokenizedVault) {
|
|
@@ -623,9 +727,14 @@ async function getVaultAvailableRedemptions({ vault, wallet, options, }) {
|
|
|
623
727
|
}
|
|
624
728
|
async function getVaultRedemptionHistory({ vault, wallet, options, }) {
|
|
625
729
|
try {
|
|
730
|
+
if ((0, utils_3.isStellarAddress)(vault)) {
|
|
731
|
+
core_1.Logger.log.warn('getVaultRedemptionHistory', `Redemption history is not yet supported for Stellar vaults: ${vault}`);
|
|
732
|
+
return [];
|
|
733
|
+
}
|
|
626
734
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
627
735
|
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault, options?.headers, false, false))?.[0];
|
|
628
736
|
if (!tokenizedVault) {
|
|
737
|
+
core_1.Logger.log.warn('getVaultRedemptionHistory', `Vault not found in backend: ${vault}`);
|
|
629
738
|
return [];
|
|
630
739
|
}
|
|
631
740
|
const chainId = tokenizedVault.chain;
|
|
@@ -736,7 +845,7 @@ async function getVaultRedemptionHistory({ vault, wallet, options, }) {
|
|
|
736
845
|
return [];
|
|
737
846
|
}
|
|
738
847
|
}
|
|
739
|
-
async function getVaultPositions({ vault, wallet, solanaWallet, options, }) {
|
|
848
|
+
async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, options, }) {
|
|
740
849
|
try {
|
|
741
850
|
const tokenizedVaults = await (0, core_1.fetchTokenizedVault)(vault ? vault : undefined, options?.headers, false, false);
|
|
742
851
|
if (!tokenizedVaults || tokenizedVaults.length === 0) {
|
|
@@ -751,10 +860,10 @@ async function getVaultPositions({ vault, wallet, solanaWallet, options, }) {
|
|
|
751
860
|
}
|
|
752
861
|
const promises = await Promise.all(tokenizedVaults.map(async (v) => {
|
|
753
862
|
try {
|
|
754
|
-
if (
|
|
863
|
+
if (utils_2.SolanaUtils.isSolanaAddress(v.address)) {
|
|
755
864
|
let balance = (0, core_1.toNormalizedBn)(0);
|
|
756
|
-
if (
|
|
757
|
-
const vaultProgramId =
|
|
865
|
+
if (utils_2.SolanaUtils.isSolanaAddress(solanaWallet)) {
|
|
866
|
+
const vaultProgramId = utils_2.SolanaUtils.resolveProgramId(String(v.address), v.solana_vault_metadata);
|
|
758
867
|
const vaultStateRes = await options.solanaService.getVaultState(vaultProgramId, SolanaConstants.vaultIdl, v.solana_vault_metadata?.vault_state_pda ?? undefined);
|
|
759
868
|
if (vaultStateRes &&
|
|
760
869
|
vaultStateRes?.vaultState?.shareMint) {
|
|
@@ -770,6 +879,30 @@ async function getVaultPositions({ vault, wallet, solanaWallet, options, }) {
|
|
|
770
879
|
walletBalance: balance,
|
|
771
880
|
};
|
|
772
881
|
}
|
|
882
|
+
if ((0, utils_3.isStellarAddress)(v.address)) {
|
|
883
|
+
let balance = (0, core_1.toNormalizedBn)(0);
|
|
884
|
+
if (stellarWallet && (0, utils_3.isStellarAddress)(stellarWallet)) {
|
|
885
|
+
const stellarNetwork = v.stellar_vault_metadata?.network_name ?? 'mainnet';
|
|
886
|
+
const position = await StellarGetters.getStellarUserPosition(v.address, stellarWallet, stellarNetwork);
|
|
887
|
+
if (position) {
|
|
888
|
+
balance = (0, core_1.toNormalizedBn)(BigInt(position.shares), position.decimals);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
core_1.Logger.log.warn('getVaultPositions', 'Stellar position query failed — showing zero balance', { vault: v.address, wallet: stellarWallet });
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
else if (stellarWallet) {
|
|
895
|
+
core_1.Logger.log.warn('getVaultPositions', 'Invalid stellarWallet address format', { vault: v.address, stellarWallet });
|
|
896
|
+
}
|
|
897
|
+
return {
|
|
898
|
+
vault: v.address,
|
|
899
|
+
status: renderStatus([], balance),
|
|
900
|
+
availableRedemptions: [],
|
|
901
|
+
pendingRedemptions: [],
|
|
902
|
+
redeemable: (0, core_1.toNormalizedBn)(0),
|
|
903
|
+
walletBalance: balance,
|
|
904
|
+
};
|
|
905
|
+
}
|
|
773
906
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
774
907
|
let decimals;
|
|
775
908
|
const version = (0, core_1.getVaultVersionV2)(v);
|
|
@@ -827,7 +960,12 @@ async function getVaultPositions({ vault, wallet, solanaWallet, options, }) {
|
|
|
827
960
|
return promises.flat();
|
|
828
961
|
}
|
|
829
962
|
catch (e) {
|
|
830
|
-
core_1.Logger.log.error('getVaultPositions', e, {
|
|
963
|
+
core_1.Logger.log.error('getVaultPositions', e, {
|
|
964
|
+
vault,
|
|
965
|
+
wallet,
|
|
966
|
+
solanaWallet,
|
|
967
|
+
stellarWallet,
|
|
968
|
+
});
|
|
831
969
|
throw new Error(`#getVaultPositions::${vault}:${e?.message}`);
|
|
832
970
|
}
|
|
833
971
|
}
|
|
@@ -990,6 +1128,24 @@ async function getVaultTvl({ vault, options, historical, }) {
|
|
|
990
1128
|
}
|
|
991
1129
|
if (!historical) {
|
|
992
1130
|
const version = (0, core_1.getVaultVersionV2)(_vaultExists);
|
|
1131
|
+
if (version === 'sol-0') {
|
|
1132
|
+
return [
|
|
1133
|
+
{
|
|
1134
|
+
value: (0, core_1.toNormalizedBn)(0),
|
|
1135
|
+
timestamp: new Date().toISOString(),
|
|
1136
|
+
},
|
|
1137
|
+
];
|
|
1138
|
+
}
|
|
1139
|
+
if (version === 'stellar-0') {
|
|
1140
|
+
const stellarDecimals = _vaultExists?.stellar_vault_metadata?.deposit_token_decimals ??
|
|
1141
|
+
constants_1.STELLAR_FALLBACK_DECIMALS;
|
|
1142
|
+
return [
|
|
1143
|
+
{
|
|
1144
|
+
value: (0, utils_1.backendTvlToNormalizedBn)(_vaultExists?.latest_reported_tvl, stellarDecimals),
|
|
1145
|
+
timestamp: new Date().toISOString(),
|
|
1146
|
+
},
|
|
1147
|
+
];
|
|
1148
|
+
}
|
|
993
1149
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
994
1150
|
switch (version) {
|
|
995
1151
|
case 'evm-2': {
|
|
@@ -1008,14 +1164,6 @@ async function getVaultTvl({ vault, options, historical, }) {
|
|
|
1008
1164
|
},
|
|
1009
1165
|
];
|
|
1010
1166
|
}
|
|
1011
|
-
case 'sol-0': {
|
|
1012
|
-
return [
|
|
1013
|
-
{
|
|
1014
|
-
value: (0, core_1.toNormalizedBn)(0),
|
|
1015
|
-
timestamp: new Date().toISOString(),
|
|
1016
|
-
},
|
|
1017
|
-
];
|
|
1018
|
-
}
|
|
1019
1167
|
default: {
|
|
1020
1168
|
const vaultContract = (0, core_1.createContract)({
|
|
1021
1169
|
address: vault,
|
|
@@ -1034,12 +1182,16 @@ async function getVaultTvl({ vault, options, historical, }) {
|
|
|
1034
1182
|
}
|
|
1035
1183
|
}
|
|
1036
1184
|
else {
|
|
1185
|
+
const version = (0, core_1.getVaultVersionV2)(_vaultExists);
|
|
1186
|
+
if (version === 'stellar-0' || version === 'sol-0') {
|
|
1187
|
+
core_1.Logger.log.warn('getVaultTvl:historical', 'Historical TVL not supported for non-EVM vaults', { vault, version });
|
|
1188
|
+
return [];
|
|
1189
|
+
}
|
|
1037
1190
|
if (typeof historical !== 'undefined' && !historical.order)
|
|
1038
1191
|
historical.order = 'desc';
|
|
1039
1192
|
if (typeof historical !== 'undefined' && !historical.interval)
|
|
1040
1193
|
historical.interval = 'days';
|
|
1041
1194
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
1042
|
-
const version = (0, core_1.getVaultVersionV2)(_vaultExists);
|
|
1043
1195
|
const vaultContract = (0, core_1.createContract)({
|
|
1044
1196
|
address: vault,
|
|
1045
1197
|
abi: version === 'evm-2' ? TokenizedVaultV2_1.ABI_TOKENIZED_VAULT_V2 : abis_1.ABI_LENDING_POOL_V2,
|
|
@@ -1254,7 +1406,8 @@ async function getYieldLastRealizedOn({ vault, options, }) {
|
|
|
1254
1406
|
assetsUpdatedOn = await contract.assetsUpdatedOn();
|
|
1255
1407
|
break;
|
|
1256
1408
|
}
|
|
1257
|
-
case 'sol-0':
|
|
1409
|
+
case 'sol-0':
|
|
1410
|
+
case 'stellar-0': {
|
|
1258
1411
|
return 0;
|
|
1259
1412
|
}
|
|
1260
1413
|
default: {
|
|
@@ -1275,6 +1428,7 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1275
1428
|
throw new Error('Vault input parameter is undefined.');
|
|
1276
1429
|
if (!wallet)
|
|
1277
1430
|
throw new Error('Wallet input parameter is undefined.');
|
|
1431
|
+
(0, utils_3.assertNotStellar)(vault, 'Lifetime PnL');
|
|
1278
1432
|
if (!(0, ethers_1.isAddress)(vault))
|
|
1279
1433
|
throw new Error(`Vault input parameter is not an address: ${String(vault)}`);
|
|
1280
1434
|
if (!(0, ethers_1.isAddress)(wallet))
|
|
@@ -1294,6 +1448,30 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1294
1448
|
if (!tokenizedVault) {
|
|
1295
1449
|
throw new Error(`Vault ${vault} not found`);
|
|
1296
1450
|
}
|
|
1451
|
+
const lzVaultKey = (0, deposits_1.isLayerZeroVault)(vault);
|
|
1452
|
+
let lzDeposits = [];
|
|
1453
|
+
let lzRedeems = [];
|
|
1454
|
+
if (lzVaultKey) {
|
|
1455
|
+
const lzPromises = [
|
|
1456
|
+
(0, deposits_1.queryLayerZeroDeposits)(lzVaultKey, wallet)
|
|
1457
|
+
.then((d) => {
|
|
1458
|
+
lzDeposits = d;
|
|
1459
|
+
})
|
|
1460
|
+
.catch((e) => {
|
|
1461
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:lzDeposits', `Failed to fetch LZ deposits for ${lzVaultKey}: ${e}`);
|
|
1462
|
+
}),
|
|
1463
|
+
];
|
|
1464
|
+
if (lzVaultKey === 'earnAUSD') {
|
|
1465
|
+
lzPromises.push((0, redeems_1.queryLayerZeroRedeems)(wallet)
|
|
1466
|
+
.then((r) => {
|
|
1467
|
+
lzRedeems = r;
|
|
1468
|
+
})
|
|
1469
|
+
.catch((e) => {
|
|
1470
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:lzRedeems', `Failed to fetch LZ redeems for ${lzVaultKey}: ${e}`);
|
|
1471
|
+
}));
|
|
1472
|
+
}
|
|
1473
|
+
await Promise.all(lzPromises);
|
|
1474
|
+
}
|
|
1297
1475
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
1298
1476
|
const currentPosition = positions.find((pos) => pos.vault?.toLowerCase() === vault.toLowerCase());
|
|
1299
1477
|
const underlyingSymbolPromise = (async () => {
|
|
@@ -1350,9 +1528,22 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1350
1528
|
totalWithdrawalsInAssets += amount;
|
|
1351
1529
|
}
|
|
1352
1530
|
}
|
|
1531
|
+
if (lzVaultKey && lzDeposits.length > 0) {
|
|
1532
|
+
for (const lzDeposit of lzDeposits) {
|
|
1533
|
+
const assetKey = 'lz-default';
|
|
1534
|
+
const amount = BigInt(lzDeposit.assetAmt);
|
|
1535
|
+
const current = depositsByAsset.get(assetKey) ?? BigInt(0);
|
|
1536
|
+
depositsByAsset.set(assetKey, current + amount);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if (lzVaultKey && lzRedeems.length > 0) {
|
|
1540
|
+
for (const lzRedeem of lzRedeems) {
|
|
1541
|
+
totalWithdrawalsInShares += BigInt(lzRedeem.shareAmt);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1353
1544
|
const assetDecimals = new Map();
|
|
1354
1545
|
await Promise.all(Array.from(depositsByAsset.keys()).map(async (assetAddress) => {
|
|
1355
|
-
if (assetAddress === 'default') {
|
|
1546
|
+
if (assetAddress === 'default' || assetAddress === 'lz-default') {
|
|
1356
1547
|
assetDecimals.set(assetAddress, decimals);
|
|
1357
1548
|
}
|
|
1358
1549
|
else {
|
|
@@ -1368,7 +1559,7 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1368
1559
|
const assetPrices = new Map();
|
|
1369
1560
|
if (tokenizedVault.chain) {
|
|
1370
1561
|
await Promise.all(Array.from(depositsByAsset.keys()).map(async (assetAddress) => {
|
|
1371
|
-
if (assetAddress === 'default') {
|
|
1562
|
+
if (assetAddress === 'default' || assetAddress === 'lz-default') {
|
|
1372
1563
|
assetPrices.set(assetAddress, 0);
|
|
1373
1564
|
}
|
|
1374
1565
|
else {
|
|
@@ -1410,6 +1601,71 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1410
1601
|
else {
|
|
1411
1602
|
currentShares = await vaultContract.balanceOf(wallet);
|
|
1412
1603
|
}
|
|
1604
|
+
if (lzVaultKey) {
|
|
1605
|
+
const remoteChains = [];
|
|
1606
|
+
if (tokenizedVault.receipt_token_integrations?.length) {
|
|
1607
|
+
for (const rti of tokenizedVault.receipt_token_integrations) {
|
|
1608
|
+
if (rti.chain !== tokenizedVault.chain &&
|
|
1609
|
+
rti.address &&
|
|
1610
|
+
rti.chain) {
|
|
1611
|
+
remoteChains.push({
|
|
1612
|
+
chain: rti.chain,
|
|
1613
|
+
address: rti.address,
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
else {
|
|
1619
|
+
const lzVaultConfig = deposits_1.LAYERZERO_VAULTS[lzVaultKey];
|
|
1620
|
+
if (lzVaultConfig.spokeChains) {
|
|
1621
|
+
for (const [chainIdStr, address] of Object.entries(lzVaultConfig.spokeChains)) {
|
|
1622
|
+
const chainId = Number(chainIdStr);
|
|
1623
|
+
if (chainId !== tokenizedVault.chain) {
|
|
1624
|
+
remoteChains.push({
|
|
1625
|
+
chain: chainId,
|
|
1626
|
+
address: address,
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (remoteChains.length > 0) {
|
|
1633
|
+
const remoteBalances = await Promise.all(remoteChains.map(async ({ chain, address }) => {
|
|
1634
|
+
try {
|
|
1635
|
+
const rpcUrls = (0, core_1.getFallbackRpcUrls)(chain);
|
|
1636
|
+
if (!rpcUrls.length) {
|
|
1637
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:lzRemoteBalance', `No RPC URL for chain ${chain}, skipping balance check`);
|
|
1638
|
+
return BigInt(0);
|
|
1639
|
+
}
|
|
1640
|
+
const remoteProvider = (0, core_1.createProvider)(rpcUrls[0]);
|
|
1641
|
+
const remoteTokenContract = (0, core_1.createContract)({
|
|
1642
|
+
provider: remoteProvider,
|
|
1643
|
+
address,
|
|
1644
|
+
abi: abis_1.ABI_ERC20,
|
|
1645
|
+
});
|
|
1646
|
+
const [rawBalance, remoteDecimals] = await Promise.all([
|
|
1647
|
+
remoteTokenContract.balanceOf(wallet),
|
|
1648
|
+
remoteTokenContract.decimals(),
|
|
1649
|
+
]);
|
|
1650
|
+
const remDec = Number(remoteDecimals) || decimals;
|
|
1651
|
+
if (remDec > decimals) {
|
|
1652
|
+
return rawBalance / BigInt(10 ** (remDec - decimals));
|
|
1653
|
+
}
|
|
1654
|
+
else if (remDec < decimals) {
|
|
1655
|
+
return rawBalance * BigInt(10 ** (decimals - remDec));
|
|
1656
|
+
}
|
|
1657
|
+
return rawBalance;
|
|
1658
|
+
}
|
|
1659
|
+
catch (e) {
|
|
1660
|
+
core_1.Logger.log.warn('getVaultUserLifetimePnl:lzRemoteBalance', `Failed to fetch balance on chain ${chain}: ${e}`);
|
|
1661
|
+
return BigInt(0);
|
|
1662
|
+
}
|
|
1663
|
+
}));
|
|
1664
|
+
for (const bal of remoteBalances) {
|
|
1665
|
+
currentShares += bal;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1413
1669
|
if (version === 'evm-2') {
|
|
1414
1670
|
sharePriceRaw = await vaultContract.getSharePrice();
|
|
1415
1671
|
}
|
|
@@ -1450,7 +1706,7 @@ async function getVaultUserLifetimePnl({ vault, wallet, options, }) {
|
|
|
1450
1706
|
}
|
|
1451
1707
|
let totalDepositedUsd = 0;
|
|
1452
1708
|
for (const [assetAddress, normalizedAmount] of totalDepositedRaw) {
|
|
1453
|
-
const assetPrice = assetAddress === 'default'
|
|
1709
|
+
const assetPrice = assetAddress === 'default' || assetAddress === 'lz-default'
|
|
1454
1710
|
? effectiveTokenPrice
|
|
1455
1711
|
: assetPrices.get(assetAddress) || effectiveTokenPrice;
|
|
1456
1712
|
totalDepositedUsd += Number(normalizedAmount.normalized) * assetPrice;
|
|
@@ -1496,6 +1752,7 @@ async function getVaultPnl({ vault, options, }) {
|
|
|
1496
1752
|
try {
|
|
1497
1753
|
if (!vault)
|
|
1498
1754
|
throw new Error('Vault input parameter is undefined.');
|
|
1755
|
+
(0, utils_3.assertNotStellar)(vault, 'Vault PnL');
|
|
1499
1756
|
if (!(0, ethers_1.isAddress)(vault))
|
|
1500
1757
|
throw new Error(`Vault input parameter is not an address: ${String(vault)}`);
|
|
1501
1758
|
const vaultData = await getVault({
|
|
@@ -1617,6 +1874,7 @@ async function getVaultSummary({ vault, options, }) {
|
|
|
1617
1874
|
if (!vault) {
|
|
1618
1875
|
throw new Error('Vault address parameter is undefined.');
|
|
1619
1876
|
}
|
|
1877
|
+
(0, utils_3.assertNotStellar)(vault, 'Vault summary');
|
|
1620
1878
|
if (!(0, ethers_1.isAddress)(vault)) {
|
|
1621
1879
|
throw new Error(`Vault parameter is not an address: ${String(vault)}`);
|
|
1622
1880
|
}
|
|
@@ -1641,6 +1899,7 @@ async function getVaultWithdrawals({ vault, chain, options, }) {
|
|
|
1641
1899
|
if (!vault) {
|
|
1642
1900
|
throw new Error('Vault address parameter is undefined.');
|
|
1643
1901
|
}
|
|
1902
|
+
(0, utils_3.assertNotStellar)(vault, 'Vault withdrawals');
|
|
1644
1903
|
if (!(0, ethers_1.isAddress)(vault)) {
|
|
1645
1904
|
throw new Error(`Vault parameter is not an address: ${String(vault)}`);
|
|
1646
1905
|
}
|
|
@@ -1663,10 +1922,78 @@ async function getVaultWithdrawals({ vault, chain, options, }) {
|
|
|
1663
1922
|
throw new Error(`#getVaultWithdrawals::${vault}::${chain}:${errorMessage}`);
|
|
1664
1923
|
}
|
|
1665
1924
|
}
|
|
1925
|
+
async function getVaultPendingRedemptions({ vault, pastDays, futureDays, options, }) {
|
|
1926
|
+
try {
|
|
1927
|
+
if (!vault)
|
|
1928
|
+
throw new Error('Vault address parameter is undefined.');
|
|
1929
|
+
if (!(0, ethers_1.isAddress)(vault))
|
|
1930
|
+
throw new Error(`Vault parameter is not an address: ${String(vault)}`);
|
|
1931
|
+
if (pastDays !== undefined && (pastDays < 1 || pastDays > 30))
|
|
1932
|
+
throw new Error('pastDays must be between 1 and 30');
|
|
1933
|
+
if (futureDays !== undefined && (futureDays < 1 || futureDays > 30))
|
|
1934
|
+
throw new Error('futureDays must be between 1 and 30');
|
|
1935
|
+
const params = new URLSearchParams();
|
|
1936
|
+
if (pastDays !== undefined)
|
|
1937
|
+
params.set('past_days', pastDays.toString());
|
|
1938
|
+
if (futureDays !== undefined)
|
|
1939
|
+
params.set('future_days', futureDays.toString());
|
|
1940
|
+
const qs = params.toString();
|
|
1941
|
+
const endpoint = `${core_1.WEBSERVER_ENDPOINTS.public.vaults.pendingRedemptions(vault)}${qs ? `?${qs}` : ''}`;
|
|
1942
|
+
const response = await (0, core_1.fetchAugustPublic)(endpoint, {
|
|
1943
|
+
headers: options?.headers,
|
|
1944
|
+
server: 'public',
|
|
1945
|
+
});
|
|
1946
|
+
if (!response.ok) {
|
|
1947
|
+
throw new Error(`Failed to fetch pending redemptions: ${response.statusText}`);
|
|
1948
|
+
}
|
|
1949
|
+
const raw = await response.json();
|
|
1950
|
+
return {
|
|
1951
|
+
vault: {
|
|
1952
|
+
address: raw.vault.address,
|
|
1953
|
+
chainId: raw.vault.chain_id,
|
|
1954
|
+
name: raw.vault.name,
|
|
1955
|
+
symbol: raw.vault.symbol,
|
|
1956
|
+
},
|
|
1957
|
+
asset: {
|
|
1958
|
+
address: raw.asset.address,
|
|
1959
|
+
symbol: raw.asset.symbol,
|
|
1960
|
+
decimals: raw.asset.decimals,
|
|
1961
|
+
},
|
|
1962
|
+
liquidity: {
|
|
1963
|
+
available: raw.liquidity.available,
|
|
1964
|
+
},
|
|
1965
|
+
summary: {
|
|
1966
|
+
totalPending: raw.summary.total_pending,
|
|
1967
|
+
pendingCount: raw.summary.pending_count,
|
|
1968
|
+
pendingToLiquidityRatio: raw.summary.pending_to_liquidity_ratio,
|
|
1969
|
+
isLiquiditySufficient: raw.summary.is_liquidity_sufficient,
|
|
1970
|
+
shortfall: raw.summary.shortfall,
|
|
1971
|
+
nextRedemptionDate: raw.summary.next_redemption_date,
|
|
1972
|
+
isOverdue: raw.summary.is_overdue,
|
|
1973
|
+
},
|
|
1974
|
+
redemptionsByDate: raw.redemptions_by_date.map((item) => ({
|
|
1975
|
+
date: item.date,
|
|
1976
|
+
assets: item.assets,
|
|
1977
|
+
daysUntilDue: item.days_until_due,
|
|
1978
|
+
isOverdue: item.is_overdue,
|
|
1979
|
+
})),
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
catch (e) {
|
|
1983
|
+
core_1.Logger.log.error('getVaultPendingRedemptions', e, {
|
|
1984
|
+
vault,
|
|
1985
|
+
pastDays,
|
|
1986
|
+
futureDays,
|
|
1987
|
+
});
|
|
1988
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
1989
|
+
throw new Error(`#getVaultPendingRedemptions::${vault}:${errorMessage}`);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1666
1992
|
async function getPreviewRedemption({ vault, sharesAmount, options, }) {
|
|
1667
1993
|
try {
|
|
1668
1994
|
if (!vault)
|
|
1669
1995
|
throw new Error('Vault address parameter is undefined.');
|
|
1996
|
+
(0, utils_3.assertNotStellar)(vault, 'Preview redemption');
|
|
1670
1997
|
if (!(0, ethers_1.isAddress)(vault)) {
|
|
1671
1998
|
throw new Error(`Vault parameter is not an address: ${String(vault)}`);
|
|
1672
1999
|
}
|
|
@@ -1732,6 +2059,7 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1732
2059
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
1733
2060
|
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vaultAddress, options?.headers, false, false))?.[0];
|
|
1734
2061
|
if (!tokenizedVault) {
|
|
2062
|
+
core_1.Logger.log.warn('getWithdrawalRequestsWithStatus', `Vault not found in backend: ${vaultAddress}`);
|
|
1735
2063
|
return [];
|
|
1736
2064
|
}
|
|
1737
2065
|
const version = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
@@ -1750,7 +2078,7 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1750
2078
|
}
|
|
1751
2079
|
}
|
|
1752
2080
|
catch (e) {
|
|
1753
|
-
core_1.Logger.log.warn(`Failed to fetch lagDuration from vault, using default 1 day: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
2081
|
+
core_1.Logger.log.warn('getWithdrawalRequestsWithStatus', `Failed to fetch lagDuration from vault ${vaultAddress}, using default 1 day — status determinations may be inaccurate: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
1754
2082
|
}
|
|
1755
2083
|
const [withdrawalRequests, processedEvents] = await Promise.all([
|
|
1756
2084
|
(0, vaults_1.getSubgraphWithdrawRequests)(vaultAddress, provider),
|
|
@@ -1783,7 +2111,7 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1783
2111
|
}
|
|
1784
2112
|
}
|
|
1785
2113
|
catch (e) {
|
|
1786
|
-
core_1.Logger.log.warn(`Failed to decode processed transaction ${processed.transactionHash}: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
2114
|
+
core_1.Logger.log.warn('getWithdrawalRequestsWithStatus', `Failed to decode processed transaction ${processed.transactionHash}: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
1787
2115
|
}
|
|
1788
2116
|
}
|
|
1789
2117
|
const requestedEpoch = Math.floor(processed.requested.getTime() / 1000);
|
|
@@ -1815,10 +2143,8 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1815
2143
|
}
|
|
1816
2144
|
const dateKey = (0, date_utils_1.formatDateKey)(processed.decodedDate.year, processed.decodedDate.month, processed.decodedDate.day);
|
|
1817
2145
|
const key = `${processed.receiver.toLowerCase()}:${dateKey}`;
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
processedMap.set(key, processed);
|
|
2146
|
+
const existing = processedMap.get(key) ?? [];
|
|
2147
|
+
processedMap.set(key, [...existing, processed]);
|
|
1822
2148
|
}
|
|
1823
2149
|
const chainId = tokenizedVault.chain;
|
|
1824
2150
|
const effectiveLookbackBlocks = params.lookbackBlocks ?? (0, core_1.determineBlockCutoff)(chainId);
|
|
@@ -1834,7 +2160,10 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1834
2160
|
let assetsReceived;
|
|
1835
2161
|
const dateKey = (0, date_utils_1.formatDateKey)(claimableDate.year, claimableDate.month, claimableDate.day);
|
|
1836
2162
|
const lookupKey = `${req.receiverAddr.toLowerCase()}:${dateKey}`;
|
|
1837
|
-
const
|
|
2163
|
+
const processedEvents = processedMap.get(lookupKey);
|
|
2164
|
+
const processedEvent = processedEvents && processedEvents.length > 0
|
|
2165
|
+
? processedEvents.shift()
|
|
2166
|
+
: undefined;
|
|
1838
2167
|
if (processedEvent) {
|
|
1839
2168
|
status = 'processed';
|
|
1840
2169
|
processedTxHash = processedEvent.transactionHash;
|
|
@@ -1859,7 +2188,13 @@ async function getWithdrawalRequestsWithStatus(params) {
|
|
|
1859
2188
|
return BigInt(req.shares);
|
|
1860
2189
|
}
|
|
1861
2190
|
catch {
|
|
1862
|
-
|
|
2191
|
+
const truncated = Math.trunc(Number(req.shares));
|
|
2192
|
+
if (!Number.isFinite(truncated)) {
|
|
2193
|
+
core_1.Logger.log.warn('getWithdrawalRequestsWithStatus', `Cannot parse shares value "${req.shares}" — defaulting to 0`);
|
|
2194
|
+
return BigInt(0);
|
|
2195
|
+
}
|
|
2196
|
+
core_1.Logger.log.info('getWithdrawalRequestsWithStatus', `Truncated decimal shares "${req.shares}" → ${truncated}`);
|
|
2197
|
+
return BigInt(truncated);
|
|
1863
2198
|
}
|
|
1864
2199
|
})(),
|
|
1865
2200
|
receiver: req.receiverAddr,
|