@gearbox-protocol/sdk 17.2.0 → 17.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/rewards/{multichain.js → RewardsService.js} +18 -30
- package/dist/cjs/rewards/errors.js +4 -4
- package/dist/cjs/rewards/helpers.js +88 -0
- package/dist/cjs/rewards/index.js +2 -2
- package/dist/cjs/rewards/merkl-api.js +14 -25
- package/dist/cjs/rewards/toMerklRewards.js +21 -77
- package/dist/cjs/rewards/toTurtleRewards.js +46 -62
- package/dist/cjs/rewards/turtle-api.js +17 -0
- package/dist/cjs/rewards/types.js +1 -0
- package/dist/esm/rewards/{multichain.js → RewardsService.js} +19 -31
- package/dist/esm/rewards/errors.js +4 -4
- package/dist/esm/rewards/helpers.js +83 -0
- package/dist/esm/rewards/index.js +2 -2
- package/dist/esm/rewards/merkl-api.js +15 -25
- package/dist/esm/rewards/toMerklRewards.js +23 -78
- package/dist/esm/rewards/toTurtleRewards.js +46 -62
- package/dist/esm/rewards/turtle-api.js +17 -1
- package/dist/esm/rewards/types.js +1 -0
- package/dist/types/rewards/RewardsService.d.ts +29 -0
- package/dist/types/rewards/errors.d.ts +2 -2
- package/dist/types/rewards/helpers.d.ts +44 -0
- package/dist/types/rewards/index.d.ts +3 -3
- package/dist/types/rewards/merkl-api.d.ts +5 -10
- package/dist/types/rewards/toMerklRewards.d.ts +5 -48
- package/dist/types/rewards/toTurtleRewards.d.ts +3 -3
- package/dist/types/rewards/turtle-api.d.ts +5 -1
- package/dist/types/rewards/types.d.ts +41 -0
- package/package.json +1 -1
- package/dist/types/rewards/multichain.d.ts +0 -28
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChainId, Token, TokenAmount } from "../model/primitives.js";
|
|
2
|
+
import { PointsProgramPnL } from "../model/positions.js";
|
|
3
|
+
import "../model/index.js";
|
|
4
|
+
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
5
|
+
import "../onchain/index.js";
|
|
6
|
+
import { Address } from "viem";
|
|
7
|
+
//#region src/rewards/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* One claimable token reward, denominated and priced.
|
|
10
|
+
*
|
|
11
|
+
* Both tokens arrive resolved, so a consumer neither looks one up nor
|
|
12
|
+
* reassembles one out of the loose fields a source sends.
|
|
13
|
+
*/
|
|
14
|
+
interface MerklReward {
|
|
15
|
+
/** Where the reward is claimed. */
|
|
16
|
+
readonly source: "merkl" | "turtle";
|
|
17
|
+
readonly chainId: ChainId;
|
|
18
|
+
/** Market pool whose depositors the campaign rewards. */
|
|
19
|
+
readonly pool: Address;
|
|
20
|
+
/** That pool's share token — what the campaign is keyed on. */
|
|
21
|
+
readonly poolToken: Token;
|
|
22
|
+
/**
|
|
23
|
+
* The incentive token being handed out, how much of it is claimable
|
|
24
|
+
* (distributed minus already claimed, always > 0) and what that is worth.
|
|
25
|
+
*
|
|
26
|
+
* Priced by the source, not by the market oracles: a campaign's incentive
|
|
27
|
+
* token is rarely collateral in the pool it incentivises, so the oracles
|
|
28
|
+
* usually do not know it — GEAR, which most Gearbox campaigns pay in, among
|
|
29
|
+
* them. `valueUsd` is `null` for a token the source does not price either.
|
|
30
|
+
*/
|
|
31
|
+
readonly amount: TokenAmount;
|
|
32
|
+
}
|
|
33
|
+
/** Points have no token and no price, and are not claimed. */
|
|
34
|
+
interface PointsReward extends Omit<MerklReward, "amount"> {
|
|
35
|
+
readonly points: PointsProgramPnL;
|
|
36
|
+
}
|
|
37
|
+
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
|
+
//#endregion
|
|
41
|
+
export { MerklReward, PointsReward, Reward, RewardsSdk };
|
package/package.json
CHANGED
|
@@ -1,28 +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 "../onchain/index.js";
|
|
7
|
-
import { Reward } from "./toMerklRewards.js";
|
|
8
|
-
import { Address } from "viem";
|
|
9
|
-
//#region src/rewards/multichain.d.ts
|
|
10
|
-
interface GetRewardsMultichainProps<Plugins extends PluginsMap = {}> {
|
|
11
|
-
sdk: MultichainSDK<Plugins>;
|
|
12
|
-
wallet: Address;
|
|
13
|
-
/** Defaults to every chain the handle carries. */
|
|
14
|
-
chainIds?: ChainId[];
|
|
15
|
-
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
16
|
-
merklApiKey?: string;
|
|
17
|
-
/** Turtle is skipped without one: its API answers no keyless request. */
|
|
18
|
-
turtleApiKey?: string;
|
|
19
|
-
}
|
|
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 rows.
|
|
25
|
-
**/
|
|
26
|
-
declare function getRewardsMultichain<const Plugins extends PluginsMap = {}>({ sdk, ...props }: GetRewardsMultichainProps<Plugins>): Promise<DataResponse<Reward[]>>;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { GetRewardsMultichainProps, getRewardsMultichain };
|