@lagoon-protocol/lagoon-mcp 0.1.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/LICENSE +201 -0
- package/README.md +618 -0
- package/dist/cache/index.d.ts +97 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +106 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +40 -0
- package/dist/config.js.map +1 -0
- package/dist/core/cache-adapter.d.ts +73 -0
- package/dist/core/cache-adapter.d.ts.map +1 -0
- package/dist/core/cache-adapter.js +47 -0
- package/dist/core/cache-adapter.js.map +1 -0
- package/dist/core/cache-invalidation.d.ts +72 -0
- package/dist/core/cache-invalidation.d.ts.map +1 -0
- package/dist/core/cache-invalidation.js +114 -0
- package/dist/core/cache-invalidation.js.map +1 -0
- package/dist/core/container.d.ts +34 -0
- package/dist/core/container.d.ts.map +1 -0
- package/dist/core/container.js +75 -0
- package/dist/core/container.js.map +1 -0
- package/dist/graphql/client.d.ts +32 -0
- package/dist/graphql/client.d.ts.map +1 -0
- package/dist/graphql/client.js +49 -0
- package/dist/graphql/client.js.map +1 -0
- package/dist/graphql/fragments/apr-breakdown.fragment.d.ts +64 -0
- package/dist/graphql/fragments/apr-breakdown.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/apr-breakdown.fragment.js +62 -0
- package/dist/graphql/fragments/apr-breakdown.fragment.js.map +1 -0
- package/dist/graphql/fragments/asset-info.fragment.d.ts +18 -0
- package/dist/graphql/fragments/asset-info.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/asset-info.fragment.js +36 -0
- package/dist/graphql/fragments/asset-info.fragment.js.map +1 -0
- package/dist/graphql/fragments/chain-info.fragment.d.ts +18 -0
- package/dist/graphql/fragments/chain-info.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/chain-info.fragment.js +32 -0
- package/dist/graphql/fragments/chain-info.fragment.js.map +1 -0
- package/dist/graphql/fragments/index.d.ts +15 -0
- package/dist/graphql/fragments/index.d.ts.map +1 -0
- package/dist/graphql/fragments/index.js +21 -0
- package/dist/graphql/fragments/index.js.map +1 -0
- package/dist/graphql/fragments/pageinfo.fragment.d.ts +33 -0
- package/dist/graphql/fragments/pageinfo.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/pageinfo.fragment.js +47 -0
- package/dist/graphql/fragments/pageinfo.fragment.js.map +1 -0
- package/dist/graphql/fragments/transaction-base.fragment.d.ts +19 -0
- package/dist/graphql/fragments/transaction-base.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/transaction-base.fragment.js +32 -0
- package/dist/graphql/fragments/transaction-base.fragment.js.map +1 -0
- package/dist/graphql/fragments/vault-list.fragment.d.ts +53 -0
- package/dist/graphql/fragments/vault-list.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/vault-list.fragment.js +51 -0
- package/dist/graphql/fragments/vault-list.fragment.js.map +1 -0
- package/dist/graphql/fragments/vault-summary.fragment.d.ts +68 -0
- package/dist/graphql/fragments/vault-summary.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/vault-summary.fragment.js +66 -0
- package/dist/graphql/fragments/vault-summary.fragment.js.map +1 -0
- package/dist/graphql/fragments/vault.fragment.d.ts +133 -0
- package/dist/graphql/fragments/vault.fragment.d.ts.map +1 -0
- package/dist/graphql/fragments/vault.fragment.js +119 -0
- package/dist/graphql/fragments/vault.fragment.js.map +1 -0
- package/dist/graphql/fragments.d.ts +183 -0
- package/dist/graphql/fragments.d.ts.map +1 -0
- package/dist/graphql/fragments.js +297 -0
- package/dist/graphql/fragments.js.map +1 -0
- package/dist/graphql/queries/export.queries.d.ts +72 -0
- package/dist/graphql/queries/export.queries.d.ts.map +1 -0
- package/dist/graphql/queries/export.queries.js +202 -0
- package/dist/graphql/queries/export.queries.js.map +1 -0
- package/dist/graphql/queries/index.d.ts +15 -0
- package/dist/graphql/queries/index.d.ts.map +1 -0
- package/dist/graphql/queries/index.js +23 -0
- package/dist/graphql/queries/index.js.map +1 -0
- package/dist/graphql/queries/performance.queries.d.ts +63 -0
- package/dist/graphql/queries/performance.queries.d.ts.map +1 -0
- package/dist/graphql/queries/performance.queries.js +133 -0
- package/dist/graphql/queries/performance.queries.js.map +1 -0
- package/dist/graphql/queries/period-summaries.d.ts +15 -0
- package/dist/graphql/queries/period-summaries.d.ts.map +1 -0
- package/dist/graphql/queries/period-summaries.js +24 -0
- package/dist/graphql/queries/period-summaries.js.map +1 -0
- package/dist/graphql/queries/portfolio.queries.d.ts +78 -0
- package/dist/graphql/queries/portfolio.queries.d.ts.map +1 -0
- package/dist/graphql/queries/portfolio.queries.js +198 -0
- package/dist/graphql/queries/portfolio.queries.js.map +1 -0
- package/dist/graphql/queries/prediction.queries.d.ts +38 -0
- package/dist/graphql/queries/prediction.queries.d.ts.map +1 -0
- package/dist/graphql/queries/prediction.queries.js +100 -0
- package/dist/graphql/queries/prediction.queries.js.map +1 -0
- package/dist/graphql/queries/risk.queries.d.ts +37 -0
- package/dist/graphql/queries/risk.queries.d.ts.map +1 -0
- package/dist/graphql/queries/risk.queries.js +90 -0
- package/dist/graphql/queries/risk.queries.js.map +1 -0
- package/dist/graphql/queries/search.queries.d.ts +61 -0
- package/dist/graphql/queries/search.queries.d.ts.map +1 -0
- package/dist/graphql/queries/search.queries.js +103 -0
- package/dist/graphql/queries/search.queries.js.map +1 -0
- package/dist/graphql/queries/transaction.queries.d.ts +60 -0
- package/dist/graphql/queries/transaction.queries.d.ts.map +1 -0
- package/dist/graphql/queries/transaction.queries.js +252 -0
- package/dist/graphql/queries/transaction.queries.js.map +1 -0
- package/dist/graphql/queries/vault.queries.d.ts +54 -0
- package/dist/graphql/queries/vault.queries.d.ts.map +1 -0
- package/dist/graphql/queries/vault.queries.js +78 -0
- package/dist/graphql/queries/vault.queries.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/competitor-comparison.d.ts +8 -0
- package/dist/prompts/competitor-comparison.d.ts.map +1 -0
- package/dist/prompts/competitor-comparison.js +432 -0
- package/dist/prompts/competitor-comparison.js.map +1 -0
- package/dist/prompts/curator-performance.d.ts +8 -0
- package/dist/prompts/curator-performance.d.ts.map +1 -0
- package/dist/prompts/curator-performance.js +383 -0
- package/dist/prompts/curator-performance.js.map +1 -0
- package/dist/prompts/financial-analysis.d.ts +8 -0
- package/dist/prompts/financial-analysis.d.ts.map +1 -0
- package/dist/prompts/financial-analysis.js +480 -0
- package/dist/prompts/financial-analysis.js.map +1 -0
- package/dist/prompts/index.d.ts +21 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +50 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/onboarding-first-vault.d.ts +8 -0
- package/dist/prompts/onboarding-first-vault.d.ts.map +1 -0
- package/dist/prompts/onboarding-first-vault.js +317 -0
- package/dist/prompts/onboarding-first-vault.js.map +1 -0
- package/dist/prompts/portfolio-optimization.d.ts +8 -0
- package/dist/prompts/portfolio-optimization.d.ts.map +1 -0
- package/dist/prompts/portfolio-optimization.js +412 -0
- package/dist/prompts/portfolio-optimization.js.map +1 -0
- package/dist/prompts/protocol-overview.d.ts +8 -0
- package/dist/prompts/protocol-overview.d.ts.map +1 -0
- package/dist/prompts/protocol-overview.js +398 -0
- package/dist/prompts/protocol-overview.js.map +1 -0
- package/dist/prompts/shared/disclaimers.d.ts +54 -0
- package/dist/prompts/shared/disclaimers.d.ts.map +1 -0
- package/dist/prompts/shared/disclaimers.js +400 -0
- package/dist/prompts/shared/disclaimers.js.map +1 -0
- package/dist/resources/glossary.d.ts +8 -0
- package/dist/resources/glossary.d.ts.map +1 -0
- package/dist/resources/glossary.js +407 -0
- package/dist/resources/glossary.js.map +1 -0
- package/dist/resources/index.d.ts +18 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +29 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/schema.d.ts +22 -0
- package/dist/resources/schema.d.ts.map +1 -0
- package/dist/resources/schema.js +67 -0
- package/dist/resources/schema.js.map +1 -0
- package/dist/schemas/config.schema.d.ts +46 -0
- package/dist/schemas/config.schema.d.ts.map +1 -0
- package/dist/schemas/config.schema.js +48 -0
- package/dist/schemas/config.schema.js.map +1 -0
- package/dist/sdk/__tests__/apr-service.test.d.ts +7 -0
- package/dist/sdk/__tests__/apr-service.test.d.ts.map +1 -0
- package/dist/sdk/__tests__/apr-service.test.js +385 -0
- package/dist/sdk/__tests__/apr-service.test.js.map +1 -0
- package/dist/sdk/__tests__/math-utils.test.d.ts +7 -0
- package/dist/sdk/__tests__/math-utils.test.d.ts.map +1 -0
- package/dist/sdk/__tests__/math-utils.test.js +185 -0
- package/dist/sdk/__tests__/math-utils.test.js.map +1 -0
- package/dist/sdk/__tests__/simulation-service.test.d.ts +5 -0
- package/dist/sdk/__tests__/simulation-service.test.d.ts.map +1 -0
- package/dist/sdk/__tests__/simulation-service.test.js +397 -0
- package/dist/sdk/__tests__/simulation-service.test.js.map +1 -0
- package/dist/sdk/__tests__/vault-utils.test.d.ts +7 -0
- package/dist/sdk/__tests__/vault-utils.test.d.ts.map +1 -0
- package/dist/sdk/__tests__/vault-utils.test.js +189 -0
- package/dist/sdk/__tests__/vault-utils.test.js.map +1 -0
- package/dist/sdk/apr-service.d.ts +101 -0
- package/dist/sdk/apr-service.d.ts.map +1 -0
- package/dist/sdk/apr-service.js +175 -0
- package/dist/sdk/apr-service.js.map +1 -0
- package/dist/sdk/math-utils.d.ts +138 -0
- package/dist/sdk/math-utils.d.ts.map +1 -0
- package/dist/sdk/math-utils.js +218 -0
- package/dist/sdk/math-utils.js.map +1 -0
- package/dist/sdk/simulation-service.d.ts +106 -0
- package/dist/sdk/simulation-service.d.ts.map +1 -0
- package/dist/sdk/simulation-service.js +143 -0
- package/dist/sdk/simulation-service.js.map +1 -0
- package/dist/sdk/vault-utils.d.ts +125 -0
- package/dist/sdk/vault-utils.d.ts.map +1 -0
- package/dist/sdk/vault-utils.js +165 -0
- package/dist/sdk/vault-utils.js.map +1 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +225 -0
- package/dist/server.js.map +1 -0
- package/dist/services/analytics/protocol-overview.service.d.ts +61 -0
- package/dist/services/analytics/protocol-overview.service.d.ts.map +1 -0
- package/dist/services/analytics/protocol-overview.service.js +182 -0
- package/dist/services/analytics/protocol-overview.service.js.map +1 -0
- package/dist/services/analytics/risk.service.d.ts +92 -0
- package/dist/services/analytics/risk.service.d.ts.map +1 -0
- package/dist/services/analytics/risk.service.js +423 -0
- package/dist/services/analytics/risk.service.js.map +1 -0
- package/dist/services/base.service.d.ts +39 -0
- package/dist/services/base.service.d.ts.map +1 -0
- package/dist/services/base.service.js +37 -0
- package/dist/services/base.service.js.map +1 -0
- package/dist/services/index.d.ts +30 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +101 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tools/__tests__/simulate-vault.test.d.ts +5 -0
- package/dist/tools/__tests__/simulate-vault.test.d.ts.map +1 -0
- package/dist/tools/__tests__/simulate-vault.test.js +363 -0
- package/dist/tools/__tests__/simulate-vault.test.js.map +1 -0
- package/dist/tools/analyze-risk.d.ts +34 -0
- package/dist/tools/analyze-risk.d.ts.map +1 -0
- package/dist/tools/analyze-risk.js +100 -0
- package/dist/tools/analyze-risk.js.map +1 -0
- package/dist/tools/compare-vaults.d.ts +29 -0
- package/dist/tools/compare-vaults.d.ts.map +1 -0
- package/dist/tools/compare-vaults.js +285 -0
- package/dist/tools/compare-vaults.js.map +1 -0
- package/dist/tools/export-data.d.ts +34 -0
- package/dist/tools/export-data.d.ts.map +1 -0
- package/dist/tools/export-data.js +309 -0
- package/dist/tools/export-data.js.map +1 -0
- package/dist/tools/get-price-history.d.ts +29 -0
- package/dist/tools/get-price-history.d.ts.map +1 -0
- package/dist/tools/get-price-history.js +236 -0
- package/dist/tools/get-price-history.js.map +1 -0
- package/dist/tools/get-transactions.d.ts +29 -0
- package/dist/tools/get-transactions.d.ts.map +1 -0
- package/dist/tools/get-transactions.js +181 -0
- package/dist/tools/get-transactions.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +32 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/optimize-portfolio.d.ts +37 -0
- package/dist/tools/optimize-portfolio.d.ts.map +1 -0
- package/dist/tools/optimize-portfolio.js +459 -0
- package/dist/tools/optimize-portfolio.js.map +1 -0
- package/dist/tools/predict-yield.d.ts +30 -0
- package/dist/tools/predict-yield.d.ts.map +1 -0
- package/dist/tools/predict-yield.js +248 -0
- package/dist/tools/predict-yield.js.map +1 -0
- package/dist/tools/query-graphql.d.ts +35 -0
- package/dist/tools/query-graphql.d.ts.map +1 -0
- package/dist/tools/query-graphql.js +54 -0
- package/dist/tools/query-graphql.js.map +1 -0
- package/dist/tools/registry.d.ts +42 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +231 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search-vaults.d.ts +40 -0
- package/dist/tools/search-vaults.d.ts.map +1 -0
- package/dist/tools/search-vaults.js +184 -0
- package/dist/tools/search-vaults.js.map +1 -0
- package/dist/tools/simulate-vault.d.ts +80 -0
- package/dist/tools/simulate-vault.d.ts.map +1 -0
- package/dist/tools/simulate-vault.js +281 -0
- package/dist/tools/simulate-vault.js.map +1 -0
- package/dist/tools/user-portfolio.d.ts +30 -0
- package/dist/tools/user-portfolio.d.ts.map +1 -0
- package/dist/tools/user-portfolio.js +142 -0
- package/dist/tools/user-portfolio.js.map +1 -0
- package/dist/tools/vault-data.d.ts +23 -0
- package/dist/tools/vault-data.d.ts.map +1 -0
- package/dist/tools/vault-data.js +68 -0
- package/dist/tools/vault-data.js.map +1 -0
- package/dist/tools/vault-performance.d.ts +30 -0
- package/dist/tools/vault-performance.d.ts.map +1 -0
- package/dist/tools/vault-performance.js +275 -0
- package/dist/tools/vault-performance.js.map +1 -0
- package/dist/types/generated.d.ts +1109 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/generated.js +2 -0
- package/dist/types/generated.js.map +1 -0
- package/dist/types/index.d.ts +46 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/comparison-metrics.d.ts +120 -0
- package/dist/utils/comparison-metrics.d.ts.map +1 -0
- package/dist/utils/comparison-metrics.js +215 -0
- package/dist/utils/comparison-metrics.js.map +1 -0
- package/dist/utils/config-loader.d.ts +17 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +45 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/csv-generator.d.ts +89 -0
- package/dist/utils/csv-generator.d.ts.map +1 -0
- package/dist/utils/csv-generator.js +97 -0
- package/dist/utils/csv-generator.js.map +1 -0
- package/dist/utils/disclaimers.d.ts +70 -0
- package/dist/utils/disclaimers.d.ts.map +1 -0
- package/dist/utils/disclaimers.js +161 -0
- package/dist/utils/disclaimers.js.map +1 -0
- package/dist/utils/errors.d.ts +66 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +86 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/execute-tool-with-cache.d.ts +97 -0
- package/dist/utils/execute-tool-with-cache.d.ts.map +1 -0
- package/dist/utils/execute-tool-with-cache.js +105 -0
- package/dist/utils/execute-tool-with-cache.js.map +1 -0
- package/dist/utils/portfolio-optimization.d.ts +100 -0
- package/dist/utils/portfolio-optimization.d.ts.map +1 -0
- package/dist/utils/portfolio-optimization.js +283 -0
- package/dist/utils/portfolio-optimization.js.map +1 -0
- package/dist/utils/risk-scoring.d.ts +226 -0
- package/dist/utils/risk-scoring.d.ts.map +1 -0
- package/dist/utils/risk-scoring.js +523 -0
- package/dist/utils/risk-scoring.js.map +1 -0
- package/dist/utils/tool-error-handler.d.ts +16 -0
- package/dist/utils/tool-error-handler.d.ts.map +1 -0
- package/dist/utils/tool-error-handler.js +43 -0
- package/dist/utils/tool-error-handler.js.map +1 -0
- package/dist/utils/tool-handler.d.ts +33 -0
- package/dist/utils/tool-handler.d.ts.map +1 -0
- package/dist/utils/tool-handler.js +59 -0
- package/dist/utils/tool-handler.js.map +1 -0
- package/dist/utils/tool-response.d.ts +16 -0
- package/dist/utils/tool-response.d.ts.map +1 -0
- package/dist/utils/tool-response.js +25 -0
- package/dist/utils/tool-response.js.map +1 -0
- package/dist/utils/validators.d.ts +359 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +233 -0
- package/dist/utils/validators.js.map +1 -0
- package/dist/utils/yield-prediction.d.ts +69 -0
- package/dist/utils/yield-prediction.d.ts.map +1 -0
- package/dist/utils/yield-prediction.js +290 -0
- package/dist/utils/yield-prediction.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APR Service Module
|
|
3
|
+
*
|
|
4
|
+
* Production-validated APR calculations using Lagoon SDK.
|
|
5
|
+
* Patterns from frontend-dapp-v2/src/lib/manage/apr-data-service.ts
|
|
6
|
+
*
|
|
7
|
+
* @module sdk/apr-service
|
|
8
|
+
*/
|
|
9
|
+
import type { VaultData } from '../graphql/fragments/index.js';
|
|
10
|
+
import type { Vault } from '../types/generated.js';
|
|
11
|
+
/**
|
|
12
|
+
* Period summary structure from GraphQL
|
|
13
|
+
*/
|
|
14
|
+
export interface PeriodSummary {
|
|
15
|
+
timestamp: string;
|
|
16
|
+
totalAssetsAtStart: string;
|
|
17
|
+
totalSupplyAtStart: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* APR historical data point
|
|
21
|
+
*/
|
|
22
|
+
export interface APRDataPoint {
|
|
23
|
+
timestamp: number;
|
|
24
|
+
pricePerShare: bigint;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* APR historical data structure
|
|
28
|
+
*/
|
|
29
|
+
export interface APRHistoricalData {
|
|
30
|
+
thirtyDay?: APRDataPoint;
|
|
31
|
+
inception?: APRDataPoint;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Transform period summaries to APR historical data
|
|
35
|
+
*
|
|
36
|
+
* Production pattern from frontend-dapp-v2/src/lib/manage/apr-data-service.ts
|
|
37
|
+
*
|
|
38
|
+
* Extracts 30-day and inception data points using SDK's getLastPeriodSummaryInDuration.
|
|
39
|
+
* Gracefully handles new vaults with no history (returns empty object).
|
|
40
|
+
*
|
|
41
|
+
* @param periodSummaries - Historical period summaries from GraphQL
|
|
42
|
+
* @param vault - Vault data for decimal calculations
|
|
43
|
+
* @returns APR historical data with optional 30-day and inception points
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const aprData = transformPeriodSummariesToAPRData(periodSummaries, vault);
|
|
48
|
+
*
|
|
49
|
+
* if (aprData.thirtyDay) {
|
|
50
|
+
* console.log('30-day price:', aprData.thirtyDay.pricePerShare);
|
|
51
|
+
* console.log('Timestamp:', aprData.thirtyDay.timestamp);
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function transformPeriodSummariesToAPRData(periodSummaries: PeriodSummary[], vault: Vault | VaultData): APRHistoricalData;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate APR from price per share change
|
|
58
|
+
*
|
|
59
|
+
* Computes annualized percentage return based on price per share change over time.
|
|
60
|
+
* Uses precise BigInt math to avoid floating-point errors.
|
|
61
|
+
*
|
|
62
|
+
* @param oldPrice - Historical price per share
|
|
63
|
+
* @param newPrice - Current price per share
|
|
64
|
+
* @param daysElapsed - Number of days between prices
|
|
65
|
+
* @returns APR as percentage (e.g., 15.5 for 15.5%)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const apr = calculateAPRFromPriceChange(
|
|
70
|
+
* 1000000n, // 1.0 USDC (6 decimals)
|
|
71
|
+
* 1025000n, // 1.025 USDC
|
|
72
|
+
* 30 // 30 days
|
|
73
|
+
* );
|
|
74
|
+
* // => ~30.42% APR (2.5% in 30 days, annualized)
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function calculateAPRFromPriceChange(oldPrice: bigint, newPrice: bigint, daysElapsed: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* Calculate current APR from historical data
|
|
80
|
+
*
|
|
81
|
+
* Convenience function that combines APR historical data with current price
|
|
82
|
+
* to compute 30-day and inception APR values.
|
|
83
|
+
*
|
|
84
|
+
* @param aprData - APR historical data with 30-day and/or inception points
|
|
85
|
+
* @param currentPricePerShare - Current price per share
|
|
86
|
+
* @returns Object with 30-day and inception APR values (undefined if no data)
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const aprs = calculateCurrentAPR(aprData, currentPrice);
|
|
91
|
+
*
|
|
92
|
+
* if (aprs.thirtyDay !== undefined) {
|
|
93
|
+
* console.log(`30-day APR: ${aprs.thirtyDay.toFixed(2)}%`);
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function calculateCurrentAPR(aprData: APRHistoricalData, currentPricePerShare: bigint): {
|
|
98
|
+
thirtyDay?: number;
|
|
99
|
+
inception?: number;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=apr-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apr-service.d.ts","sourceRoot":"","sources":["../../src/sdk/apr-service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAOnD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAWD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iCAAiC,CAC/C,eAAe,EAAE,aAAa,EAAE,EAChC,KAAK,EAAE,KAAK,GAAG,SAAS,GACvB,iBAAiB,CAqDnB;AAoCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAaR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,iBAAiB,EAC1B,oBAAoB,EAAE,MAAM,GAC3B;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CA4B5C"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APR Service Module
|
|
3
|
+
*
|
|
4
|
+
* Production-validated APR calculations using Lagoon SDK.
|
|
5
|
+
* Patterns from frontend-dapp-v2/src/lib/manage/apr-data-service.ts
|
|
6
|
+
*
|
|
7
|
+
* @module sdk/apr-service
|
|
8
|
+
*/
|
|
9
|
+
import * as LagoonCore from '@lagoon-protocol/v0-core';
|
|
10
|
+
import { getLastPeriodSummaryInDuration } from '@lagoon-protocol/v0-computation';
|
|
11
|
+
/**
|
|
12
|
+
* Duration constants (seconds)
|
|
13
|
+
*/
|
|
14
|
+
const THIRTY_DAYS_SECONDS = 30 * 24 * 60 * 60;
|
|
15
|
+
/**
|
|
16
|
+
* Transform period summaries to APR historical data
|
|
17
|
+
*
|
|
18
|
+
* Production pattern from frontend-dapp-v2/src/lib/manage/apr-data-service.ts
|
|
19
|
+
*
|
|
20
|
+
* Extracts 30-day and inception data points using SDK's getLastPeriodSummaryInDuration.
|
|
21
|
+
* Gracefully handles new vaults with no history (returns empty object).
|
|
22
|
+
*
|
|
23
|
+
* @param periodSummaries - Historical period summaries from GraphQL
|
|
24
|
+
* @param vault - Vault data for decimal calculations
|
|
25
|
+
* @returns APR historical data with optional 30-day and inception points
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const aprData = transformPeriodSummariesToAPRData(periodSummaries, vault);
|
|
30
|
+
*
|
|
31
|
+
* if (aprData.thirtyDay) {
|
|
32
|
+
* console.log('30-day price:', aprData.thirtyDay.pricePerShare);
|
|
33
|
+
* console.log('Timestamp:', aprData.thirtyDay.timestamp);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function transformPeriodSummariesToAPRData(periodSummaries, vault) {
|
|
38
|
+
// Graceful degradation for new vaults with no history
|
|
39
|
+
if (!periodSummaries?.length) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
// Transform to SDK format (BigInt timestamps for getLastPeriodSummaryInDuration)
|
|
44
|
+
const sdkPeriodSummaries = periodSummaries.map((ps) => ({
|
|
45
|
+
...ps,
|
|
46
|
+
timestamp: BigInt(parseInt(ps.timestamp)),
|
|
47
|
+
}));
|
|
48
|
+
const result = {};
|
|
49
|
+
// Find 30-day data point using SDK function
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- SDK function lacks proper type exports
|
|
51
|
+
const thirtyDayPeriod = getLastPeriodSummaryInDuration(sdkPeriodSummaries, THIRTY_DAYS_SECONDS);
|
|
52
|
+
if (thirtyDayPeriod && typeof thirtyDayPeriod.timestamp === 'bigint') {
|
|
53
|
+
// Find original period summary for conversion
|
|
54
|
+
const original = periodSummaries.find((ps) => ps.timestamp === thirtyDayPeriod.timestamp.toString());
|
|
55
|
+
if (original) {
|
|
56
|
+
result.thirtyDay = {
|
|
57
|
+
timestamp: Number(thirtyDayPeriod.timestamp),
|
|
58
|
+
pricePerShare: calculatePricePerShareFromPeriod(original, vault),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Find inception (oldest) data point
|
|
63
|
+
const sorted = [...periodSummaries].sort((a, b) => parseInt(a.timestamp) - parseInt(b.timestamp));
|
|
64
|
+
if (sorted[0]) {
|
|
65
|
+
result.inception = {
|
|
66
|
+
timestamp: parseInt(sorted[0].timestamp),
|
|
67
|
+
pricePerShare: calculatePricePerShareFromPeriod(sorted[0], vault),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error('Failed to transform period summaries:', error);
|
|
74
|
+
return {}; // Graceful degradation on error
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Calculate price per share from period summary
|
|
79
|
+
*
|
|
80
|
+
* Internal helper using VaultUtils.convertToAssets for protocol-accurate calculation.
|
|
81
|
+
* Matches smart contract pricing logic.
|
|
82
|
+
*
|
|
83
|
+
* @param period - Period summary with historical vault state
|
|
84
|
+
* @param vault - Vault data for decimal configuration
|
|
85
|
+
* @returns Price per share in asset decimals
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
function calculatePricePerShareFromPeriod(period, vault) {
|
|
90
|
+
const vaultDecimals = vault.decimals ?? 18;
|
|
91
|
+
const assetDecimals = vault.asset.decimals;
|
|
92
|
+
const decimalsOffset = vaultDecimals - assetDecimals;
|
|
93
|
+
try {
|
|
94
|
+
return LagoonCore.VaultUtils.convertToAssets(BigInt(1e18), // 1 share in wei (18 decimals)
|
|
95
|
+
{
|
|
96
|
+
totalAssets: BigInt(period.totalAssetsAtStart),
|
|
97
|
+
totalSupply: BigInt(period.totalSupplyAtStart),
|
|
98
|
+
decimalsOffset: BigInt(decimalsOffset),
|
|
99
|
+
}, 'Down' // Round down for conservative pricing
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// Fallback to 1:1 ratio if calculation fails (e.g., zero supply)
|
|
104
|
+
console.warn('Price per share calculation failed, using 1:1 ratio:', error);
|
|
105
|
+
return BigInt(10 ** assetDecimals);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Calculate APR from price per share change
|
|
110
|
+
*
|
|
111
|
+
* Computes annualized percentage return based on price per share change over time.
|
|
112
|
+
* Uses precise BigInt math to avoid floating-point errors.
|
|
113
|
+
*
|
|
114
|
+
* @param oldPrice - Historical price per share
|
|
115
|
+
* @param newPrice - Current price per share
|
|
116
|
+
* @param daysElapsed - Number of days between prices
|
|
117
|
+
* @returns APR as percentage (e.g., 15.5 for 15.5%)
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const apr = calculateAPRFromPriceChange(
|
|
122
|
+
* 1000000n, // 1.0 USDC (6 decimals)
|
|
123
|
+
* 1025000n, // 1.025 USDC
|
|
124
|
+
* 30 // 30 days
|
|
125
|
+
* );
|
|
126
|
+
* // => ~30.42% APR (2.5% in 30 days, annualized)
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function calculateAPRFromPriceChange(oldPrice, newPrice, daysElapsed) {
|
|
130
|
+
if (oldPrice === 0n || daysElapsed <= 0) {
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
// Calculate percentage change with 10000x scaling for precision
|
|
134
|
+
const priceChange = ((newPrice - oldPrice) * 10000n) / oldPrice;
|
|
135
|
+
// Annualize: multiply by (365 / daysElapsed)
|
|
136
|
+
const annualizedChange = (Number(priceChange) * 365) / daysElapsed;
|
|
137
|
+
// Convert from basis points to percentage (divide by 100)
|
|
138
|
+
return annualizedChange / 100;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Calculate current APR from historical data
|
|
142
|
+
*
|
|
143
|
+
* Convenience function that combines APR historical data with current price
|
|
144
|
+
* to compute 30-day and inception APR values.
|
|
145
|
+
*
|
|
146
|
+
* @param aprData - APR historical data with 30-day and/or inception points
|
|
147
|
+
* @param currentPricePerShare - Current price per share
|
|
148
|
+
* @returns Object with 30-day and inception APR values (undefined if no data)
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const aprs = calculateCurrentAPR(aprData, currentPrice);
|
|
153
|
+
*
|
|
154
|
+
* if (aprs.thirtyDay !== undefined) {
|
|
155
|
+
* console.log(`30-day APR: ${aprs.thirtyDay.toFixed(2)}%`);
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export function calculateCurrentAPR(aprData, currentPricePerShare) {
|
|
160
|
+
const result = {};
|
|
161
|
+
if (aprData.thirtyDay) {
|
|
162
|
+
const daysElapsed = (Date.now() / 1000 - aprData.thirtyDay.timestamp) / (24 * 60 * 60);
|
|
163
|
+
if (daysElapsed > 0) {
|
|
164
|
+
result.thirtyDay = calculateAPRFromPriceChange(aprData.thirtyDay.pricePerShare, currentPricePerShare, daysElapsed);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (aprData.inception) {
|
|
168
|
+
const daysElapsed = (Date.now() / 1000 - aprData.inception.timestamp) / (24 * 60 * 60);
|
|
169
|
+
if (daysElapsed > 0) {
|
|
170
|
+
result.inception = calculateAPRFromPriceChange(aprData.inception.pricePerShare, currentPricePerShare, daysElapsed);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
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C5C,OAAO,CAAC,SAAS,CAAC,aAAa,EAC/B,oBAAoB,EACpB,WAAW,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAEvF,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,SAAS,GAAG,2BAA2B,CAC5C,OAAO,CAAC,SAAS,CAAC,aAAa,EAC/B,oBAAoB,EACpB,WAAW,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BigInt Mathematical Utilities
|
|
3
|
+
*
|
|
4
|
+
* Production-validated utilities for safe BigInt operations and serialization.
|
|
5
|
+
* Patterns from frontend-dapp-v2 ensuring no precision loss.
|
|
6
|
+
*
|
|
7
|
+
* @module sdk/math-utils
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Safely serialize BigInt values to JSON
|
|
11
|
+
*
|
|
12
|
+
* Production pattern from frontend-dapp-v2 for JSON serialization of BigInt values.
|
|
13
|
+
* Prevents TypeError: Do not know how to serialize a BigInt.
|
|
14
|
+
*
|
|
15
|
+
* @param _key - JSON key (unused but required by replacer signature)
|
|
16
|
+
* @param value - Value to serialize
|
|
17
|
+
* @returns Serializable value (BigInt → string, others unchanged)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const data = { amount: 1000000000000000000n };
|
|
22
|
+
* JSON.stringify(data, bigIntReplacer);
|
|
23
|
+
* // => '{"amount":"1000000000000000000"}'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Stringify object with BigInt support
|
|
29
|
+
*
|
|
30
|
+
* Convenience wrapper for JSON.stringify with automatic BigInt handling.
|
|
31
|
+
* Uses 2-space indentation for readability.
|
|
32
|
+
*
|
|
33
|
+
* @param obj - Object to stringify (may contain BigInt values)
|
|
34
|
+
* @returns JSON string with BigInt values as strings
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* safeBigIntStringify({ balance: 1000000000000000000n });
|
|
39
|
+
* // => '{\n "balance": "1000000000000000000"\n}'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function safeBigIntStringify(obj: unknown): string;
|
|
43
|
+
/**
|
|
44
|
+
* Format BigInt to human-readable decimal string
|
|
45
|
+
*
|
|
46
|
+
* Converts BigInt wei amounts to decimal representation with proper decimal placement.
|
|
47
|
+
* No floating-point operations - pure integer math for precision.
|
|
48
|
+
*
|
|
49
|
+
* @param value - BigInt value in smallest unit (e.g., wei)
|
|
50
|
+
* @param decimals - Number of decimal places (e.g., 18 for ether)
|
|
51
|
+
* @returns Formatted decimal string (e.g., "1.500000000000000000")
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* formatBigInt(1500000000000000000n, 18);
|
|
56
|
+
* // => "1.500000000000000000"
|
|
57
|
+
*
|
|
58
|
+
* formatBigInt(1000000n, 6);
|
|
59
|
+
* // => "1.000000"
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatBigInt(value: bigint, decimals: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* Parse decimal string to BigInt
|
|
65
|
+
*
|
|
66
|
+
* Converts human-readable decimal to BigInt in smallest unit.
|
|
67
|
+
* Validates input format and handles edge cases safely.
|
|
68
|
+
*
|
|
69
|
+
* @param value - Decimal string (e.g., "1.5" or "1500")
|
|
70
|
+
* @param decimals - Target decimal places
|
|
71
|
+
* @returns BigInt value in smallest unit
|
|
72
|
+
* @throws {Error} If value format is invalid
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* parseBigInt("1.5", 18);
|
|
77
|
+
* // => 1500000000000000000n
|
|
78
|
+
*
|
|
79
|
+
* parseBigInt("1000000", 6);
|
|
80
|
+
* // => 1000000000000n
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseBigInt(value: string, decimals: number): bigint;
|
|
84
|
+
/**
|
|
85
|
+
* Validate BigInt string format
|
|
86
|
+
*
|
|
87
|
+
* Checks if a string represents a valid BigInt (unsigned integer).
|
|
88
|
+
* Returns false for negative numbers, decimals, or invalid formats.
|
|
89
|
+
*
|
|
90
|
+
* @param value - String to validate
|
|
91
|
+
* @returns true if valid BigInt string, false otherwise
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* isValidBigIntString("1000000000000000000"); // => true
|
|
96
|
+
* isValidBigIntString("1.5"); // => false
|
|
97
|
+
* isValidBigIntString("-100"); // => false
|
|
98
|
+
* isValidBigIntString("abc"); // => false
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function isValidBigIntString(value: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Calculate percentage change between two BigInt values
|
|
104
|
+
*
|
|
105
|
+
* Computes percentage change with high precision using integer math.
|
|
106
|
+
* Returns result scaled to basis points (10000 = 100.00%).
|
|
107
|
+
*
|
|
108
|
+
* @param oldValue - Original value
|
|
109
|
+
* @param newValue - New value
|
|
110
|
+
* @returns Percentage change in basis points (e.g., 250 = 2.50%)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* percentageChange(1000000n, 1025000n);
|
|
115
|
+
* // => 250 (2.50% increase)
|
|
116
|
+
*
|
|
117
|
+
* percentageChange(1000000n, 975000n);
|
|
118
|
+
* // => -250 (2.50% decrease)
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function percentageChange(oldValue: bigint, newValue: bigint): number;
|
|
122
|
+
/**
|
|
123
|
+
* Format percentage change for display
|
|
124
|
+
*
|
|
125
|
+
* Converts basis points to human-readable percentage string.
|
|
126
|
+
*
|
|
127
|
+
* @param basisPoints - Percentage change in basis points
|
|
128
|
+
* @returns Formatted percentage string with sign and symbol
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* formatPercentageChange(250); // => "+2.50%"
|
|
133
|
+
* formatPercentageChange(-250); // => "-2.50%"
|
|
134
|
+
* formatPercentageChange(0); // => "0.00%"
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function formatPercentageChange(basisPoints: number): string;
|
|
138
|
+
//# sourceMappingURL=math-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-utils.d.ts","sourceRoot":"","sources":["../../src/sdk/math-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwCnE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAkB1D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAalE"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BigInt Mathematical Utilities
|
|
3
|
+
*
|
|
4
|
+
* Production-validated utilities for safe BigInt operations and serialization.
|
|
5
|
+
* Patterns from frontend-dapp-v2 ensuring no precision loss.
|
|
6
|
+
*
|
|
7
|
+
* @module sdk/math-utils
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Safely serialize BigInt values to JSON
|
|
11
|
+
*
|
|
12
|
+
* Production pattern from frontend-dapp-v2 for JSON serialization of BigInt values.
|
|
13
|
+
* Prevents TypeError: Do not know how to serialize a BigInt.
|
|
14
|
+
*
|
|
15
|
+
* @param _key - JSON key (unused but required by replacer signature)
|
|
16
|
+
* @param value - Value to serialize
|
|
17
|
+
* @returns Serializable value (BigInt → string, others unchanged)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const data = { amount: 1000000000000000000n };
|
|
22
|
+
* JSON.stringify(data, bigIntReplacer);
|
|
23
|
+
* // => '{"amount":"1000000000000000000"}'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function bigIntReplacer(_key, value) {
|
|
27
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Stringify object with BigInt support
|
|
31
|
+
*
|
|
32
|
+
* Convenience wrapper for JSON.stringify with automatic BigInt handling.
|
|
33
|
+
* Uses 2-space indentation for readability.
|
|
34
|
+
*
|
|
35
|
+
* @param obj - Object to stringify (may contain BigInt values)
|
|
36
|
+
* @returns JSON string with BigInt values as strings
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* safeBigIntStringify({ balance: 1000000000000000000n });
|
|
41
|
+
* // => '{\n "balance": "1000000000000000000"\n}'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function safeBigIntStringify(obj) {
|
|
45
|
+
return JSON.stringify(obj, bigIntReplacer, 2);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Format BigInt to human-readable decimal string
|
|
49
|
+
*
|
|
50
|
+
* Converts BigInt wei amounts to decimal representation with proper decimal placement.
|
|
51
|
+
* No floating-point operations - pure integer math for precision.
|
|
52
|
+
*
|
|
53
|
+
* @param value - BigInt value in smallest unit (e.g., wei)
|
|
54
|
+
* @param decimals - Number of decimal places (e.g., 18 for ether)
|
|
55
|
+
* @returns Formatted decimal string (e.g., "1.500000000000000000")
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* formatBigInt(1500000000000000000n, 18);
|
|
60
|
+
* // => "1.500000000000000000"
|
|
61
|
+
*
|
|
62
|
+
* formatBigInt(1000000n, 6);
|
|
63
|
+
* // => "1.000000"
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function formatBigInt(value, decimals) {
|
|
67
|
+
if (decimals < 0) {
|
|
68
|
+
throw new Error('Decimals must be non-negative');
|
|
69
|
+
}
|
|
70
|
+
if (decimals === 0) {
|
|
71
|
+
return value.toString();
|
|
72
|
+
}
|
|
73
|
+
const divisor = BigInt(10 ** decimals);
|
|
74
|
+
const integerPart = value / divisor;
|
|
75
|
+
const remainder = value % divisor;
|
|
76
|
+
// Pad fractional part with leading zeros
|
|
77
|
+
const fractionalPart = remainder.toString().padStart(decimals, '0');
|
|
78
|
+
return `${integerPart}.${fractionalPart}`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse decimal string to BigInt
|
|
82
|
+
*
|
|
83
|
+
* Converts human-readable decimal to BigInt in smallest unit.
|
|
84
|
+
* Validates input format and handles edge cases safely.
|
|
85
|
+
*
|
|
86
|
+
* @param value - Decimal string (e.g., "1.5" or "1500")
|
|
87
|
+
* @param decimals - Target decimal places
|
|
88
|
+
* @returns BigInt value in smallest unit
|
|
89
|
+
* @throws {Error} If value format is invalid
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* parseBigInt("1.5", 18);
|
|
94
|
+
* // => 1500000000000000000n
|
|
95
|
+
*
|
|
96
|
+
* parseBigInt("1000000", 6);
|
|
97
|
+
* // => 1000000000000n
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function parseBigInt(value, decimals) {
|
|
101
|
+
if (!value || value.trim() === '') {
|
|
102
|
+
throw new Error('Value cannot be empty');
|
|
103
|
+
}
|
|
104
|
+
if (decimals < 0) {
|
|
105
|
+
throw new Error('Decimals must be non-negative');
|
|
106
|
+
}
|
|
107
|
+
const trimmed = value.trim();
|
|
108
|
+
// Handle integer-only values
|
|
109
|
+
if (!trimmed.includes('.')) {
|
|
110
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
111
|
+
throw new Error(`Invalid integer format: ${value}`);
|
|
112
|
+
}
|
|
113
|
+
return BigInt(trimmed) * BigInt(10 ** decimals);
|
|
114
|
+
}
|
|
115
|
+
// Handle decimal values
|
|
116
|
+
const parts = trimmed.split('.');
|
|
117
|
+
if (parts.length > 2) {
|
|
118
|
+
throw new Error(`Invalid decimal format: ${value}`);
|
|
119
|
+
}
|
|
120
|
+
const [integerPart, fractionalPart] = parts;
|
|
121
|
+
if (!/^\d+$/.test(integerPart) || !/^\d+$/.test(fractionalPart)) {
|
|
122
|
+
throw new Error(`Invalid decimal format: ${value}`);
|
|
123
|
+
}
|
|
124
|
+
if (fractionalPart.length > decimals) {
|
|
125
|
+
throw new Error(`Too many decimal places: ${value} (max: ${decimals})`);
|
|
126
|
+
}
|
|
127
|
+
// Pad fractional part to match decimals
|
|
128
|
+
const paddedFractional = fractionalPart.padEnd(decimals, '0');
|
|
129
|
+
return BigInt(integerPart) * BigInt(10 ** decimals) + BigInt(paddedFractional);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Validate BigInt string format
|
|
133
|
+
*
|
|
134
|
+
* Checks if a string represents a valid BigInt (unsigned integer).
|
|
135
|
+
* Returns false for negative numbers, decimals, or invalid formats.
|
|
136
|
+
*
|
|
137
|
+
* @param value - String to validate
|
|
138
|
+
* @returns true if valid BigInt string, false otherwise
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* isValidBigIntString("1000000000000000000"); // => true
|
|
143
|
+
* isValidBigIntString("1.5"); // => false
|
|
144
|
+
* isValidBigIntString("-100"); // => false
|
|
145
|
+
* isValidBigIntString("abc"); // => false
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function isValidBigIntString(value) {
|
|
149
|
+
if (!value || value.trim() === '') {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const trimmed = value.trim();
|
|
153
|
+
// Must be digits only (no negative, no decimal)
|
|
154
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
BigInt(trimmed);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculate percentage change between two BigInt values
|
|
167
|
+
*
|
|
168
|
+
* Computes percentage change with high precision using integer math.
|
|
169
|
+
* Returns result scaled to basis points (10000 = 100.00%).
|
|
170
|
+
*
|
|
171
|
+
* @param oldValue - Original value
|
|
172
|
+
* @param newValue - New value
|
|
173
|
+
* @returns Percentage change in basis points (e.g., 250 = 2.50%)
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* percentageChange(1000000n, 1025000n);
|
|
178
|
+
* // => 250 (2.50% increase)
|
|
179
|
+
*
|
|
180
|
+
* percentageChange(1000000n, 975000n);
|
|
181
|
+
* // => -250 (2.50% decrease)
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export function percentageChange(oldValue, newValue) {
|
|
185
|
+
if (oldValue === 0n) {
|
|
186
|
+
return newValue === 0n ? 0 : Infinity;
|
|
187
|
+
}
|
|
188
|
+
// Calculate change with 10000x scaling for basis points
|
|
189
|
+
const change = ((newValue - oldValue) * 10000n) / oldValue;
|
|
190
|
+
return Number(change);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Format percentage change for display
|
|
194
|
+
*
|
|
195
|
+
* Converts basis points to human-readable percentage string.
|
|
196
|
+
*
|
|
197
|
+
* @param basisPoints - Percentage change in basis points
|
|
198
|
+
* @returns Formatted percentage string with sign and symbol
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* formatPercentageChange(250); // => "+2.50%"
|
|
203
|
+
* formatPercentageChange(-250); // => "-2.50%"
|
|
204
|
+
* formatPercentageChange(0); // => "0.00%"
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export function formatPercentageChange(basisPoints) {
|
|
208
|
+
if (basisPoints === Infinity) {
|
|
209
|
+
return '+∞%';
|
|
210
|
+
}
|
|
211
|
+
if (basisPoints === -Infinity) {
|
|
212
|
+
return '-∞%';
|
|
213
|
+
}
|
|
214
|
+
const percentage = basisPoints / 100;
|
|
215
|
+
const sign = percentage > 0 ? '+' : '';
|
|
216
|
+
return `${sign}${percentage.toFixed(2)}%`;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=math-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-utils.js","sourceRoot":"","sources":["../../src/sdk/math-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;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