@gearbox-protocol/sdk 7.11.0-next.3 → 7.11.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/adapters/AdaptersPlugin.js +3 -2
- package/dist/cjs/bots/BotsPlugin.js +17 -29
- package/dist/cjs/dev/AccountsCounterPlugin.js +10 -19
- package/dist/cjs/dev/createTransport.js +2 -1
- package/dist/cjs/sdk/GearboxSDK.js +3 -13
- package/dist/cjs/sdk/chain/chains.js +21 -10
- package/dist/cjs/sdk/constants/address-provider.js +2 -1
- package/dist/cjs/sdk/constants/addresses.js +8 -4
- package/dist/cjs/sdk/constants/networks.js +5 -2
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +1 -3
- package/dist/cjs/sdk/router/RouterV300Contract.js +2 -1
- package/dist/cjs/sdk/sdk-gov-legacy/contracts/contracts.js +74 -37
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/token.js +4 -2
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/tokenData.js +2 -1
- package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +2 -1
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +159 -94
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/cjs/sdk/sdk-legacy/index.js +2 -0
- package/dist/cjs/{pools7DAgo/types.js → sdk/sdk-legacy/pathfinder/core.js} +2 -2
- package/dist/cjs/{pools7DAgo → sdk/sdk-legacy/pathfinder}/index.js +4 -6
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +1 -0
- package/dist/cjs/zappers/ZappersPlugin.js +4 -13
- package/dist/esm/adapters/AdaptersPlugin.js +3 -2
- package/dist/esm/bots/BotsPlugin.js +17 -29
- package/dist/esm/dev/AccountsCounterPlugin.js +10 -19
- package/dist/esm/dev/createTransport.js +2 -1
- package/dist/esm/sdk/GearboxSDK.js +3 -13
- package/dist/esm/sdk/chain/chains.js +22 -10
- package/dist/esm/sdk/constants/address-provider.js +2 -1
- package/dist/esm/sdk/constants/addresses.js +8 -4
- package/dist/esm/sdk/constants/networks.js +5 -2
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +1 -3
- package/dist/esm/sdk/router/RouterV300Contract.js +2 -1
- package/dist/esm/sdk/sdk-gov-legacy/contracts/contracts.js +74 -37
- package/dist/esm/sdk/sdk-gov-legacy/tokens/token.js +4 -2
- package/dist/esm/sdk/sdk-gov-legacy/tokens/tokenData.js +2 -1
- package/dist/esm/sdk/sdk-legacy/core/endpoint.js +2 -1
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +159 -94
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/apy.js +1 -1
- package/dist/esm/sdk/sdk-legacy/index.js +1 -0
- package/dist/esm/sdk/sdk-legacy/pathfinder/index.js +1 -0
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -0
- package/dist/esm/zappers/ZappersPlugin.js +4 -13
- package/dist/types/adapters/AdaptersPlugin.d.ts +4 -5
- package/dist/types/bots/BotsPlugin.d.ts +3 -5
- package/dist/types/bots/types.d.ts +2 -2
- package/dist/types/dev/AccountsCounterPlugin.d.ts +2 -4
- package/dist/types/sdk/GearboxSDK.d.ts +3 -4
- package/dist/types/sdk/chain/chains.d.ts +2 -2
- package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +2 -3
- package/dist/types/sdk/plugins/types.d.ts +15 -33
- package/dist/types/sdk/sdk-legacy/gearboxRewards/api.d.ts +27 -16
- package/dist/types/sdk/sdk-legacy/gearboxRewards/apy.d.ts +15 -9
- package/dist/types/sdk/sdk-legacy/index.d.ts +1 -0
- package/dist/types/sdk/sdk-legacy/pathfinder/core.d.ts +14 -0
- package/dist/types/sdk/sdk-legacy/pathfinder/index.d.ts +1 -0
- package/dist/types/zappers/ZappersPlugin.d.ts +4 -5
- package/package.json +1 -1
- package/dist/cjs/degenDistributors/DegenDistributorsPlugin.js +0 -110
- package/dist/cjs/degenDistributors/index.js +0 -24
- package/dist/cjs/degenDistributors/package.json +0 -1
- package/dist/cjs/degenDistributors/types.js +0 -16
- package/dist/cjs/pools7DAgo/Pools7DAgoPlugin.js +0 -116
- package/dist/cjs/pools7DAgo/package.json +0 -1
- package/dist/esm/degenDistributors/DegenDistributorsPlugin.js +0 -86
- package/dist/esm/degenDistributors/index.js +0 -2
- package/dist/esm/degenDistributors/package.json +0 -1
- package/dist/esm/pools7DAgo/Pools7DAgoPlugin.js +0 -99
- package/dist/esm/pools7DAgo/index.js +0 -2
- package/dist/esm/pools7DAgo/package.json +0 -1
- package/dist/esm/pools7DAgo/types.js +0 -0
- package/dist/types/degenDistributors/DegenDistributorsPlugin.d.ts +0 -22
- package/dist/types/degenDistributors/index.d.ts +0 -2
- package/dist/types/degenDistributors/types.d.ts +0 -4
- package/dist/types/pools7DAgo/Pools7DAgoPlugin.d.ts +0 -22
- package/dist/types/pools7DAgo/index.d.ts +0 -2
- package/dist/types/pools7DAgo/types.d.ts +0 -9
- /package/dist/esm/{degenDistributors/types.js → sdk/sdk-legacy/pathfinder/core.js} +0 -0
|
@@ -40,25 +40,28 @@ export interface MerkleDistributorInfo {
|
|
|
40
40
|
proof: Array<Address>;
|
|
41
41
|
}>;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
reportError?: ReportHandler;
|
|
43
|
+
export interface FarmInfo {
|
|
44
|
+
pool: Address;
|
|
45
|
+
finished: bigint;
|
|
46
|
+
duration: bigint;
|
|
47
|
+
reward: bigint;
|
|
48
|
+
balance: bigint;
|
|
49
|
+
symbol: SupportedToken;
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
type ReportHandler = (e: unknown, description?: string) => void;
|
|
52
|
+
export interface GetLmRewardsInfoProps {
|
|
53
|
+
pools: Record<Address, PoolData_Legacy>;
|
|
54
54
|
tokensList: Record<Address, TokenData>;
|
|
55
|
-
account: Address;
|
|
56
55
|
provider: PublicClient;
|
|
57
|
-
reportError?: ReportHandler;
|
|
58
56
|
}
|
|
59
|
-
export interface
|
|
57
|
+
export interface GetLmRewardsProps {
|
|
60
58
|
pools: Record<Address, PoolData_Legacy>;
|
|
59
|
+
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
60
|
+
currentTokenData: Record<SupportedToken, Address>;
|
|
61
|
+
tokensList: Record<Address, TokenData>;
|
|
61
62
|
account: Address;
|
|
63
|
+
provider: PublicClient;
|
|
64
|
+
airdropDistributorAddress: Address | undefined;
|
|
62
65
|
network: NetworkType;
|
|
63
66
|
reportError?: ReportHandler;
|
|
64
67
|
}
|
|
@@ -75,9 +78,17 @@ export interface ClaimLmRewardsV3Props {
|
|
|
75
78
|
signer: WalletClient;
|
|
76
79
|
}
|
|
77
80
|
export declare class GearboxRewardsApi {
|
|
78
|
-
static
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
static getLmRewardsInfo({ pools, provider, tokensList, }: GetLmRewardsInfoProps): Promise<{
|
|
82
|
+
rewardPoolsInfo: Record<string, FarmInfo[]>;
|
|
83
|
+
baseRewardPoolsInfo: Record<string, FarmInfo>;
|
|
84
|
+
rewardPoolsSupply: Record<string, bigint>;
|
|
85
|
+
}>;
|
|
86
|
+
static getLmRewardsV2({ provider, account, currentTokenData, network, airdropDistributorAddress, }: GetLmRewardsProps): Promise<{
|
|
87
|
+
rewards: GearboxLmReward[];
|
|
88
|
+
}>;
|
|
89
|
+
static getLmRewardsV3({ pools, baseRewardPoolsInfo, currentTokenData, tokensList, provider, account, network, reportError, }: GetLmRewardsProps): Promise<{
|
|
90
|
+
rewards: (GearboxLmReward | GearboxLmReward[])[];
|
|
91
|
+
}>;
|
|
81
92
|
private static extractFulfilled;
|
|
82
93
|
static claimLmRewardsV2({ signer, account, provider, network, airdropDistributorAddress, }: ClaimLmRewardsV2Props): Promise<`0x${string}`>;
|
|
83
94
|
static claimLmRewardsV3({ reward, signer, account, }: ClaimLmRewardsV3Props): Promise<`0x${string}`>;
|
|
@@ -3,13 +3,19 @@ import type { Asset } from "../../router/index.js";
|
|
|
3
3
|
import type { SupportedToken } from "../../sdk-gov-legacy/index.js";
|
|
4
4
|
import type { PoolData_Legacy } from "../core/pool.js";
|
|
5
5
|
import type { TokenData } from "../tokens/tokenData.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import type { FarmInfo } from "./api.js";
|
|
7
|
+
interface CalculateV3PoolLmAPYProps {
|
|
8
|
+
currentTimestamp: number;
|
|
9
|
+
info: FarmInfo;
|
|
10
|
+
supply: {
|
|
11
|
+
decimals: number;
|
|
12
|
+
amount: bigint;
|
|
13
|
+
price: bigint;
|
|
14
|
+
};
|
|
15
|
+
reward: {
|
|
16
|
+
decimals: number;
|
|
17
|
+
price: bigint;
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
export interface ExtraRewardApy {
|
|
15
21
|
token: Address;
|
|
@@ -23,7 +29,7 @@ interface GetPoolExtraAPY_V3Props {
|
|
|
23
29
|
stakedDieselToken: Address | undefined;
|
|
24
30
|
pool: PoolData_Legacy;
|
|
25
31
|
prices: Record<Address, bigint>;
|
|
26
|
-
rewardPoolsInfo: Record<Address, Array<FarmInfo
|
|
32
|
+
rewardPoolsInfo: Record<Address, Array<FarmInfo>>;
|
|
27
33
|
rewardPoolsSupply: Record<Address, bigint>;
|
|
28
34
|
tokensList: Record<Address, TokenData>;
|
|
29
35
|
currentTokenData: Record<SupportedToken, Address>;
|
|
@@ -41,7 +47,7 @@ interface GetCAExtraAPYProps {
|
|
|
41
47
|
export declare class GearboxRewardsApy {
|
|
42
48
|
static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy>;
|
|
43
49
|
private static getPoolSingleExtraLmAPY_V3;
|
|
44
|
-
|
|
50
|
+
static calculateAPY_V3({ info, supply, reward, currentTimestamp, }: CalculateV3PoolLmAPYProps): number;
|
|
45
51
|
static getCAExtraAPY_V3({ rewardInfo, assets, ...restProps }: GetCAExtraAPYProps): Array<ExtraRewardApy>;
|
|
46
52
|
private static getCASingleExtraAPY_V3;
|
|
47
53
|
}
|
|
@@ -9,6 +9,7 @@ export * from "./core/pool.js";
|
|
|
9
9
|
export * from "./core/strategy.js";
|
|
10
10
|
export * from "./core/transactions.js";
|
|
11
11
|
export * from "./gearboxRewards/index.js";
|
|
12
|
+
export * from "./pathfinder/index.js";
|
|
12
13
|
export * from "./payload/creditAccount.js";
|
|
13
14
|
export * from "./payload/creditManager.js";
|
|
14
15
|
export * from "./payload/creditSession.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { MultiCall } from "../../types/index.js";
|
|
3
|
+
export interface PathFinderResult {
|
|
4
|
+
amount: bigint;
|
|
5
|
+
minAmount: bigint;
|
|
6
|
+
calls: MultiCall[];
|
|
7
|
+
}
|
|
8
|
+
export interface PathFinderOpenStrategyResult extends PathFinderResult {
|
|
9
|
+
balances: Record<Address, bigint>;
|
|
10
|
+
minBalances: Record<Address, bigint>;
|
|
11
|
+
}
|
|
12
|
+
export interface PathFinderCloseResult extends PathFinderResult {
|
|
13
|
+
underlyingBalance: bigint;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core.js";
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { IGearboxSDKPlugin } from "../sdk/index.js";
|
|
2
|
+
import type { IGearboxSDKPlugin, IPluginState } from "../sdk/index.js";
|
|
3
3
|
import { AddressMap, SDKConstruct } from "../sdk/index.js";
|
|
4
4
|
import type { ZapperDataFull, ZapperStateHuman } from "./types.js";
|
|
5
|
-
export interface ZappersPluginState {
|
|
5
|
+
export interface ZappersPluginState extends IPluginState {
|
|
6
6
|
zappers: Record<Address, ZapperDataFull[]>;
|
|
7
7
|
}
|
|
8
8
|
export declare class ZappersPlugin extends SDKConstruct implements IGearboxSDKPlugin<ZappersPluginState> {
|
|
9
9
|
#private;
|
|
10
10
|
readonly version = 1;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
attach(): Promise<void>;
|
|
12
|
+
loadZappers(): Promise<void>;
|
|
13
13
|
get zappers(): AddressMap<ZapperDataFull[]>;
|
|
14
|
-
get loaded(): boolean;
|
|
15
14
|
stateHuman(_?: boolean): ZapperStateHuman[];
|
|
16
15
|
get state(): ZappersPluginState;
|
|
17
16
|
hydrate(state: ZappersPluginState): void;
|
package/package.json
CHANGED
|
@@ -1,110 +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 DegenDistributorsPlugin_exports = {};
|
|
20
|
-
__export(DegenDistributorsPlugin_exports, {
|
|
21
|
-
DegenDistributorsPlugin: () => DegenDistributorsPlugin
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(DegenDistributorsPlugin_exports);
|
|
24
|
-
var import_sdk = require("../sdk/index.js");
|
|
25
|
-
const MAP_LABEL = "degenDistributors";
|
|
26
|
-
class DegenDistributorsPlugin extends import_sdk.SDKConstruct {
|
|
27
|
-
#distributors;
|
|
28
|
-
version = 1;
|
|
29
|
-
// public async attach(): Promise<void> {
|
|
30
|
-
// await this.loadDegenDistributors();
|
|
31
|
-
// }
|
|
32
|
-
async syncState() {
|
|
33
|
-
await this.load();
|
|
34
|
-
}
|
|
35
|
-
async load(force) {
|
|
36
|
-
if (!force && this.loaded) {
|
|
37
|
-
return this.state;
|
|
38
|
-
}
|
|
39
|
-
const configurators = Object.values(
|
|
40
|
-
this.sdk.marketRegister.markets.reduce((acc, market) => {
|
|
41
|
-
const cfgLC = market.configurator.address.toLowerCase();
|
|
42
|
-
acc[cfgLC] = market.configurator;
|
|
43
|
-
return acc;
|
|
44
|
-
}, {})
|
|
45
|
-
);
|
|
46
|
-
this.sdk.logger?.debug(
|
|
47
|
-
`loading degen distributors for ${this.sdk.provider.networkType}`
|
|
48
|
-
);
|
|
49
|
-
const distributors = await Promise.allSettled(
|
|
50
|
-
configurators.map((cfg) => cfg.getPeripheryContract("DEGEN_DISTRIBUTOR"))
|
|
51
|
-
);
|
|
52
|
-
const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
|
|
53
|
-
const cfgLC = cfg.address.toLowerCase();
|
|
54
|
-
acc[cfgLC] = distributors[index];
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
this.sdk.marketRegister.markets.forEach((m) => {
|
|
58
|
-
const pool = m.pool.pool.address;
|
|
59
|
-
const cfg = m.configurator.address;
|
|
60
|
-
const cfgLC = cfg.toLowerCase();
|
|
61
|
-
const r = distributorByConfigurator?.[cfgLC];
|
|
62
|
-
if (!this.#distributors) {
|
|
63
|
-
this.#distributors = new import_sdk.AddressMap(void 0, MAP_LABEL);
|
|
64
|
-
}
|
|
65
|
-
if (r.status === "fulfilled") {
|
|
66
|
-
this.#distributors.upsert(pool, r.value);
|
|
67
|
-
} else {
|
|
68
|
-
this.sdk.logger?.error(
|
|
69
|
-
`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.reason}`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return this.state;
|
|
74
|
-
}
|
|
75
|
-
get loaded() {
|
|
76
|
-
return !!this.#distributors;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns a map of pool addresses to degen distributor addresses
|
|
80
|
-
* @throws if degen distributor plugin is not attached
|
|
81
|
-
*/
|
|
82
|
-
get distributors() {
|
|
83
|
-
if (!this.#distributors) {
|
|
84
|
-
throw new Error("degen distributor plugin not attached");
|
|
85
|
-
}
|
|
86
|
-
return this.#distributors;
|
|
87
|
-
}
|
|
88
|
-
stateHuman(_) {
|
|
89
|
-
return this.distributors.entries().flatMap(([pool, distributor]) => ({
|
|
90
|
-
address: distributor,
|
|
91
|
-
version: this.version,
|
|
92
|
-
pool
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
get state() {
|
|
96
|
-
return {
|
|
97
|
-
distributors: this.distributors.asRecord()
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
hydrate(state) {
|
|
101
|
-
this.#distributors = new import_sdk.AddressMap(
|
|
102
|
-
Object.entries(state.distributors),
|
|
103
|
-
MAP_LABEL
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
-
0 && (module.exports = {
|
|
109
|
-
DegenDistributorsPlugin
|
|
110
|
-
});
|
|
@@ -1,24 +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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var degenDistributors_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(degenDistributors_exports);
|
|
18
|
-
__reExport(degenDistributors_exports, require("./DegenDistributorsPlugin.js"), module.exports);
|
|
19
|
-
__reExport(degenDistributors_exports, require("./types.js"), module.exports);
|
|
20
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
-
0 && (module.exports = {
|
|
22
|
-
...require("./DegenDistributorsPlugin.js"),
|
|
23
|
-
...require("./types.js")
|
|
24
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1,16 +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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
|
@@ -1,116 +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_compressors = require("../abi/compressors.js");
|
|
25
|
-
var import_sdk = require("../sdk/index.js");
|
|
26
|
-
const MAP_LABEL = "pools7DAgo";
|
|
27
|
-
class Pools7DAgoPlugin extends import_sdk.SDKConstruct {
|
|
28
|
-
#pools7DAgo;
|
|
29
|
-
version = 1;
|
|
30
|
-
// public async attach(): Promise<void> {
|
|
31
|
-
// await this.loadPools7DAgo();
|
|
32
|
-
// }
|
|
33
|
-
async syncState() {
|
|
34
|
-
await this.load();
|
|
35
|
-
}
|
|
36
|
-
async load(force) {
|
|
37
|
-
if (!force && this.loaded) {
|
|
38
|
-
return this.state;
|
|
39
|
-
}
|
|
40
|
-
const targetBlock = this.sdk.currentBlock - import_sdk.BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.provider.networkType];
|
|
41
|
-
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
42
|
-
import_sdk.AP_MARKET_COMPRESSOR,
|
|
43
|
-
import_sdk.VERSION_RANGE_310
|
|
44
|
-
);
|
|
45
|
-
this.sdk.logger?.debug(
|
|
46
|
-
`loading pools 7d ago with market compressor ${marketCompressorAddress}`
|
|
47
|
-
);
|
|
48
|
-
const markets = this.sdk.marketRegister.markets;
|
|
49
|
-
const resp = await this.provider.publicClient.multicall({
|
|
50
|
-
allowFailure: true,
|
|
51
|
-
contracts: markets.map(
|
|
52
|
-
(m) => ({
|
|
53
|
-
address: marketCompressorAddress,
|
|
54
|
-
abi: import_compressors.iMarketCompressorAbi,
|
|
55
|
-
functionName: "getPoolState",
|
|
56
|
-
args: [m.pool.pool.address]
|
|
57
|
-
})
|
|
58
|
-
),
|
|
59
|
-
blockNumber: import_sdk.BigIntMath.max(0n, targetBlock)
|
|
60
|
-
});
|
|
61
|
-
resp.forEach((r, index) => {
|
|
62
|
-
const m = markets[index];
|
|
63
|
-
const cfg = m.configurator.address;
|
|
64
|
-
const pool = m.pool.pool.address;
|
|
65
|
-
if (!this.#pools7DAgo) {
|
|
66
|
-
this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
|
|
67
|
-
}
|
|
68
|
-
if (r.status === "success") {
|
|
69
|
-
this.#pools7DAgo.upsert(m.pool.pool.address, {
|
|
70
|
-
dieselRate: r.result.dieselRate,
|
|
71
|
-
pool
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
this.sdk.logger?.error(
|
|
75
|
-
`failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return this.state;
|
|
80
|
-
}
|
|
81
|
-
get loaded() {
|
|
82
|
-
return !!this.#pools7DAgo;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Returns a map of pool addresses to minified pool 7d ago state
|
|
86
|
-
* @throws if pool 7d ago plugin is not attached
|
|
87
|
-
*/
|
|
88
|
-
get pools7DAgo() {
|
|
89
|
-
if (!this.#pools7DAgo) {
|
|
90
|
-
throw new Error("pools 7d ago plugin not attached");
|
|
91
|
-
}
|
|
92
|
-
return this.#pools7DAgo;
|
|
93
|
-
}
|
|
94
|
-
stateHuman(_) {
|
|
95
|
-
return this.pools7DAgo.values().flatMap((p) => ({
|
|
96
|
-
address: p.pool,
|
|
97
|
-
version: this.version,
|
|
98
|
-
dieselRate: p.dieselRate
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
get state() {
|
|
102
|
-
return {
|
|
103
|
-
pools7DAgo: this.pools7DAgo.asRecord()
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
hydrate(state) {
|
|
107
|
-
this.#pools7DAgo = new import_sdk.AddressMap(
|
|
108
|
-
Object.entries(state.pools7DAgo),
|
|
109
|
-
MAP_LABEL
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
-
0 && (module.exports = {
|
|
115
|
-
Pools7DAgoPlugin
|
|
116
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { AddressMap, SDKConstruct } from "../sdk/index.js";
|
|
2
|
-
const MAP_LABEL = "degenDistributors";
|
|
3
|
-
class DegenDistributorsPlugin extends SDKConstruct {
|
|
4
|
-
#distributors;
|
|
5
|
-
version = 1;
|
|
6
|
-
// public async attach(): Promise<void> {
|
|
7
|
-
// await this.loadDegenDistributors();
|
|
8
|
-
// }
|
|
9
|
-
async syncState() {
|
|
10
|
-
await this.load();
|
|
11
|
-
}
|
|
12
|
-
async load(force) {
|
|
13
|
-
if (!force && this.loaded) {
|
|
14
|
-
return this.state;
|
|
15
|
-
}
|
|
16
|
-
const configurators = Object.values(
|
|
17
|
-
this.sdk.marketRegister.markets.reduce((acc, market) => {
|
|
18
|
-
const cfgLC = market.configurator.address.toLowerCase();
|
|
19
|
-
acc[cfgLC] = market.configurator;
|
|
20
|
-
return acc;
|
|
21
|
-
}, {})
|
|
22
|
-
);
|
|
23
|
-
this.sdk.logger?.debug(
|
|
24
|
-
`loading degen distributors for ${this.sdk.provider.networkType}`
|
|
25
|
-
);
|
|
26
|
-
const distributors = await Promise.allSettled(
|
|
27
|
-
configurators.map((cfg) => cfg.getPeripheryContract("DEGEN_DISTRIBUTOR"))
|
|
28
|
-
);
|
|
29
|
-
const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
|
|
30
|
-
const cfgLC = cfg.address.toLowerCase();
|
|
31
|
-
acc[cfgLC] = distributors[index];
|
|
32
|
-
return acc;
|
|
33
|
-
}, {});
|
|
34
|
-
this.sdk.marketRegister.markets.forEach((m) => {
|
|
35
|
-
const pool = m.pool.pool.address;
|
|
36
|
-
const cfg = m.configurator.address;
|
|
37
|
-
const cfgLC = cfg.toLowerCase();
|
|
38
|
-
const r = distributorByConfigurator?.[cfgLC];
|
|
39
|
-
if (!this.#distributors) {
|
|
40
|
-
this.#distributors = new AddressMap(void 0, MAP_LABEL);
|
|
41
|
-
}
|
|
42
|
-
if (r.status === "fulfilled") {
|
|
43
|
-
this.#distributors.upsert(pool, r.value);
|
|
44
|
-
} else {
|
|
45
|
-
this.sdk.logger?.error(
|
|
46
|
-
`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.reason}`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return this.state;
|
|
51
|
-
}
|
|
52
|
-
get loaded() {
|
|
53
|
-
return !!this.#distributors;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns a map of pool addresses to degen distributor addresses
|
|
57
|
-
* @throws if degen distributor plugin is not attached
|
|
58
|
-
*/
|
|
59
|
-
get distributors() {
|
|
60
|
-
if (!this.#distributors) {
|
|
61
|
-
throw new Error("degen distributor plugin not attached");
|
|
62
|
-
}
|
|
63
|
-
return this.#distributors;
|
|
64
|
-
}
|
|
65
|
-
stateHuman(_) {
|
|
66
|
-
return this.distributors.entries().flatMap(([pool, distributor]) => ({
|
|
67
|
-
address: distributor,
|
|
68
|
-
version: this.version,
|
|
69
|
-
pool
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
get state() {
|
|
73
|
-
return {
|
|
74
|
-
distributors: this.distributors.asRecord()
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
hydrate(state) {
|
|
78
|
-
this.#distributors = new AddressMap(
|
|
79
|
-
Object.entries(state.distributors),
|
|
80
|
-
MAP_LABEL
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export {
|
|
85
|
-
DegenDistributorsPlugin
|
|
86
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "module","sideEffects":false}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { iMarketCompressorAbi } from "../abi/compressors.js";
|
|
2
|
-
import {
|
|
3
|
-
AddressMap,
|
|
4
|
-
AP_MARKET_COMPRESSOR,
|
|
5
|
-
BigIntMath,
|
|
6
|
-
BLOCKS_PER_WEEK_BY_NETWORK,
|
|
7
|
-
SDKConstruct,
|
|
8
|
-
VERSION_RANGE_310
|
|
9
|
-
} from "../sdk/index.js";
|
|
10
|
-
const MAP_LABEL = "pools7DAgo";
|
|
11
|
-
class Pools7DAgoPlugin extends SDKConstruct {
|
|
12
|
-
#pools7DAgo;
|
|
13
|
-
version = 1;
|
|
14
|
-
// public async attach(): Promise<void> {
|
|
15
|
-
// await this.loadPools7DAgo();
|
|
16
|
-
// }
|
|
17
|
-
async syncState() {
|
|
18
|
-
await this.load();
|
|
19
|
-
}
|
|
20
|
-
async load(force) {
|
|
21
|
-
if (!force && this.loaded) {
|
|
22
|
-
return this.state;
|
|
23
|
-
}
|
|
24
|
-
const targetBlock = this.sdk.currentBlock - BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.provider.networkType];
|
|
25
|
-
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
26
|
-
AP_MARKET_COMPRESSOR,
|
|
27
|
-
VERSION_RANGE_310
|
|
28
|
-
);
|
|
29
|
-
this.sdk.logger?.debug(
|
|
30
|
-
`loading pools 7d ago with market compressor ${marketCompressorAddress}`
|
|
31
|
-
);
|
|
32
|
-
const markets = this.sdk.marketRegister.markets;
|
|
33
|
-
const resp = await this.provider.publicClient.multicall({
|
|
34
|
-
allowFailure: true,
|
|
35
|
-
contracts: markets.map(
|
|
36
|
-
(m) => ({
|
|
37
|
-
address: marketCompressorAddress,
|
|
38
|
-
abi: iMarketCompressorAbi,
|
|
39
|
-
functionName: "getPoolState",
|
|
40
|
-
args: [m.pool.pool.address]
|
|
41
|
-
})
|
|
42
|
-
),
|
|
43
|
-
blockNumber: BigIntMath.max(0n, targetBlock)
|
|
44
|
-
});
|
|
45
|
-
resp.forEach((r, index) => {
|
|
46
|
-
const m = markets[index];
|
|
47
|
-
const cfg = m.configurator.address;
|
|
48
|
-
const pool = m.pool.pool.address;
|
|
49
|
-
if (!this.#pools7DAgo) {
|
|
50
|
-
this.#pools7DAgo = new AddressMap(void 0, MAP_LABEL);
|
|
51
|
-
}
|
|
52
|
-
if (r.status === "success") {
|
|
53
|
-
this.#pools7DAgo.upsert(m.pool.pool.address, {
|
|
54
|
-
dieselRate: r.result.dieselRate,
|
|
55
|
-
pool
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
this.sdk.logger?.error(
|
|
59
|
-
`failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return this.state;
|
|
64
|
-
}
|
|
65
|
-
get loaded() {
|
|
66
|
-
return !!this.#pools7DAgo;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Returns a map of pool addresses to minified pool 7d ago state
|
|
70
|
-
* @throws if pool 7d ago plugin is not attached
|
|
71
|
-
*/
|
|
72
|
-
get pools7DAgo() {
|
|
73
|
-
if (!this.#pools7DAgo) {
|
|
74
|
-
throw new Error("pools 7d ago plugin not attached");
|
|
75
|
-
}
|
|
76
|
-
return this.#pools7DAgo;
|
|
77
|
-
}
|
|
78
|
-
stateHuman(_) {
|
|
79
|
-
return this.pools7DAgo.values().flatMap((p) => ({
|
|
80
|
-
address: p.pool,
|
|
81
|
-
version: this.version,
|
|
82
|
-
dieselRate: p.dieselRate
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
get state() {
|
|
86
|
-
return {
|
|
87
|
-
pools7DAgo: this.pools7DAgo.asRecord()
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
hydrate(state) {
|
|
91
|
-
this.#pools7DAgo = new AddressMap(
|
|
92
|
-
Object.entries(state.pools7DAgo),
|
|
93
|
-
MAP_LABEL
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
Pools7DAgoPlugin
|
|
99
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "module","sideEffects":false}
|
|
File without changes
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { IGearboxSDKPlugin } from "../sdk/index.js";
|
|
3
|
-
import { AddressMap, SDKConstruct } from "../sdk/index.js";
|
|
4
|
-
import type { DegenDistributorsStateHuman } from "./types.js";
|
|
5
|
-
export interface DegenDistributorsPluginState {
|
|
6
|
-
distributors: Record<Address, Address>;
|
|
7
|
-
}
|
|
8
|
-
export declare class DegenDistributorsPlugin extends SDKConstruct implements IGearboxSDKPlugin<DegenDistributorsPluginState> {
|
|
9
|
-
#private;
|
|
10
|
-
readonly version = 1;
|
|
11
|
-
syncState(): Promise<void>;
|
|
12
|
-
load(force?: boolean): Promise<DegenDistributorsPluginState>;
|
|
13
|
-
get loaded(): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Returns a map of pool addresses to degen distributor addresses
|
|
16
|
-
* @throws if degen distributor plugin is not attached
|
|
17
|
-
*/
|
|
18
|
-
get distributors(): AddressMap<Address>;
|
|
19
|
-
stateHuman(_?: boolean): DegenDistributorsStateHuman[];
|
|
20
|
-
get state(): DegenDistributorsPluginState;
|
|
21
|
-
hydrate(state: DegenDistributorsPluginState): void;
|
|
22
|
-
}
|