@gearbox-protocol/sdk 13.5.3 → 13.6.0-apy-plugin.2

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.
Files changed (43) hide show
  1. package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
  2. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
  3. package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
  4. package/dist/cjs/plugins/adapters/types.js +1 -1
  5. package/dist/cjs/plugins/pools-history/ApyPlugin.js +265 -0
  6. package/dist/cjs/plugins/pools-history/apy-cache.js +120 -0
  7. package/dist/cjs/plugins/pools-history/apy-parser.js +169 -0
  8. package/dist/cjs/plugins/pools-history/constants.js +31 -0
  9. package/dist/cjs/plugins/pools-history/index.js +12 -2
  10. package/dist/cjs/plugins/pools-history/pool-apy-types.js +16 -0
  11. package/dist/cjs/plugins/pools-history/pool-apy-utils.js +141 -0
  12. package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
  13. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +2 -39
  14. package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
  15. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
  16. package/dist/esm/plugins/adapters/createAdapter.js +1 -1
  17. package/dist/esm/plugins/adapters/types.js +1 -1
  18. package/dist/esm/plugins/pools-history/ApyPlugin.js +254 -0
  19. package/dist/esm/plugins/pools-history/apy-cache.js +86 -0
  20. package/dist/esm/plugins/pools-history/apy-parser.js +143 -0
  21. package/dist/esm/plugins/pools-history/constants.js +6 -0
  22. package/dist/esm/plugins/pools-history/index.js +6 -1
  23. package/dist/esm/plugins/pools-history/pool-apy-types.js +0 -0
  24. package/dist/esm/plugins/pools-history/pool-apy-utils.js +113 -0
  25. package/dist/esm/rewards/rewards/extra-apy.js +10 -8
  26. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +2 -41
  27. package/dist/types/plugins/adapters/types.d.ts +2 -2
  28. package/dist/types/plugins/pools-history/ApyPlugin.d.ts +46 -0
  29. package/dist/types/plugins/pools-history/apy-cache.d.ts +28 -0
  30. package/dist/types/plugins/pools-history/apy-parser.d.ts +5 -0
  31. package/dist/types/plugins/pools-history/constants.d.ts +2 -0
  32. package/dist/types/plugins/pools-history/index.d.ts +6 -1
  33. package/dist/types/plugins/pools-history/pool-apy-types.d.ts +39 -0
  34. package/dist/types/plugins/pools-history/pool-apy-utils.d.ts +71 -0
  35. package/dist/types/plugins/pools-history/types.d.ts +28 -0
  36. package/dist/types/rewards/rewards/api.d.ts +10 -1
  37. package/dist/types/rewards/rewards/common.d.ts +0 -10
  38. package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
  39. package/dist/types/sdk/base/types.d.ts +0 -9
  40. package/package.json +1 -1
  41. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
  42. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
  43. package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
@@ -4,13 +4,3 @@ export interface TokenData {
4
4
  symbol: string;
5
5
  decimals: number;
6
6
  }
7
- export interface PoolData {
8
- address: Address;
9
- version: number;
10
- underlyingToken: Address;
11
- dieselRateRay: bigint;
12
- dieselToken: Address;
13
- stakedDieselToken: Address[];
14
- stakedDieselToken_old: Address[];
15
- expectedLiquidity: bigint;
16
- }
@@ -1,13 +1,12 @@
1
1
  import type { Address } from "viem";
2
- import { type Asset, type NetworkType } from "../../sdk/index.js";
2
+ import { type Asset, type MarketSuite, type NetworkType, type TokensMeta } from "../../sdk/index.js";
3
3
  import type { PoolPointsInfo } from "../index.js";
4
- import type { PoolData, TokenData } from "./common.js";
5
- type PartialPool = Pick<PoolData, "expectedLiquidity" | "underlyingToken" | "address">;
4
+ import type { TokenData } from "./common.js";
6
5
  export interface GetPointsByPoolProps {
7
6
  poolRewards: Record<Address, Array<PoolPointsInfo<string>>>;
8
7
  totalTokenBalances: Record<Address, Asset>;
9
- pools: Array<PartialPool>;
10
- tokensList: Record<Address, TokenData>;
8
+ pools: MarketSuite[];
9
+ tokensList: TokensMeta;
11
10
  }
12
11
  export interface GetTotalTokensOnProtocolProps {
13
12
  tokensToCheck: Array<Address>;
@@ -27,4 +26,3 @@ export declare class PoolPointsAPI {
27
26
  static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps): PoolPointsBase;
28
27
  private static getPoolTokenPoints;
29
28
  }
30
- export {};
@@ -5,7 +5,6 @@ import type { gaugeCompressorAbi } from "../../abi/compressors/gaugeCompressor.j
5
5
  import type { marketCompressorAbi } from "../../abi/compressors/marketCompressor.js";
6
6
  import type { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
7
7
  import type { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
8
- import type { NetworkType } from "../chain/index.js";
9
8
  /**
10
9
  * Recursively unwraps array types to their element type.
11
10
  **/
@@ -245,14 +244,6 @@ export interface IBaseContract {
245
244
  * labeling methods for user-facing output.
246
245
  */
247
246
  readonly name: string;
248
- /**
249
- * Chain ID of the contract.
250
- **/
251
- readonly chainId: number;
252
- /**
253
- * Network type of the contract.
254
- **/
255
- readonly networkType: NetworkType;
256
247
  /**
257
248
  * @internal
258
249
  * `true` when the local state has diverged from on-chain and needs a sync.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "13.5.3",
3
+ "version": "13.6.0-apy-plugin.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var Pools7DAgoPlugin_exports = {};
20
- __export(Pools7DAgoPlugin_exports, {
21
- Pools7DAgoPlugin: () => Pools7DAgoPlugin
22
- });
23
- module.exports = __toCommonJS(Pools7DAgoPlugin_exports);
24
- var import_marketCompressor = require("../../abi/compressors/marketCompressor.js");
25
- var import_sdk = require("../../sdk/index.js");
26
- const MAP_LABEL = "pools7DAgo";
27
- class Pools7DAgoPlugin extends import_sdk.BasePlugin {
28
- #pools7DAgo;
29
- async load(force) {
30
- if (!force && this.loaded) {
31
- return this.state;
32
- }
33
- const targetBlock = this.sdk.currentBlock - import_sdk.BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.networkType];
34
- const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
35
- import_sdk.AP_MARKET_COMPRESSOR,
36
- import_sdk.VERSION_RANGE_310
37
- );
38
- this.sdk.logger?.debug(
39
- `loading pools 7d ago with market compressor ${marketCompressorAddress}`
40
- );
41
- const markets = this.sdk.marketRegister.markets;
42
- const resp = await this.client.multicall({
43
- allowFailure: true,
44
- contracts: markets.map(
45
- (m) => ({
46
- address: marketCompressorAddress,
47
- abi: import_marketCompressor.marketCompressorAbi,
48
- functionName: "getPoolState",
49
- args: [m.pool.pool.address]
50
- })
51
- ),
52
- blockNumber: targetBlock > 0n ? targetBlock : void 0,
53
- batchSize: 0
54
- });
55
- this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
56
- resp.forEach((r, index) => {
57
- const m = markets[index];
58
- const cfg = m.configurator.address;
59
- const pool = m.pool.pool.address;
60
- if (r.status === "success") {
61
- this.#pools7DAgo?.upsert(m.pool.pool.address, {
62
- dieselRate: r.result.dieselRate,
63
- pool
64
- });
65
- } else {
66
- this.sdk.logger?.error(
67
- `failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
68
- );
69
- }
70
- });
71
- return this.state;
72
- }
73
- get loaded() {
74
- return !!this.#pools7DAgo;
75
- }
76
- /**
77
- * Returns a map of pool addresses to minified pool 7d ago state
78
- * @throws if pool 7d ago plugin is not attached
79
- */
80
- get pools7DAgo() {
81
- if (!this.#pools7DAgo) {
82
- throw new Error("pools 7d ago plugin not attached");
83
- }
84
- return this.#pools7DAgo;
85
- }
86
- stateHuman(_) {
87
- return this.pools7DAgo.values().flatMap((p) => ({
88
- address: p.pool,
89
- version: this.version,
90
- dieselRate: p.dieselRate
91
- }));
92
- }
93
- get state() {
94
- return {
95
- pools7DAgo: this.pools7DAgo.asRecord()
96
- };
97
- }
98
- hydrate(state) {
99
- this.#pools7DAgo = new import_sdk.AddressMap(
100
- Object.entries(state.pools7DAgo),
101
- MAP_LABEL
102
- );
103
- }
104
- }
105
- // Annotate the CommonJS export names for ESM import in node:
106
- 0 && (module.exports = {
107
- Pools7DAgoPlugin
108
- });
@@ -1,90 +0,0 @@
1
- import { marketCompressorAbi } from "../../abi/compressors/marketCompressor.js";
2
- import {
3
- AddressMap,
4
- AP_MARKET_COMPRESSOR,
5
- BasePlugin,
6
- BLOCKS_PER_WEEK_BY_NETWORK,
7
- VERSION_RANGE_310
8
- } from "../../sdk/index.js";
9
- const MAP_LABEL = "pools7DAgo";
10
- class Pools7DAgoPlugin extends BasePlugin {
11
- #pools7DAgo;
12
- async load(force) {
13
- if (!force && this.loaded) {
14
- return this.state;
15
- }
16
- const targetBlock = this.sdk.currentBlock - BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.networkType];
17
- const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
18
- AP_MARKET_COMPRESSOR,
19
- VERSION_RANGE_310
20
- );
21
- this.sdk.logger?.debug(
22
- `loading pools 7d ago with market compressor ${marketCompressorAddress}`
23
- );
24
- const markets = this.sdk.marketRegister.markets;
25
- const resp = await this.client.multicall({
26
- allowFailure: true,
27
- contracts: markets.map(
28
- (m) => ({
29
- address: marketCompressorAddress,
30
- abi: marketCompressorAbi,
31
- functionName: "getPoolState",
32
- args: [m.pool.pool.address]
33
- })
34
- ),
35
- blockNumber: targetBlock > 0n ? targetBlock : void 0,
36
- batchSize: 0
37
- });
38
- this.#pools7DAgo = new AddressMap(void 0, MAP_LABEL);
39
- resp.forEach((r, index) => {
40
- const m = markets[index];
41
- const cfg = m.configurator.address;
42
- const pool = m.pool.pool.address;
43
- if (r.status === "success") {
44
- this.#pools7DAgo?.upsert(m.pool.pool.address, {
45
- dieselRate: r.result.dieselRate,
46
- pool
47
- });
48
- } else {
49
- this.sdk.logger?.error(
50
- `failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
51
- );
52
- }
53
- });
54
- return this.state;
55
- }
56
- get loaded() {
57
- return !!this.#pools7DAgo;
58
- }
59
- /**
60
- * Returns a map of pool addresses to minified pool 7d ago state
61
- * @throws if pool 7d ago plugin is not attached
62
- */
63
- get pools7DAgo() {
64
- if (!this.#pools7DAgo) {
65
- throw new Error("pools 7d ago plugin not attached");
66
- }
67
- return this.#pools7DAgo;
68
- }
69
- stateHuman(_) {
70
- return this.pools7DAgo.values().flatMap((p) => ({
71
- address: p.pool,
72
- version: this.version,
73
- dieselRate: p.dieselRate
74
- }));
75
- }
76
- get state() {
77
- return {
78
- pools7DAgo: this.pools7DAgo.asRecord()
79
- };
80
- }
81
- hydrate(state) {
82
- this.#pools7DAgo = new AddressMap(
83
- Object.entries(state.pools7DAgo),
84
- MAP_LABEL
85
- );
86
- }
87
- }
88
- export {
89
- Pools7DAgoPlugin
90
- };
@@ -1,20 +0,0 @@
1
- import type { Address } from "viem";
2
- import type { IGearboxSDKPlugin } from "../../sdk/index.js";
3
- import { AddressMap, BasePlugin } from "../../sdk/index.js";
4
- import type { Pool7DAgoState, Pools7DAgoStateHuman } from "./types.js";
5
- export interface Pools7DAgoPluginState {
6
- pools7DAgo: Record<Address, Pool7DAgoState>;
7
- }
8
- export declare class Pools7DAgoPlugin extends BasePlugin<Pools7DAgoPluginState> implements IGearboxSDKPlugin<Pools7DAgoPluginState> {
9
- #private;
10
- load(force?: boolean): Promise<Pools7DAgoPluginState>;
11
- get loaded(): boolean;
12
- /**
13
- * Returns a map of pool addresses to minified pool 7d ago state
14
- * @throws if pool 7d ago plugin is not attached
15
- */
16
- get pools7DAgo(): AddressMap<Pool7DAgoState>;
17
- stateHuman(_?: boolean): Pools7DAgoStateHuman[];
18
- get state(): Pools7DAgoPluginState;
19
- hydrate(state: Pools7DAgoPluginState): void;
20
- }