@gearbox-protocol/sdk 16.0.0-next.53 → 16.0.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dev/mode-parity/compareOpportunities.js +4 -5
- package/dist/cjs/dev/mode-parity/comparePositions.js +6 -7
- package/dist/cjs/dev/mode-parity/fieldDiff.js +4 -6
- package/dist/cjs/dev/mode-parity/scriptUtils.js +145 -5
- package/dist/cjs/model/analytics.schema.js +117 -0
- package/dist/cjs/model/charts.schema.js +1 -1
- package/dist/cjs/model/index.js +18 -7
- package/dist/cjs/model/liquidations.schema.js +2 -2
- package/dist/cjs/model/opportunities.schema.js +3 -3
- package/dist/cjs/model/positions.schema.js +2 -2
- package/dist/cjs/offchain/GearboxAPI.js +5 -0
- package/dist/cjs/offchain/analytics/OffchainAnalytics.js +12 -0
- package/dist/cjs/offchain/analytics/OffchainAnalyticsPositions.js +24 -0
- package/dist/cjs/offchain/analytics/index.js +6 -0
- package/dist/cjs/offchain/index.js +5 -0
- package/dist/cjs/rewards/errors.js +27 -0
- package/dist/cjs/rewards/index.js +6 -7
- package/dist/cjs/rewards/merkl-api.js +45 -0
- package/dist/cjs/rewards/multichain.js +40 -0
- package/dist/cjs/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
- package/dist/cjs/sdk/GearboxSDK.js +5 -0
- package/dist/cjs/sdk/analytics/AnalyticsNamespace.js +11 -0
- package/dist/cjs/sdk/analytics/index.js +4 -0
- package/dist/cjs/sdk/index.js +3 -0
- package/dist/esm/dev/mode-parity/compareOpportunities.js +4 -5
- package/dist/esm/dev/mode-parity/comparePositions.js +6 -7
- package/dist/esm/dev/mode-parity/fieldDiff.js +4 -6
- package/dist/esm/dev/mode-parity/scriptUtils.js +142 -6
- package/dist/esm/model/analytics.schema.js +108 -0
- package/dist/esm/model/charts.schema.js +1 -1
- package/dist/esm/model/index.js +10 -8
- package/dist/esm/model/liquidations.schema.js +2 -2
- package/dist/esm/model/opportunities.schema.js +3 -3
- package/dist/esm/model/positions.schema.js +2 -2
- package/dist/esm/offchain/GearboxAPI.js +5 -0
- package/dist/esm/offchain/analytics/OffchainAnalytics.js +11 -0
- package/dist/esm/offchain/analytics/OffchainAnalyticsPositions.js +23 -0
- package/dist/esm/offchain/analytics/index.js +4 -0
- package/dist/esm/offchain/index.js +4 -1
- package/dist/esm/rewards/errors.js +26 -0
- package/dist/esm/rewards/index.js +4 -5
- package/dist/esm/rewards/merkl-api.js +42 -0
- package/dist/esm/rewards/multichain.js +39 -0
- package/dist/esm/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
- package/dist/esm/sdk/GearboxSDK.js +5 -0
- package/dist/esm/sdk/analytics/AnalyticsNamespace.js +10 -0
- package/dist/esm/sdk/analytics/index.js +3 -0
- package/dist/esm/sdk/index.js +3 -1
- package/dist/types/dev/mode-parity/compareOpportunities.d.ts +3 -7
- package/dist/types/dev/mode-parity/comparePositions.d.ts +4 -8
- package/dist/types/dev/mode-parity/fieldDiff.d.ts +9 -8
- package/dist/types/dev/mode-parity/scriptUtils.d.ts +26 -1
- package/dist/types/model/analytics.d.ts +62 -0
- package/dist/types/model/analytics.schema.d.ts +149 -0
- package/dist/types/model/index.d.ts +10 -8
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/model/previews.d.ts +2 -2
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
- package/dist/types/offchain/GearboxAPI.d.ts +4 -0
- package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +11 -0
- package/dist/types/offchain/analytics/OffchainAnalyticsPositions.d.ts +14 -0
- package/dist/types/offchain/analytics/index.d.ts +4 -0
- package/dist/types/offchain/analytics/types.d.ts +17 -0
- package/dist/types/offchain/index.d.ts +5 -1
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
- package/dist/types/offchain/opportunities/types.d.ts +1 -1
- package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
- package/dist/types/offchain/positions/types.d.ts +1 -1
- package/dist/types/rewards/errors.d.ts +18 -0
- package/dist/types/rewards/index.d.ts +4 -7
- package/dist/types/rewards/merkl-api.d.ts +64 -0
- package/dist/types/rewards/multichain.d.ts +33 -0
- package/dist/types/rewards/toMerklRewards.d.ts +42 -0
- package/dist/types/sdk/GearboxSDK.d.ts +4 -0
- package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +11 -0
- package/dist/types/sdk/analytics/index.d.ts +3 -0
- package/dist/types/sdk/analytics/types.d.ts +15 -0
- package/dist/types/sdk/index.d.ts +4 -1
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
- package/dist/types/sdk/opportunities/types.d.ts +1 -1
- package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
- package/dist/types/sdk/positions/types.d.ts +1 -1
- package/dist/types/sdk/types.d.ts +3 -0
- package/package.json +1 -3
- package/dist/cjs/_virtual/_rolldown/runtime.js +0 -23
- package/dist/cjs/rewards/apy/index.js +0 -3
- package/dist/cjs/rewards/rewards/extra-apy.js +0 -71
- package/dist/cjs/rewards/rewards/index.js +0 -6
- package/dist/cjs/rewards/rewards/merkl-api.js +0 -22
- package/dist/esm/rewards/apy/index.js +0 -3
- package/dist/esm/rewards/rewards/extra-apy.js +0 -67
- package/dist/esm/rewards/rewards/index.js +0 -3
- package/dist/esm/rewards/rewards/merkl-api.js +0 -19
- package/dist/types/rewards/apy/index.d.ts +0 -3
- package/dist/types/rewards/apy/output-details.d.ts +0 -99
- package/dist/types/rewards/apy/output.d.ts +0 -25
- package/dist/types/rewards/rewards/api.d.ts +0 -60
- package/dist/types/rewards/rewards/common.d.ts +0 -9
- package/dist/types/rewards/rewards/extra-apy.d.ts +0 -37
- package/dist/types/rewards/rewards/index.d.ts +0 -3
- package/dist/types/rewards/rewards/merkl-api.d.ts +0 -54
- /package/dist/cjs/{rewards/apy/output-details.js → model/analytics.js} +0 -0
- /package/dist/cjs/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
- /package/dist/cjs/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
- /package/dist/esm/{rewards/apy/output-details.js → model/analytics.js} +0 -0
- /package/dist/esm/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
- /package/dist/esm/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GearboxAPI } from "../../offchain/GearboxAPI.js";
|
|
2
|
+
import "../../offchain/index.js";
|
|
3
|
+
import { IAnalytics } from "./types.js";
|
|
4
|
+
//#region src/sdk/analytics/AnalyticsNamespace.d.ts
|
|
5
|
+
/** Backend-only protocol analytics exposed by {@link GearboxSDK}. */
|
|
6
|
+
declare class AnalyticsNamespace implements IAnalytics {
|
|
7
|
+
readonly positions: GearboxAPI["analytics"]["positions"];
|
|
8
|
+
constructor(backend: GearboxAPI);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { AnalyticsNamespace };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IOffchainAnalyticsPositions } from "../../offchain/analytics/types.js";
|
|
2
|
+
import "../../offchain/index.js";
|
|
3
|
+
//#region src/sdk/analytics/types.d.ts
|
|
4
|
+
/** Backend-only protocol analytics, grouped by subject. */
|
|
5
|
+
interface IAnalytics {
|
|
6
|
+
readonly positions: IOffchainAnalyticsPositions;
|
|
7
|
+
}
|
|
8
|
+
/** `sdk.analytics` per mode: absent when the SDK has no backend source. */
|
|
9
|
+
interface IAnalyticsByMode {
|
|
10
|
+
onchain: undefined;
|
|
11
|
+
offchain: IAnalytics;
|
|
12
|
+
both: IAnalytics;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { IAnalytics, IAnalyticsByMode };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BorrowLimitBinding, IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "../onchain/validation/refusal.js";
|
|
2
2
|
import { LeverageBand } from "../onchain/accounts/intents/leverage-band.js";
|
|
3
3
|
import { OperationState, PathLossRate, WithdrawCeilings } from "../onchain/accounts/intents/types.js";
|
|
4
|
+
import { IAnalytics, IAnalyticsByMode } from "./analytics/types.js";
|
|
4
5
|
import { ILiquidations, ILiquidationsByMode } from "./liquidations/types.js";
|
|
5
6
|
import { AccountFlowError, CreditAccountNotFoundError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientCollateralError, InsufficientPoolLiquidityError, InsufficientSourceBalanceError, LeverageOutOfRangeError, MalformedTransactionError, MarketExpiredError, MarketPausedError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, OpenFlowError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RefusalErrors, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, WithdrawalInProgressError, creditAccountNotFound, noStrategyTargetCollateral, toRefusalError, unexpectedFailure } from "./prepare/errors.js";
|
|
6
7
|
import { AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
|
|
@@ -18,6 +19,8 @@ import { IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositi
|
|
|
18
19
|
import { IPreview, IPreviewByMode } from "./preview/types.js";
|
|
19
20
|
import { EnsureFreshChains, GearboxSDKOptions, IGearboxSDK, INotices, INoticesByMode, Mode, NamespaceOptions, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, PlainMultichainSDKOptions } from "./types.js";
|
|
20
21
|
import { AbstractNamespace, MergedQuery } from "./AbstractNamespace.js";
|
|
22
|
+
import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
|
|
23
|
+
import "./analytics/index.js";
|
|
21
24
|
import { LiquidationsNamespace } from "./liquidations/LiquidationsNamespace.js";
|
|
22
25
|
import "./liquidations/index.js";
|
|
23
26
|
import { OpportunitiesNamespace } from "./opportunities/OpportunitiesNamespace.js";
|
|
@@ -35,4 +38,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
|
35
38
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
36
39
|
import { everyChainFailed } from "./errors/everyChainFailed.js";
|
|
37
40
|
import "./errors/index.js";
|
|
38
|
-
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, BorrowLimitBinding, ChainOf, ChainRef, CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DebtOutOfRangeError, DelayedStrategyResult, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, FinalizeResult, ForbiddenTokenError, GearboxSDK, GearboxSDKOptions, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, InsufficientCollateralError, InsufficientPoolLiquidityError, InsufficientSourceBalanceError, IntentPreviewError, type LeverageBand, LeverageOutOfRangeError, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, MalformedTransactionError, MarketExpiredError, MarketPausedError, type MergeListResult, MergedQuery, MissingSourceError, Mode, MultipleDelayedWithdrawalsError, NamespaceOptions, NoDelayedRouteError, NoRecordedIntentError, NoSourceServedError, NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PoolSunsetError, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewNamespace, PreviewRefusal, QuotaCountExceededError, QuotaLimitReachedError, RefusalErrors, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, WithdrawalInProgressError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
|
|
41
|
+
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, BorrowLimitBinding, ChainOf, ChainRef, CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DebtOutOfRangeError, DelayedStrategyResult, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, FinalizeResult, ForbiddenTokenError, GearboxSDK, GearboxSDKOptions, IAnalytics, IAnalyticsByMode, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, InsufficientCollateralError, InsufficientPoolLiquidityError, InsufficientSourceBalanceError, IntentPreviewError, type LeverageBand, LeverageOutOfRangeError, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, MalformedTransactionError, MarketExpiredError, MarketPausedError, type MergeListResult, MergedQuery, MissingSourceError, Mode, MultipleDelayedWithdrawalsError, NamespaceOptions, NoDelayedRouteError, NoRecordedIntentError, NoSourceServedError, NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PoolSunsetError, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewNamespace, PreviewRefusal, QuotaCountExceededError, QuotaLimitReachedError, RefusalErrors, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, WithdrawalInProgressError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import "../../model/index.js";
|
|
5
5
|
import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import "../../model/index.js";
|
|
5
5
|
import { IMultichainOpportunitiesService } from "../../onchain/opportunities/types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { PositionWithdrawals } from "../../model/withdrawals.js";
|
|
5
5
|
import "../../model/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { PositionWithdrawals } from "../../model/withdrawals.js";
|
|
5
5
|
import "../../model/index.js";
|
|
@@ -9,6 +9,7 @@ import "../onchain/index.js";
|
|
|
9
9
|
import { GearboxAPIOptions } from "../offchain/types.js";
|
|
10
10
|
import { GearboxAPI } from "../offchain/GearboxAPI.js";
|
|
11
11
|
import "../offchain/index.js";
|
|
12
|
+
import { IAnalyticsByMode } from "./analytics/types.js";
|
|
12
13
|
import { ILiquidationsByMode } from "./liquidations/types.js";
|
|
13
14
|
import { IOpportunities } from "./opportunities/types.js";
|
|
14
15
|
import { IPositions } from "./positions/types.js";
|
|
@@ -149,6 +150,8 @@ interface IGearboxSDK<M extends Mode = Mode> {
|
|
|
149
150
|
* `offchain` mode and when an already-attached SDK was injected.
|
|
150
151
|
**/
|
|
151
152
|
attach(): Promise<void>;
|
|
153
|
+
/** Protocol-wide analytics. Absent in `onchain` mode. */
|
|
154
|
+
readonly analytics: IAnalyticsByMode[M];
|
|
152
155
|
/**
|
|
153
156
|
* Namespace for pool and strategy opportunities.
|
|
154
157
|
**/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "16.0.0-next.
|
|
3
|
+
"version": "16.0.0-next.55",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -107,7 +107,6 @@
|
|
|
107
107
|
"@commitlint/cli": "^21.2.1",
|
|
108
108
|
"@commitlint/config-conventional": "^21.2.0",
|
|
109
109
|
"@gearbox-protocol/biome-config": "^1.1.6",
|
|
110
|
-
"axios": "^1.19.0",
|
|
111
110
|
"husky": "^9.1.7",
|
|
112
111
|
"lint-staged": "^17.3.0",
|
|
113
112
|
"pino": "^10.3.1",
|
|
@@ -122,7 +121,6 @@
|
|
|
122
121
|
"yaml": "^2.9.0"
|
|
123
122
|
},
|
|
124
123
|
"peerDependencies": {
|
|
125
|
-
"axios": "^1.0.0",
|
|
126
124
|
"viem-deal": "^2.0.4"
|
|
127
125
|
},
|
|
128
126
|
"peerDependenciesMeta": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
|
-
exports.__toESM = __toESM;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
-
const require_onchain_utils_bigint_math = require("../../onchain/utils/bigint-math.js");
|
|
4
|
-
const require_onchain_chain_chains = require("../../onchain/chain/chains.js");
|
|
5
|
-
const require_onchain_constants_math = require("../../onchain/constants/math.js");
|
|
6
|
-
const require_onchain_utils_formatter = require("../../onchain/utils/formatter.js");
|
|
7
|
-
require("../../onchain/index.js");
|
|
8
|
-
let axios = require("axios");
|
|
9
|
-
axios = require_runtime.__toESM(axios);
|
|
10
|
-
//#region src/rewards/rewards/extra-apy.ts
|
|
11
|
-
function getKeyForPoolPointsInfo(i) {
|
|
12
|
-
return [
|
|
13
|
-
i.pool,
|
|
14
|
-
i.token,
|
|
15
|
-
i.symbol,
|
|
16
|
-
i.duration,
|
|
17
|
-
i.name,
|
|
18
|
-
i.type,
|
|
19
|
-
i.estimation,
|
|
20
|
-
i.condition
|
|
21
|
-
].join("-");
|
|
22
|
-
}
|
|
23
|
-
var PoolPointsAPI = class PoolPointsAPI {
|
|
24
|
-
constructor() {}
|
|
25
|
-
static defaultBackendUrl = "https://api.gearbox.foundation";
|
|
26
|
-
static async getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, backendUrl = PoolPointsAPI.defaultBackendUrl }) {
|
|
27
|
-
const list = [...new Set(tokensToCheck)];
|
|
28
|
-
return (await Promise.allSettled(list.map((t) => PoolPointsAPI.getTokenTotal(t, network, tokensList, backendUrl)))).map((r, i) => [list[i], r]);
|
|
29
|
-
}
|
|
30
|
-
static async getTokenTotal(token, network, tokensList, backendUrl) {
|
|
31
|
-
const url = `${backendUrl}/v1/getBalanceAt?asset=${token}&chainId=${require_onchain_chain_chains.chains[network]?.id}`;
|
|
32
|
-
const balance = (await axios.default.get(url)).data.result.reduce((sum, r) => r.effective_balance + sum, 0);
|
|
33
|
-
const { decimals = 18 } = tokensList[token] || {};
|
|
34
|
-
return {
|
|
35
|
-
token,
|
|
36
|
-
balance: require_onchain_utils_formatter.toBN(String(balance), decimals)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList }) {
|
|
40
|
-
return pools.reduce((acc, p) => {
|
|
41
|
-
const poolAddress = p.pool.pool.address.toLowerCase();
|
|
42
|
-
acc[poolAddress] = (poolRewards[poolAddress] || []).reduce((acc, pointsInfo) => {
|
|
43
|
-
const { addr: tokenAddress } = tokensList.get(pointsInfo.token) || {};
|
|
44
|
-
const tokenBalance = totalTokenBalances[(tokenAddress || "").toLowerCase()];
|
|
45
|
-
const points = PoolPointsAPI.getPoolTokenPoints(tokenBalance, p, tokensList, pointsInfo);
|
|
46
|
-
if (points !== null) acc.push({
|
|
47
|
-
key: getKeyForPoolPointsInfo(pointsInfo),
|
|
48
|
-
info: pointsInfo,
|
|
49
|
-
points
|
|
50
|
-
});
|
|
51
|
-
return acc;
|
|
52
|
-
}, []);
|
|
53
|
-
return acc;
|
|
54
|
-
}, {});
|
|
55
|
-
}
|
|
56
|
-
static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
|
|
57
|
-
if (pool.pool.pool.expectedLiquidity <= 0) return 0n;
|
|
58
|
-
if (pointsInfo.estimation === "relative" && !tokenBalanceInPool) return null;
|
|
59
|
-
const { decimals = 18 } = tokensList.get(pointsInfo.token) || {};
|
|
60
|
-
const targetFactor = 10n ** BigInt(decimals);
|
|
61
|
-
const defaultPoints = pointsInfo.amount * targetFactor / require_onchain_constants_math.PERCENTAGE_FACTOR;
|
|
62
|
-
if (pointsInfo.estimation === "absolute") return defaultPoints;
|
|
63
|
-
const { decimals: underlyingDecimals = 18 } = tokensList.get(pool.pool.pool.underlying) || {};
|
|
64
|
-
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
65
|
-
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.pool.pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
66
|
-
return require_onchain_utils_bigint_math.BigIntMath.min(points, defaultPoints);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.PoolPointsAPI = PoolPointsAPI;
|
|
71
|
-
exports.getKeyForPoolPointsInfo = getKeyForPoolPointsInfo;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rewards_rewards_api = require("./api.js");
|
|
3
|
-
const require_rewards_rewards_extra_apy = require("./extra-apy.js");
|
|
4
|
-
exports.PoolPointsAPI = require_rewards_rewards_extra_apy.PoolPointsAPI;
|
|
5
|
-
exports.getKeyForPoolPointsInfo = require_rewards_rewards_extra_apy.getKeyForPoolPointsInfo;
|
|
6
|
-
exports.getMerklRewards = require_rewards_rewards_api.getMerklRewards;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
-
let axios = require("axios");
|
|
4
|
-
axios = require_runtime.__toESM(axios);
|
|
5
|
-
//#region src/rewards/rewards/merkl-api.ts
|
|
6
|
-
var MerkleXYZApi = class MerkleXYZApi {
|
|
7
|
-
constructor() {}
|
|
8
|
-
static defaultDomain = "https://api.merkl.xyz";
|
|
9
|
-
static angleDomain = "https://api-merkl.angle.money";
|
|
10
|
-
static apiKeyHeader = "X-API-Key";
|
|
11
|
-
static fetchWithFallback = async (getUrl, apiKey) => {
|
|
12
|
-
const headers = apiKey ? { [MerkleXYZApi.apiKeyHeader]: apiKey } : void 0;
|
|
13
|
-
try {
|
|
14
|
-
return await axios.default.get(getUrl(MerkleXYZApi.defaultDomain), { headers });
|
|
15
|
-
} catch {
|
|
16
|
-
return await axios.default.get(getUrl(MerkleXYZApi.angleDomain), { headers });
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
20
|
-
};
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.MerkleXYZApi = MerkleXYZApi;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { BigIntMath } from "../../onchain/utils/bigint-math.js";
|
|
2
|
-
import { chains } from "../../onchain/chain/chains.js";
|
|
3
|
-
import { PERCENTAGE_FACTOR } from "../../onchain/constants/math.js";
|
|
4
|
-
import { toBN } from "../../onchain/utils/formatter.js";
|
|
5
|
-
import "../../onchain/index.js";
|
|
6
|
-
import axios from "axios";
|
|
7
|
-
//#region src/rewards/rewards/extra-apy.ts
|
|
8
|
-
function getKeyForPoolPointsInfo(i) {
|
|
9
|
-
return [
|
|
10
|
-
i.pool,
|
|
11
|
-
i.token,
|
|
12
|
-
i.symbol,
|
|
13
|
-
i.duration,
|
|
14
|
-
i.name,
|
|
15
|
-
i.type,
|
|
16
|
-
i.estimation,
|
|
17
|
-
i.condition
|
|
18
|
-
].join("-");
|
|
19
|
-
}
|
|
20
|
-
var PoolPointsAPI = class PoolPointsAPI {
|
|
21
|
-
constructor() {}
|
|
22
|
-
static defaultBackendUrl = "https://api.gearbox.foundation";
|
|
23
|
-
static async getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, backendUrl = PoolPointsAPI.defaultBackendUrl }) {
|
|
24
|
-
const list = [...new Set(tokensToCheck)];
|
|
25
|
-
return (await Promise.allSettled(list.map((t) => PoolPointsAPI.getTokenTotal(t, network, tokensList, backendUrl)))).map((r, i) => [list[i], r]);
|
|
26
|
-
}
|
|
27
|
-
static async getTokenTotal(token, network, tokensList, backendUrl) {
|
|
28
|
-
const url = `${backendUrl}/v1/getBalanceAt?asset=${token}&chainId=${chains[network]?.id}`;
|
|
29
|
-
const balance = (await axios.get(url)).data.result.reduce((sum, r) => r.effective_balance + sum, 0);
|
|
30
|
-
const { decimals = 18 } = tokensList[token] || {};
|
|
31
|
-
return {
|
|
32
|
-
token,
|
|
33
|
-
balance: toBN(String(balance), decimals)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList }) {
|
|
37
|
-
return pools.reduce((acc, p) => {
|
|
38
|
-
const poolAddress = p.pool.pool.address.toLowerCase();
|
|
39
|
-
acc[poolAddress] = (poolRewards[poolAddress] || []).reduce((acc, pointsInfo) => {
|
|
40
|
-
const { addr: tokenAddress } = tokensList.get(pointsInfo.token) || {};
|
|
41
|
-
const tokenBalance = totalTokenBalances[(tokenAddress || "").toLowerCase()];
|
|
42
|
-
const points = PoolPointsAPI.getPoolTokenPoints(tokenBalance, p, tokensList, pointsInfo);
|
|
43
|
-
if (points !== null) acc.push({
|
|
44
|
-
key: getKeyForPoolPointsInfo(pointsInfo),
|
|
45
|
-
info: pointsInfo,
|
|
46
|
-
points
|
|
47
|
-
});
|
|
48
|
-
return acc;
|
|
49
|
-
}, []);
|
|
50
|
-
return acc;
|
|
51
|
-
}, {});
|
|
52
|
-
}
|
|
53
|
-
static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
|
|
54
|
-
if (pool.pool.pool.expectedLiquidity <= 0) return 0n;
|
|
55
|
-
if (pointsInfo.estimation === "relative" && !tokenBalanceInPool) return null;
|
|
56
|
-
const { decimals = 18 } = tokensList.get(pointsInfo.token) || {};
|
|
57
|
-
const targetFactor = 10n ** BigInt(decimals);
|
|
58
|
-
const defaultPoints = pointsInfo.amount * targetFactor / PERCENTAGE_FACTOR;
|
|
59
|
-
if (pointsInfo.estimation === "absolute") return defaultPoints;
|
|
60
|
-
const { decimals: underlyingDecimals = 18 } = tokensList.get(pool.pool.pool.underlying) || {};
|
|
61
|
-
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
62
|
-
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.pool.pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
63
|
-
return BigIntMath.min(points, defaultPoints);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
//#endregion
|
|
67
|
-
export { PoolPointsAPI, getKeyForPoolPointsInfo };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
//#region src/rewards/rewards/merkl-api.ts
|
|
3
|
-
var MerkleXYZApi = class MerkleXYZApi {
|
|
4
|
-
constructor() {}
|
|
5
|
-
static defaultDomain = "https://api.merkl.xyz";
|
|
6
|
-
static angleDomain = "https://api-merkl.angle.money";
|
|
7
|
-
static apiKeyHeader = "X-API-Key";
|
|
8
|
-
static fetchWithFallback = async (getUrl, apiKey) => {
|
|
9
|
-
const headers = apiKey ? { [MerkleXYZApi.apiKeyHeader]: apiKey } : void 0;
|
|
10
|
-
try {
|
|
11
|
-
return await axios.get(getUrl(MerkleXYZApi.defaultDomain), { headers });
|
|
12
|
-
} catch {
|
|
13
|
-
return await axios.get(getUrl(MerkleXYZApi.angleDomain), { headers });
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
static getUserRewardsUrl = (options) => (domain) => `${domain}/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { MerkleXYZApi };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Apy, ApyDetails, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsInfo, TokenOutputDetails } from "./output-details.js";
|
|
2
|
-
import { DataResult, Output } from "./output.js";
|
|
3
|
-
export { Apy, ApyDetails, DataResult, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, Output, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsInfo, TokenOutputDetails };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
2
|
-
//#region src/rewards/apy/output-details.d.ts
|
|
3
|
-
interface GearAPY {
|
|
4
|
-
base: number;
|
|
5
|
-
crv: number;
|
|
6
|
-
gear: number;
|
|
7
|
-
gearPrice: number;
|
|
8
|
-
}
|
|
9
|
-
type GearAPYDetails = GearAPY & {
|
|
10
|
-
lastUpdated: string;
|
|
11
|
-
};
|
|
12
|
-
interface TokenOutputDetails<T extends string> {
|
|
13
|
-
chainId: number;
|
|
14
|
-
address: string;
|
|
15
|
-
symbol: string;
|
|
16
|
-
rewards: {
|
|
17
|
-
apy: Array<Omit<ApyDetails, "symbol" | "address">>;
|
|
18
|
-
points: Array<Omit<PointsInfo<T>, "symbol" | "address">>;
|
|
19
|
-
extraRewards: Array<Omit<FarmInfo, "symbol" | "address">>;
|
|
20
|
-
extraCollateralAPY: Array<Omit<ExtraCollateralAPY, "symbol" | "address">>;
|
|
21
|
-
extraCollateralPoints: Array<Omit<ExtraCollateralPointsInfo<T>, "symbol" | "address">>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
type ApyDetails = Apy & {
|
|
25
|
-
lastUpdated: string;
|
|
26
|
-
};
|
|
27
|
-
interface FarmInfo {
|
|
28
|
-
address: Address;
|
|
29
|
-
symbol: string;
|
|
30
|
-
rewardToken: Address;
|
|
31
|
-
rewardSymbol: string;
|
|
32
|
-
duration: bigint;
|
|
33
|
-
finished: bigint;
|
|
34
|
-
reward: bigint;
|
|
35
|
-
balance: bigint;
|
|
36
|
-
}
|
|
37
|
-
interface Apy {
|
|
38
|
-
address: Address;
|
|
39
|
-
symbol: string;
|
|
40
|
-
protocol: string;
|
|
41
|
-
value: number;
|
|
42
|
-
}
|
|
43
|
-
interface ExtraCollateralAPY extends Omit<Apy, "protocol"> {
|
|
44
|
-
pool: Address;
|
|
45
|
-
type: "relative" | "absolute";
|
|
46
|
-
}
|
|
47
|
-
interface PointsReward<T extends string> {
|
|
48
|
-
name: string;
|
|
49
|
-
units: string;
|
|
50
|
-
multiplier: bigint | "soon";
|
|
51
|
-
type: T;
|
|
52
|
-
}
|
|
53
|
-
interface DebtReward<T extends string> extends PointsReward<T> {
|
|
54
|
-
cm: Address | "any";
|
|
55
|
-
}
|
|
56
|
-
interface PointsInfo<T extends string> {
|
|
57
|
-
symbol: string;
|
|
58
|
-
address: Address;
|
|
59
|
-
rewards: Array<PointsReward<T>>;
|
|
60
|
-
debtRewards?: Array<DebtReward<T>>;
|
|
61
|
-
}
|
|
62
|
-
interface ExtraCollateralPointsInfo<T extends string> extends PointsInfo<T> {
|
|
63
|
-
pool: Address;
|
|
64
|
-
}
|
|
65
|
-
interface PoolOutputDetails<T extends string> {
|
|
66
|
-
chainId: number;
|
|
67
|
-
pool: Address;
|
|
68
|
-
rewards: {
|
|
69
|
-
points: Array<Omit<PoolPointsInfo<T>, "pool">>;
|
|
70
|
-
externalAPY: Array<Omit<ExternalApy, "pool">>;
|
|
71
|
-
extraAPY: Array<Omit<PoolExtraApy, "pool">>;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
interface PoolPointsInfo<T extends string> {
|
|
75
|
-
pool: Address;
|
|
76
|
-
token: Address;
|
|
77
|
-
symbol: string;
|
|
78
|
-
amount: bigint;
|
|
79
|
-
duration: string | undefined;
|
|
80
|
-
name: string;
|
|
81
|
-
type: T;
|
|
82
|
-
estimation: "absolute" | "relative";
|
|
83
|
-
condition: "deposit" | "cross-chain-deposit" | "holding";
|
|
84
|
-
}
|
|
85
|
-
interface ExternalApy {
|
|
86
|
-
value: number;
|
|
87
|
-
name: string;
|
|
88
|
-
pool: Address;
|
|
89
|
-
}
|
|
90
|
-
interface PoolExtraApy {
|
|
91
|
-
token: Address;
|
|
92
|
-
apy: number;
|
|
93
|
-
rewardToken: Address;
|
|
94
|
-
rewardTokenSymbol: string;
|
|
95
|
-
endTimestamp?: number;
|
|
96
|
-
lastUpdated: string;
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
export { Apy, ApyDetails, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsInfo, TokenOutputDetails };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { GearAPYDetails, PoolOutputDetails, TokenOutputDetails } from "./output-details.js";
|
|
2
|
-
//#region src/rewards/apy/output.d.ts
|
|
3
|
-
interface Output<POOL_POINTS_TYPE extends string, TOKEN_POINTS_TYPE extends string> {
|
|
4
|
-
gearApy: DataResult<GearAPYDetails>;
|
|
5
|
-
chains: Record<string, {
|
|
6
|
-
tokens: DataResult<TokenOutputDetails<TOKEN_POINTS_TYPE>[]>;
|
|
7
|
-
pools: DataResult<PoolOutputDetails<POOL_POINTS_TYPE>[]>;
|
|
8
|
-
}>;
|
|
9
|
-
timestamp: string;
|
|
10
|
-
metadata: {
|
|
11
|
-
totalChains: number;
|
|
12
|
-
successfulChains: number;
|
|
13
|
-
failedChains: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
type DataResult<T> = {
|
|
17
|
-
status: "ok";
|
|
18
|
-
data: T;
|
|
19
|
-
} | {
|
|
20
|
-
status: "error";
|
|
21
|
-
message: string;
|
|
22
|
-
code?: string;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { DataResult, Output };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ChainId, Token, TokenAmount } from "../../model/primitives.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
4
|
-
import "../../onchain/index.js";
|
|
5
|
-
import { Address } from "viem";
|
|
6
|
-
//#region src/rewards/rewards/api.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* One claimable Merkl liquidity-mining reward, denominated and priced.
|
|
9
|
-
*
|
|
10
|
-
* Both tokens arrive resolved, so a consumer neither looks one up nor
|
|
11
|
-
* reassembles one out of the loose fields Merkl sends.
|
|
12
|
-
*/
|
|
13
|
-
interface MerklReward {
|
|
14
|
-
readonly chainId: ChainId;
|
|
15
|
-
/** Market pool whose depositors the campaign rewards. */
|
|
16
|
-
readonly pool: Address;
|
|
17
|
-
/** That pool's share token — what the campaign is keyed on. */
|
|
18
|
-
readonly poolToken: Token;
|
|
19
|
-
/**
|
|
20
|
-
* The incentive token being handed out, how much of it is claimable
|
|
21
|
-
* (distributed minus already claimed, always > 0) and what that is worth.
|
|
22
|
-
*
|
|
23
|
-
* Priced by Merkl, not by the market oracles: a campaign's incentive token
|
|
24
|
-
* is rarely collateral in the pool it incentivises, so the oracles usually
|
|
25
|
-
* do not know it — GEAR, which most Gearbox campaigns pay in, among them.
|
|
26
|
-
* `valueUsd` is `null` for a token Merkl does not price either.
|
|
27
|
-
*/
|
|
28
|
-
readonly amount: TokenAmount;
|
|
29
|
-
}
|
|
30
|
-
type ReportHandler = (e: unknown, description?: string) => void;
|
|
31
|
-
/**
|
|
32
|
-
* What this read needs off a chain's SDK: which chain to ask Merkl about, the
|
|
33
|
-
* pools a campaign can be keyed on, and the registry that names their tokens.
|
|
34
|
-
*
|
|
35
|
-
* Sliced rather than taking the whole {@link OnchainSDK} so a caller can hand
|
|
36
|
-
* over a narrowed object — a test fixture included — without casting.
|
|
37
|
-
*/
|
|
38
|
-
type MerklRewardsSdk = Pick<OnchainSDK, "chainId" | "marketRegister" | "tokensMeta">;
|
|
39
|
-
interface GetMerklRewardsProps {
|
|
40
|
-
/**
|
|
41
|
-
* The chain's SDK, attached. Reading `marketRegister` before attach throws,
|
|
42
|
-
* which the slice above cannot express.
|
|
43
|
-
*/
|
|
44
|
-
sdk: MerklRewardsSdk;
|
|
45
|
-
account: Address;
|
|
46
|
-
reportError?: ReportHandler;
|
|
47
|
-
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
48
|
-
apiKey?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The wallet's claimable Merkl rewards on one chain.
|
|
52
|
-
*
|
|
53
|
-
* Never rejects on a transport failure: the fetch is settled rather than
|
|
54
|
-
* awaited, and a failure goes to `reportError` and yields an empty list. A
|
|
55
|
-
* caller that must tell "this chain is down" from "this chain has no rewards"
|
|
56
|
-
* has to watch that callback.
|
|
57
|
-
*/
|
|
58
|
-
declare function getMerklRewards({ sdk, account, reportError, apiKey }: GetMerklRewardsProps): Promise<MerklReward[]>;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { GetMerklRewardsProps, MerklReward, MerklRewardsSdk, getMerklRewards };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { NetworkType } from "../../onchain/chain/chains.js";
|
|
2
|
-
import { Asset } from "../../onchain/base/types.js";
|
|
3
|
-
import { MarketSuite } from "../../onchain/market/MarketSuite.js";
|
|
4
|
-
import { TokensMeta } from "../../onchain/base/TokensMeta.js";
|
|
5
|
-
import "../../onchain/index.js";
|
|
6
|
-
import { PoolPointsInfo } from "../apy/output-details.js";
|
|
7
|
-
import { TokenData } from "./common.js";
|
|
8
|
-
import { Address } from "viem";
|
|
9
|
-
//#region src/rewards/rewards/extra-apy.d.ts
|
|
10
|
-
interface GetPointsByPoolProps {
|
|
11
|
-
poolRewards: Record<Address, Array<PoolPointsInfo<string>>>;
|
|
12
|
-
totalTokenBalances: Record<Address, Asset>;
|
|
13
|
-
pools: MarketSuite[];
|
|
14
|
-
tokensList: TokensMeta;
|
|
15
|
-
}
|
|
16
|
-
interface GetTotalTokensOnProtocolProps {
|
|
17
|
-
tokensToCheck: Array<Address>;
|
|
18
|
-
tokensList: Record<Address, TokenData>;
|
|
19
|
-
network: NetworkType;
|
|
20
|
-
backendUrl?: string;
|
|
21
|
-
}
|
|
22
|
-
type PoolPointsBase = Record<Address, Array<{
|
|
23
|
-
key: string;
|
|
24
|
-
info: PoolPointsInfo<string>;
|
|
25
|
-
points: bigint;
|
|
26
|
-
}>>;
|
|
27
|
-
declare function getKeyForPoolPointsInfo(i: PoolPointsInfo<string>): string;
|
|
28
|
-
declare class PoolPointsAPI {
|
|
29
|
-
private constructor();
|
|
30
|
-
private static defaultBackendUrl;
|
|
31
|
-
static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, backendUrl }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
|
|
32
|
-
private static getTokenTotal;
|
|
33
|
-
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList }: GetPointsByPoolProps): PoolPointsBase;
|
|
34
|
-
private static getPoolTokenPoints;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { GetPointsByPoolProps, GetTotalTokensOnProtocolProps, PoolPointsAPI, PoolPointsBase, getKeyForPoolPointsInfo };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { GetMerklRewardsProps, MerklReward, MerklRewardsSdk, getMerklRewards } from "./api.js";
|
|
2
|
-
import { GetPointsByPoolProps, GetTotalTokensOnProtocolProps, PoolPointsAPI, PoolPointsBase, getKeyForPoolPointsInfo } from "./extra-apy.js";
|
|
3
|
-
export { GetMerklRewardsProps, GetPointsByPoolProps, GetTotalTokensOnProtocolProps, MerklReward, MerklRewardsSdk, PoolPointsAPI, PoolPointsBase, getKeyForPoolPointsInfo, getMerklRewards };
|