@gearbox-protocol/sdk 17.8.0 → 17.9.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/dist/cjs/model/index.js +1 -0
- package/dist/cjs/sdk/GearboxSDK.js +8 -1
- package/dist/cjs/sdk/index.js +6 -0
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/cjs/sdk/rewards/RewardsNamespace.js +51 -0
- package/dist/cjs/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/cjs/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/cjs/sdk/rewards/index.js +6 -0
- package/dist/cjs/{rewards → sdk/rewards}/merkl-api.js +3 -3
- package/dist/cjs/{rewards → sdk/rewards}/toMerklRewards.js +6 -6
- package/dist/cjs/{rewards → sdk/rewards}/toTurtleRewards.js +7 -7
- package/dist/cjs/{rewards → sdk/rewards}/turtle-api.js +3 -3
- package/dist/cjs/sdk/rewards/types.js +1 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/index.js +1 -0
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/GearboxSDK.js +8 -1
- package/dist/esm/sdk/index.js +4 -1
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/esm/{rewards/RewardsService.js → sdk/rewards/RewardsNamespace.js} +15 -12
- package/dist/esm/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/esm/sdk/rewards/index.js +3 -0
- package/dist/esm/{rewards → sdk/rewards}/merkl-api.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toMerklRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toTurtleRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/turtle-api.js +1 -1
- package/dist/esm/sdk/rewards/types.js +1 -0
- package/dist/types/model/index.d.ts +2 -1
- package/dist/types/{rewards/types.d.ts → model/rewards.d.ts} +4 -9
- package/dist/types/sdk/GearboxSDK.d.ts +6 -0
- package/dist/types/sdk/index.d.ts +8 -2
- package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -1
- package/dist/types/sdk/liquidations/index.d.ts +2 -2
- package/dist/types/sdk/liquidations/types.d.ts +12 -2
- package/dist/types/sdk/rewards/RewardsNamespace.d.ts +24 -0
- package/dist/types/{rewards → sdk/rewards}/errors.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/helpers.d.ts +5 -4
- package/dist/types/sdk/rewards/index.d.ts +6 -0
- package/dist/types/{rewards → sdk/rewards}/merkl-api.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/toMerklRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/toTurtleRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/turtle-api.d.ts +3 -3
- package/dist/types/sdk/rewards/types.d.ts +35 -0
- package/dist/types/sdk/types.d.ts +9 -0
- package/package.json +1 -6
- package/dist/cjs/rewards/RewardsService.js +0 -48
- package/dist/cjs/rewards/index.js +0 -6
- package/dist/cjs/rewards/package.json +0 -1
- package/dist/esm/rewards/index.js +0 -3
- package/dist/esm/rewards/package.json +0 -1
- package/dist/types/rewards/RewardsService.d.ts +0 -29
- package/dist/types/rewards/index.d.ts +0 -6
- /package/dist/cjs/{rewards/types.js → model/rewards.js} +0 -0
- /package/dist/esm/{rewards/types.js → model/rewards.js} +0 -0
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { MultichainConstruct } from "
|
|
2
|
-
import "
|
|
1
|
+
import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
|
|
2
|
+
import "../../onchain/index.js";
|
|
3
3
|
import { fetchMerklUserRewards } from "./merkl-api.js";
|
|
4
4
|
import { toMerklRewards } from "./toMerklRewards.js";
|
|
5
5
|
import { toTurtleRewards } from "./toTurtleRewards.js";
|
|
6
6
|
import { fetchTurtleWalletRewards, readTurtleClaimed } from "./turtle-api.js";
|
|
7
7
|
import { getAddress } from "viem";
|
|
8
|
-
//#region src/rewards/
|
|
9
|
-
|
|
8
|
+
//#region src/sdk/rewards/RewardsNamespace.ts
|
|
9
|
+
/**
|
|
10
|
+
* {@inheritDoc IRewards}
|
|
11
|
+
**/
|
|
12
|
+
var RewardsNamespace = class extends MultichainConstruct {
|
|
10
13
|
#keys;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
#ensureFresh;
|
|
15
|
+
constructor(onchain, keys, options) {
|
|
16
|
+
super(onchain);
|
|
17
|
+
this.#keys = keys ?? {};
|
|
18
|
+
this.#ensureFresh = options.ensureFresh;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
17
|
-
* organisation's Turtle streams — across the chains the handle carries.
|
|
18
|
-
* A chain is `status: "error"` only when every source failed on it; a chain
|
|
19
|
-
* with nothing to claim is a `"success"` with no rewards.
|
|
21
|
+
* {@inheritDoc IRewards.list}
|
|
20
22
|
**/
|
|
21
23
|
async list(wallet, chainIds) {
|
|
24
|
+
await this.#ensureFresh?.(chainIds);
|
|
22
25
|
const { merklApiKey, turtleApiKey } = this.#keys;
|
|
23
26
|
const user = getAddress(wallet);
|
|
24
27
|
const turtle = turtleApiKey ? fetchTurtleWalletRewards(user, turtleApiKey) : void 0;
|
|
@@ -44,4 +47,4 @@ var RewardsService = class extends MultichainConstruct {
|
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
//#endregion
|
|
47
|
-
export {
|
|
50
|
+
export { RewardsNamespace };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AddressMap } from "
|
|
2
|
-
import { toBigInt } from "
|
|
3
|
-
import "
|
|
1
|
+
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
2
|
+
import { toBigInt } from "../../onchain/utils/formatter.js";
|
|
3
|
+
import "../../onchain/index.js";
|
|
4
4
|
import { formatUnits, isAddress } from "viem";
|
|
5
|
-
//#region src/rewards/helpers.ts
|
|
5
|
+
//#region src/sdk/rewards/helpers.ts
|
|
6
6
|
/**
|
|
7
7
|
* The pool a source names, and its share token. A v3.1 pool is its own
|
|
8
8
|
* ERC-4626 share token, so its address is the only token a campaign can name;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeRewards, parseAmount, remaining, resolvePool, toRewardToken } from "./helpers.js";
|
|
2
2
|
import { getAddress, isAddress } from "viem";
|
|
3
|
-
//#region src/rewards/toMerklRewards.ts
|
|
3
|
+
//#region src/sdk/rewards/toMerklRewards.ts
|
|
4
4
|
/**
|
|
5
5
|
* Merkl's answer for one chain, one reward per pool and incentive token.
|
|
6
6
|
* A breakdown Merkl cannot be read from is skipped rather than thrown on: it
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeRewards, parseAmount, remaining, resolvePool, toRewardToken } from "./helpers.js";
|
|
2
2
|
import { formatUnits, getAddress, isAddress } from "viem";
|
|
3
|
-
//#region src/rewards/toTurtleRewards.ts
|
|
3
|
+
//#region src/sdk/rewards/toTurtleRewards.ts
|
|
4
4
|
/**
|
|
5
5
|
* The streams targeting a pool on the SDK's chain, merged per pool and
|
|
6
6
|
* incentive. A token reward is what is committed and not yet claimed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TurtleRequestFailedError } from "./errors.js";
|
|
2
|
-
//#region src/rewards/turtle-api.ts
|
|
2
|
+
//#region src/sdk/rewards/turtle-api.ts
|
|
3
3
|
const TURTLE_API_URL = "https://earn.turtle.xyz";
|
|
4
4
|
const GEARBOX_ORG_ID = "d171ba3d-ff89-4e6c-8f13-d94840b06edd";
|
|
5
5
|
const TIMEOUT = 1e4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -30,7 +30,8 @@ import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema
|
|
|
30
30
|
import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
|
|
31
31
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
32
32
|
import { SDKError, SDKResult, SDKReturn, SafeValue, safeValue, sdkErr, sdkOk } from "./result.js";
|
|
33
|
+
import { MerklReward, PointsReward, Reward } from "./rewards.js";
|
|
33
34
|
import { kycRequirementSchema, rwaProtocolSchema } from "./rwa.schema.js";
|
|
34
35
|
import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
|
|
35
36
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
36
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, accountNotMidasGreenlisted, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
37
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountNotMidasGreenlistedError, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MerklReward, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsReward, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ReservePriceLimitedError, ResponseMetadata, Reward, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, accountNotMidasGreenlisted, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { ChainId, Token, TokenAmount } from "
|
|
2
|
-
import { PointsProgramPnL } from "
|
|
3
|
-
import "../model/index.js";
|
|
4
|
-
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
5
|
-
import "../onchain/index.js";
|
|
1
|
+
import { ChainId, Token, TokenAmount } from "./primitives.js";
|
|
2
|
+
import { PointsProgramPnL } from "./positions.js";
|
|
6
3
|
import { Address } from "viem";
|
|
7
|
-
//#region src/rewards
|
|
4
|
+
//#region src/model/rewards.d.ts
|
|
8
5
|
/**
|
|
9
6
|
* One claimable token reward, denominated and priced.
|
|
10
7
|
*
|
|
@@ -35,7 +32,5 @@ interface PointsReward extends Omit<MerklReward, "amount"> {
|
|
|
35
32
|
readonly points: PointsProgramPnL;
|
|
36
33
|
}
|
|
37
34
|
type Reward = MerklReward | PointsReward;
|
|
38
|
-
/** What the mapping needs off a chain's SDK, and nothing asynchronous. */
|
|
39
|
-
type RewardsSdk = Pick<OnchainSDK, "chainId" | "marketRegister" | "tokensMeta">;
|
|
40
35
|
//#endregion
|
|
41
|
-
export { MerklReward, PointsReward, Reward
|
|
36
|
+
export { MerklReward, PointsReward, Reward };
|
|
@@ -5,12 +5,14 @@ import { ILiquidationsByMode } from "./liquidations/types.js";
|
|
|
5
5
|
import { IOpportunities } from "./opportunities/types.js";
|
|
6
6
|
import { IPositions } from "./positions/types.js";
|
|
7
7
|
import { IPreviewByMode } from "./preview/types.js";
|
|
8
|
+
import { IRewardsByMode } from "./rewards/types.js";
|
|
8
9
|
import { GearboxSDKOptions, IGearboxSDK, INoticesByMode, Mode, OffchainByMode, OnchainByMode } from "./types.js";
|
|
9
10
|
import "./analytics/index.js";
|
|
10
11
|
import "./liquidations/index.js";
|
|
11
12
|
import "./opportunities/index.js";
|
|
12
13
|
import "./positions/index.js";
|
|
13
14
|
import "./preview/index.js";
|
|
15
|
+
import "./rewards/index.js";
|
|
14
16
|
//#region src/sdk/GearboxSDK.d.ts
|
|
15
17
|
/**
|
|
16
18
|
* Default {@link GearboxSDKOptions.maxStateAgeSeconds}: the fastest poll an
|
|
@@ -68,6 +70,10 @@ declare class GearboxSDK<const M extends Mode = Mode> implements IGearboxSDK<M>
|
|
|
68
70
|
* mode.
|
|
69
71
|
**/
|
|
70
72
|
readonly preview: IPreviewByMode[M];
|
|
73
|
+
/**
|
|
74
|
+
* Namespace for claimable rewards. Absent in `offchain` mode.
|
|
75
|
+
**/
|
|
76
|
+
readonly rewards: IRewardsByMode[M];
|
|
71
77
|
/**
|
|
72
78
|
* The banners the backend attaches to a pool opportunity or a strategy
|
|
73
79
|
* position, see {@link Notice}. Top-level because the subject is either
|
|
@@ -4,7 +4,7 @@ import { BorrowState } from "../onchain/accounts/intents/borrow.js";
|
|
|
4
4
|
import { LeverageBand } from "../onchain/accounts/intents/leverage-band.js";
|
|
5
5
|
import { PoolOperationError } from "../onchain/validation/bundles/checkPoolOperation.js";
|
|
6
6
|
import { IAnalytics, IAnalyticsByMode } from "./analytics/types.js";
|
|
7
|
-
import { ILiquidations, ILiquidationsByMode } from "./liquidations/types.js";
|
|
7
|
+
import { ILiquidations, ILiquidationsByMode, IsEmergencyLiquidatorProps } from "./liquidations/types.js";
|
|
8
8
|
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowParams, BorrowResult, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, MaxWithdrawCollateralOptions, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
|
|
9
9
|
import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
|
|
10
10
|
import "./prepare/index.js";
|
|
@@ -18,6 +18,7 @@ import "./utils/index.js";
|
|
|
18
18
|
import { IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunityMergers } from "./opportunities/types.js";
|
|
19
19
|
import { IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly } from "./positions/types.js";
|
|
20
20
|
import { CheckOperationProps, IPreview, IPreviewByMode } from "./preview/types.js";
|
|
21
|
+
import { IRewards, IRewardsByMode, RewardsKeys } from "./rewards/types.js";
|
|
21
22
|
import { EnsureFreshChains, GearboxSDKOptions, IGearboxSDK, INotices, INoticesByMode, Mode, NamespaceOptions, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, PlainMultichainSDKOptions } from "./types.js";
|
|
22
23
|
import { AbstractNamespace, MergedQuery } from "./AbstractNamespace.js";
|
|
23
24
|
import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
|
|
@@ -30,6 +31,11 @@ import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
|
30
31
|
import "./positions/index.js";
|
|
31
32
|
import { PreviewNamespace } from "./preview/PreviewNamespace.js";
|
|
32
33
|
import "./preview/index.js";
|
|
34
|
+
import { MerklRequestFailedError, TurtleRequestFailedError } from "./rewards/errors.js";
|
|
35
|
+
import { MerkleXYZUserRewardsV4Response } from "./rewards/merkl-api.js";
|
|
36
|
+
import { RewardsNamespace } from "./rewards/RewardsNamespace.js";
|
|
37
|
+
import { TurtleWalletRewards } from "./rewards/turtle-api.js";
|
|
38
|
+
import "./rewards/index.js";
|
|
33
39
|
import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
|
|
34
40
|
import { AllSourcesFailedError } from "./errors/AllSourcesFailedError.js";
|
|
35
41
|
import { MissingSourceError } from "./errors/MissingSourceError.js";
|
|
@@ -39,4 +45,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
|
39
45
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
40
46
|
import { everyChainFailed } from "./errors/everyChainFailed.js";
|
|
41
47
|
import "./errors/index.js";
|
|
42
|
-
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, BorrowParams, BorrowPrepareRequest, BorrowResult, type BorrowState, ChainOf, ChainRef, CheckOperationProps, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, EnsureFreshChains, type EntityMerger, ExecuteApi, type ExecutionCost, type FilterResult, FinalizeParams, FinalizeResult, 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, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, MaxWithdrawCollateralOptions, type MergeListResult, MergedQuery, MissingSourceError, Mode, type MultipleDelayedWithdrawalsError, NamespaceOptions, type NoDelayedRouteError, type NoRecordedIntentError, NoSourceServedError, type NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenEmptyPrepareRequest, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, type PoolOperationError, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewNamespace, RepayStrategyParams, type RouteErrors, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, type WithPartialState, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
48
|
+
export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, BorrowParams, BorrowPrepareRequest, BorrowResult, type BorrowState, ChainOf, ChainRef, CheckOperationProps, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, EnsureFreshChains, type EntityMerger, ExecuteApi, type ExecutionCost, type FilterResult, FinalizeParams, FinalizeResult, 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, type IRewards, type IRewardsByMode, IsEmergencyLiquidatorProps, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, MaxWithdrawCollateralOptions, type MergeListResult, MergedQuery, MerklRequestFailedError, type MerkleXYZUserRewardsV4Response, MissingSourceError, Mode, type MultipleDelayedWithdrawalsError, NamespaceOptions, type NoDelayedRouteError, type NoRecordedIntentError, NoSourceServedError, type NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenEmptyPrepareRequest, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, type PoolOperationError, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewNamespace, RepayStrategyParams, type RewardsKeys, RewardsNamespace, type RouteErrors, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, TurtleRequestFailedError, type TurtleWalletRewards, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, type WithPartialState, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -6,7 +6,7 @@ import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
|
6
6
|
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps } from "../../onchain/accounts/liquidations/types.js";
|
|
7
7
|
import { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError } from "../../onchain/validation/checkLiquidation.js";
|
|
8
8
|
import "../../onchain/index.js";
|
|
9
|
-
import { ILiquidations } from "./types.js";
|
|
9
|
+
import { ILiquidations, IsEmergencyLiquidatorProps } from "./types.js";
|
|
10
10
|
import { NamespaceOptions } from "../types.js";
|
|
11
11
|
//#region src/sdk/liquidations/LiquidationsNamespace.d.ts
|
|
12
12
|
/**
|
|
@@ -35,6 +35,10 @@ declare class LiquidationsNamespace implements ILiquidations {
|
|
|
35
35
|
* {@inheritDoc ILiquidations.checkLiquidation}
|
|
36
36
|
**/
|
|
37
37
|
checkLiquidation(props: CheckLiquidationInput, options?: CheckLiquidationOptions): Promise<LiquidationValidationError[]>;
|
|
38
|
+
/**
|
|
39
|
+
* {@inheritDoc ILiquidations.isEmergencyLiquidator}
|
|
40
|
+
**/
|
|
41
|
+
isEmergencyLiquidator(props: IsEmergencyLiquidatorProps): boolean;
|
|
38
42
|
}
|
|
39
43
|
//#endregion
|
|
40
44
|
export { LiquidationsNamespace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ILiquidations, ILiquidationsByMode } from "./types.js";
|
|
1
|
+
import { ILiquidations, ILiquidationsByMode, IsEmergencyLiquidatorProps } from "./types.js";
|
|
2
2
|
import { LiquidationsNamespace } from "./LiquidationsNamespace.js";
|
|
3
|
-
export { ILiquidations, ILiquidationsByMode, LiquidationsNamespace };
|
|
3
|
+
export { ILiquidations, ILiquidationsByMode, IsEmergencyLiquidatorProps, LiquidationsNamespace };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { TxCall } from "../../model/primitives.js";
|
|
1
|
+
import { ChainId, TxCall } from "../../model/primitives.js";
|
|
2
2
|
import { LiquidatableAccount, LiquidationDetails, LiquidationPosition } from "../../model/liquidations.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import "../../model/index.js";
|
|
5
5
|
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps } from "../../onchain/accounts/liquidations/types.js";
|
|
6
6
|
import { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError } from "../../onchain/validation/checkLiquidation.js";
|
|
7
7
|
import "../../onchain/index.js";
|
|
8
|
+
import { Address } from "viem";
|
|
8
9
|
//#region src/sdk/liquidations/types.d.ts
|
|
9
10
|
/**
|
|
10
11
|
* On-chain discovery of liquidatable credit accounts and delayed-withdrawal
|
|
@@ -38,6 +39,15 @@ interface ILiquidations {
|
|
|
38
39
|
* with the same `liquidator`.
|
|
39
40
|
**/
|
|
40
41
|
checkLiquidation(props: CheckLiquidationInput, options?: CheckLiquidationOptions): Promise<LiquidationValidationError[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether `liquidator` may liquidate while the facade is paused; `false` when unknown.
|
|
44
|
+
**/
|
|
45
|
+
isEmergencyLiquidator(props: IsEmergencyLiquidatorProps): boolean;
|
|
46
|
+
}
|
|
47
|
+
interface IsEmergencyLiquidatorProps {
|
|
48
|
+
chainId: ChainId;
|
|
49
|
+
creditManager: Address;
|
|
50
|
+
liquidator: Address;
|
|
41
51
|
}
|
|
42
52
|
/**
|
|
43
53
|
* `sdk.liquidations` per mode: an on-chain read, absent when the SDK reads no
|
|
@@ -49,4 +59,4 @@ interface ILiquidationsByMode {
|
|
|
49
59
|
both: ILiquidations;
|
|
50
60
|
}
|
|
51
61
|
//#endregion
|
|
52
|
-
export { ILiquidations, ILiquidationsByMode };
|
|
62
|
+
export { ILiquidations, ILiquidationsByMode, IsEmergencyLiquidatorProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChainId } from "../../model/primitives.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
import { Reward } from "../../model/rewards.js";
|
|
4
|
+
import "../../model/index.js";
|
|
5
|
+
import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
6
|
+
import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
|
|
7
|
+
import "../../onchain/index.js";
|
|
8
|
+
import { IRewards, RewardsKeys } from "./types.js";
|
|
9
|
+
import { NamespaceOptions } from "../types.js";
|
|
10
|
+
import { Address } from "viem";
|
|
11
|
+
//#region src/sdk/rewards/RewardsNamespace.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* {@inheritDoc IRewards}
|
|
14
|
+
**/
|
|
15
|
+
declare class RewardsNamespace extends MultichainConstruct implements IRewards {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(onchain: MultichainSDK, keys: RewardsKeys | undefined, options: NamespaceOptions);
|
|
18
|
+
/**
|
|
19
|
+
* {@inheritDoc IRewards.list}
|
|
20
|
+
**/
|
|
21
|
+
list(wallet: Address, chainIds?: ChainId[]): Promise<DataResponse<Reward[]>>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RewardsNamespace };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChainId } from "
|
|
2
|
-
import "
|
|
1
|
+
import { ChainId } from "../../model/primitives.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
3
|
import { BaseError } from "viem";
|
|
4
|
-
//#region src/rewards/errors.d.ts
|
|
4
|
+
//#region src/sdk/rewards/errors.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Thrown when Merkl did not answer for a chain.
|
|
7
7
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Token } from "
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
1
|
+
import { Token } from "../../model/primitives.js";
|
|
2
|
+
import { MerklReward } from "../../model/rewards.js";
|
|
3
|
+
import "../../model/index.js";
|
|
4
|
+
import { RewardsSdk } from "./types.js";
|
|
4
5
|
import { Address } from "viem";
|
|
5
|
-
//#region src/rewards/helpers.d.ts
|
|
6
|
+
//#region src/sdk/rewards/helpers.d.ts
|
|
6
7
|
/** A claimable amount of one token in one pool, before it is merged. */
|
|
7
8
|
interface RewardPart {
|
|
8
9
|
pool: Address;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IRewards, IRewardsByMode, RewardsKeys } from "./types.js";
|
|
2
|
+
import { MerklRequestFailedError, TurtleRequestFailedError } from "./errors.js";
|
|
3
|
+
import { MerkleXYZUserRewardsV4Response } from "./merkl-api.js";
|
|
4
|
+
import { RewardsNamespace } from "./RewardsNamespace.js";
|
|
5
|
+
import { TurtleWalletRewards } from "./turtle-api.js";
|
|
6
|
+
export { type IRewards, type IRewardsByMode, MerklRequestFailedError, type MerkleXYZUserRewardsV4Response, type RewardsKeys, RewardsNamespace, TurtleRequestFailedError, type TurtleWalletRewards };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChainId } from "
|
|
2
|
-
import "
|
|
1
|
+
import { ChainId } from "../../model/primitives.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
3
|
import { Address } from "viem";
|
|
4
|
-
//#region src/rewards/merkl-api.d.ts
|
|
4
|
+
//#region src/sdk/rewards/merkl-api.d.ts
|
|
5
5
|
interface MerkleXYZUserRewardsV4 {
|
|
6
6
|
chain: MerkleXYZChain;
|
|
7
7
|
rewards: Array<{
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { MerklReward
|
|
1
|
+
import { MerklReward } from "../../model/rewards.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { RewardsSdk } from "./types.js";
|
|
2
4
|
import { MerkleXYZUserRewardsV4Response } from "./merkl-api.js";
|
|
3
|
-
//#region src/rewards/toMerklRewards.d.ts
|
|
5
|
+
//#region src/sdk/rewards/toMerklRewards.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Merkl's answer for one chain, one reward per pool and incentive token.
|
|
6
8
|
* A breakdown Merkl cannot be read from is skipped rather than thrown on: it
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Reward
|
|
1
|
+
import { Reward } from "../../model/rewards.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { RewardsSdk } from "./types.js";
|
|
2
4
|
import { TurtleWalletRewards } from "./turtle-api.js";
|
|
3
|
-
//#region src/rewards/toTurtleRewards.d.ts
|
|
5
|
+
//#region src/sdk/rewards/toTurtleRewards.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* The streams targeting a pool on the SDK's chain, merged per pool and
|
|
6
8
|
* incentive. A token reward is what is committed and not yet claimed.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OnchainSDK } from "
|
|
2
|
-
import "
|
|
1
|
+
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
2
|
+
import "../../onchain/index.js";
|
|
3
3
|
import { Address } from "viem";
|
|
4
|
-
//#region src/rewards/turtle-api.d.ts
|
|
4
|
+
//#region src/sdk/rewards/turtle-api.d.ts
|
|
5
5
|
interface TurtleWalletStream {
|
|
6
6
|
streamId: string;
|
|
7
7
|
snapshots: Array<{
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChainId } from "../../model/primitives.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
import { Reward } from "../../model/rewards.js";
|
|
4
|
+
import "../../model/index.js";
|
|
5
|
+
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
6
|
+
import "../../onchain/index.js";
|
|
7
|
+
import { Address } from "viem";
|
|
8
|
+
//#region src/sdk/rewards/types.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Claimable Merkl and Turtle rewards.
|
|
11
|
+
**/
|
|
12
|
+
interface IRewards {
|
|
13
|
+
/**
|
|
14
|
+
* Claimable rewards of `wallet`; a chain errors only when every source failed on it.
|
|
15
|
+
**/
|
|
16
|
+
list(wallet: Address, chainIds?: ChainId[]): Promise<DataResponse<Reward[]>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `sdk.rewards` per mode: absent when the SDK reads no chain.
|
|
20
|
+
**/
|
|
21
|
+
interface IRewardsByMode {
|
|
22
|
+
onchain: IRewards;
|
|
23
|
+
offchain: undefined;
|
|
24
|
+
both: IRewards;
|
|
25
|
+
}
|
|
26
|
+
interface RewardsKeys {
|
|
27
|
+
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
28
|
+
merklApiKey?: string;
|
|
29
|
+
/** Turtle is skipped without one: its API answers no keyless request. */
|
|
30
|
+
turtleApiKey?: string;
|
|
31
|
+
}
|
|
32
|
+
/** What the mapping needs off a chain's SDK, and nothing asynchronous. */
|
|
33
|
+
type RewardsSdk = Pick<OnchainSDK, "chainId" | "marketRegister" | "tokensMeta">;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { IRewards, IRewardsByMode, RewardsKeys, RewardsSdk };
|
|
@@ -14,6 +14,7 @@ import { ILiquidationsByMode } from "./liquidations/types.js";
|
|
|
14
14
|
import { IOpportunities } from "./opportunities/types.js";
|
|
15
15
|
import { IPositions } from "./positions/types.js";
|
|
16
16
|
import { IPreviewByMode } from "./preview/types.js";
|
|
17
|
+
import { IRewardsByMode, RewardsKeys } from "./rewards/types.js";
|
|
17
18
|
//#region src/sdk/types.d.ts
|
|
18
19
|
/**
|
|
19
20
|
* Which sources a {@link GearboxSDK} reads from, and therefore which of its
|
|
@@ -74,6 +75,10 @@ interface GearboxSDKOptions<M extends Mode = Mode> {
|
|
|
74
75
|
* builds the on-chain source itself.
|
|
75
76
|
**/
|
|
76
77
|
attach?: MultichainAttachOptions;
|
|
78
|
+
/**
|
|
79
|
+
* API keys for {@link IGearboxSDK.rewards}.
|
|
80
|
+
**/
|
|
81
|
+
rewards?: RewardsKeys;
|
|
77
82
|
logger?: ILogger;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
@@ -170,6 +175,10 @@ interface IGearboxSDK<M extends Mode = Mode> {
|
|
|
170
175
|
* `offchain` mode.
|
|
171
176
|
**/
|
|
172
177
|
readonly preview: IPreviewByMode[M];
|
|
178
|
+
/**
|
|
179
|
+
* Namespace for claimable rewards. Absent in `offchain` mode.
|
|
180
|
+
**/
|
|
181
|
+
readonly rewards: IRewardsByMode[M];
|
|
173
182
|
/**
|
|
174
183
|
* The banners the backend attaches to a pool opportunity or a strategy
|
|
175
184
|
* position, see {@link Notice}. Absent in `onchain` mode.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.9.0",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -58,11 +58,6 @@
|
|
|
58
58
|
"types": "./dist/types/permissionless/index.d.ts",
|
|
59
59
|
"import": "./dist/esm/permissionless/index.js",
|
|
60
60
|
"default": "./dist/cjs/permissionless/index.js"
|
|
61
|
-
},
|
|
62
|
-
"./rewards": {
|
|
63
|
-
"types": "./dist/types/rewards/index.d.ts",
|
|
64
|
-
"import": "./dist/esm/rewards/index.js",
|
|
65
|
-
"default": "./dist/cjs/rewards/index.js"
|
|
66
61
|
}
|
|
67
62
|
},
|
|
68
63
|
"files": [
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_base_MultichainConstruct = require("../onchain/base/MultichainConstruct.js");
|
|
3
|
-
require("../onchain/index.js");
|
|
4
|
-
const require_rewards_merkl_api = require("./merkl-api.js");
|
|
5
|
-
const require_rewards_toMerklRewards = require("./toMerklRewards.js");
|
|
6
|
-
const require_rewards_toTurtleRewards = require("./toTurtleRewards.js");
|
|
7
|
-
const require_rewards_turtle_api = require("./turtle-api.js");
|
|
8
|
-
let viem = require("viem");
|
|
9
|
-
//#region src/rewards/RewardsService.ts
|
|
10
|
-
var RewardsService = class extends require_onchain_base_MultichainConstruct.MultichainConstruct {
|
|
11
|
-
#keys;
|
|
12
|
-
constructor(sdk, keys = {}) {
|
|
13
|
-
super(sdk);
|
|
14
|
-
this.#keys = keys;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Every claimable reward a wallet holds — Merkl campaigns and the Gearbox
|
|
18
|
-
* organisation's Turtle streams — across the chains the handle carries.
|
|
19
|
-
* A chain is `status: "error"` only when every source failed on it; a chain
|
|
20
|
-
* with nothing to claim is a `"success"` with no rewards.
|
|
21
|
-
**/
|
|
22
|
-
async list(wallet, chainIds) {
|
|
23
|
-
const { merklApiKey, turtleApiKey } = this.#keys;
|
|
24
|
-
const user = (0, viem.getAddress)(wallet);
|
|
25
|
-
const turtle = turtleApiKey ? require_rewards_turtle_api.fetchTurtleWalletRewards(user, turtleApiKey) : void 0;
|
|
26
|
-
turtle?.catch(() => {});
|
|
27
|
-
return this.queryChains({
|
|
28
|
-
chainIds,
|
|
29
|
-
label: "list rewards",
|
|
30
|
-
block: "state",
|
|
31
|
-
run: async (sdk) => {
|
|
32
|
-
const sources = [require_rewards_merkl_api.fetchMerklUserRewards({
|
|
33
|
-
chainId: sdk.chainId,
|
|
34
|
-
user,
|
|
35
|
-
apiKey: merklApiKey
|
|
36
|
-
}).then((response) => require_rewards_toMerklRewards.toMerklRewards(sdk, response))];
|
|
37
|
-
if (turtle) sources.push(turtle.then(async (rewards) => require_rewards_toTurtleRewards.toTurtleRewards(sdk, rewards, await require_rewards_turtle_api.readTurtleClaimed(sdk, user, rewards))));
|
|
38
|
-
const settled = await Promise.allSettled(sources);
|
|
39
|
-
const failed = settled.flatMap((r) => r.status === "rejected" ? [r.reason] : []);
|
|
40
|
-
if (failed.length === settled.length) throw failed.length === 1 ? failed[0] : new AggregateError(failed, "no rewards source answered");
|
|
41
|
-
for (const reason of failed) (sdk.logger ?? this.sdk.logger)?.warn(reason, `rewards source failed on chain ${sdk.chainId}`);
|
|
42
|
-
return settled.flatMap((r) => r.status === "fulfilled" ? r.value : []);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
exports.RewardsService = RewardsService;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rewards_errors = require("./errors.js");
|
|
3
|
-
const require_rewards_RewardsService = require("./RewardsService.js");
|
|
4
|
-
exports.MerklRequestFailedError = require_rewards_errors.MerklRequestFailedError;
|
|
5
|
-
exports.RewardsService = require_rewards_RewardsService.RewardsService;
|
|
6
|
-
exports.TurtleRequestFailedError = require_rewards_errors.TurtleRequestFailedError;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "module","sideEffects":false}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ChainId } from "../model/primitives.js";
|
|
2
|
-
import { DataResponse } from "../model/response.js";
|
|
3
|
-
import "../model/index.js";
|
|
4
|
-
import { PluginsMap } from "../onchain/plugins/types.js";
|
|
5
|
-
import { MultichainSDK } from "../onchain/MultichainSDK.js";
|
|
6
|
-
import { MultichainConstruct } from "../onchain/base/MultichainConstruct.js";
|
|
7
|
-
import "../onchain/index.js";
|
|
8
|
-
import { Reward } from "./types.js";
|
|
9
|
-
import { Address } from "viem";
|
|
10
|
-
//#region src/rewards/RewardsService.d.ts
|
|
11
|
-
interface RewardsServiceKeys {
|
|
12
|
-
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
13
|
-
merklApiKey?: string;
|
|
14
|
-
/** Turtle is skipped without one: its API answers no keyless request. */
|
|
15
|
-
turtleApiKey?: string;
|
|
16
|
-
}
|
|
17
|
-
declare class RewardsService<const Plugins extends PluginsMap = {}> extends MultichainConstruct<Plugins> {
|
|
18
|
-
#private;
|
|
19
|
-
constructor(sdk: MultichainSDK<Plugins>, keys?: RewardsServiceKeys);
|
|
20
|
-
/**
|
|
21
|
-
* Every claimable reward a wallet holds — Merkl campaigns and the Gearbox
|
|
22
|
-
* organisation's Turtle streams — across the chains the handle carries.
|
|
23
|
-
* A chain is `status: "error"` only when every source failed on it; a chain
|
|
24
|
-
* with nothing to claim is a `"success"` with no rewards.
|
|
25
|
-
**/
|
|
26
|
-
list(wallet: Address, chainIds?: ChainId[]): Promise<DataResponse<Reward[]>>;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { RewardsService };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { MerklReward, PointsReward, Reward } from "./types.js";
|
|
2
|
-
import { RewardsService } from "./RewardsService.js";
|
|
3
|
-
import { MerklRequestFailedError, TurtleRequestFailedError } from "./errors.js";
|
|
4
|
-
import { MerkleXYZUserRewardsV4Response } from "./merkl-api.js";
|
|
5
|
-
import { TurtleWalletRewards } from "./turtle-api.js";
|
|
6
|
-
export { MerklRequestFailedError, type MerklReward, type MerkleXYZUserRewardsV4Response, type PointsReward, type Reward, RewardsService, TurtleRequestFailedError, type TurtleWalletRewards };
|
|
File without changes
|