@gearbox-protocol/sdk 3.0.0-draft.7 → 3.0.0-draft.9
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/lib/apy/index.d.ts +2 -2
- package/lib/apy/index.js +2 -0
- package/lib/core/creditSession.d.ts +0 -4
- package/lib/core/creditSession.js +0 -12
- package/lib/core/endpoint.js +2 -1
- package/lib/core/protocols.d.ts +1 -1
- package/lib/core/protocols.js +4 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/redstone/api.js +3 -3
- package/lib/utils/formatter.d.ts +0 -1
- package/lib/utils/formatter.js +1 -6
- package/package.json +7 -5
- package/lib/core/events.d.ts +0 -562
- package/lib/core/events.js +0 -896
package/lib/apy/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
type ExtraFarmTokens = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH" | "LBTC" | "Re7LRT" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "eBTC" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "pumpBTC" | "PT_sUSDe_27MAR2025" | "DVstETH" | "beraSTONE" | "PT_sUSDe_29MAY2025" | "tETH" | "PT_beraSTONE_10APR2025" | "stS" | "csUSDL">;
|
|
3
|
-
type ExtraTokensWithAPY = Extract<ExtraFarmTokens, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH" | "pzETH" | "ezETH" | "Re7LRT" | "rsETH" | "weETH" | "rswETH" | "rstETH" | "steakLRT" | "amphrETH" | "pufETH" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "PT_sUSDe_27MAR2025" | "DVstETH" | "PT_sUSDe_29MAY2025" | "tETH" | "PT_beraSTONE_10APR2025" | "stS" | "csUSDL">;
|
|
2
|
+
type ExtraFarmTokens = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH" | "pzETH" | "rstETH" | "steakLRT" | "amphrETH" | "LBTC" | "Re7LRT" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "eBTC" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "pumpBTC" | "PT_sUSDe_27MAR2025" | "DVstETH" | "beraSTONE" | "PT_sUSDe_29MAY2025" | "tETH" | "PT_beraSTONE_10APR2025" | "stS" | "csUSDL" | "scUSD">;
|
|
3
|
+
type ExtraTokensWithAPY = Extract<ExtraFarmTokens, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH" | "pzETH" | "ezETH" | "Re7LRT" | "rsETH" | "weETH" | "rswETH" | "rstETH" | "steakLRT" | "amphrETH" | "pufETH" | "PT_ezETH_26DEC2024" | "PT_eETH_26DEC2024" | "PT_sUSDe_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_corn_pumpBTC_26DEC2024" | "PT_sUSDe_27MAR2025" | "DVstETH" | "PT_sUSDe_29MAY2025" | "tETH" | "PT_beraSTONE_10APR2025" | "stS" | "csUSDL" | "scUSD">;
|
|
4
4
|
type LRTAndLSTTokens = Exclude<ExtraFarmTokens, "USDe">;
|
|
5
5
|
export declare const isExtraFarmToken: (t: unknown) => t is ExtraFarmTokens;
|
|
6
6
|
export declare const isLRT_LSTToken: (t: unknown) => t is LRTAndLSTTokens;
|
package/lib/apy/index.js
CHANGED
|
@@ -39,6 +39,7 @@ const EXTRA_FARM_TOKENS = {
|
|
|
39
39
|
PT_beraSTONE_10APR2025: true,
|
|
40
40
|
stS: true,
|
|
41
41
|
csUSDL: true,
|
|
42
|
+
scUSD: true,
|
|
42
43
|
};
|
|
43
44
|
const isExtraFarmToken = (t) => {
|
|
44
45
|
if (typeof t !== "string")
|
|
@@ -78,6 +79,7 @@ const EXTRA_TOKENS_WITH_APY = {
|
|
|
78
79
|
PT_beraSTONE_10APR2025: true,
|
|
79
80
|
stS: true,
|
|
80
81
|
csUSDL: true,
|
|
82
|
+
scUSD: true,
|
|
81
83
|
};
|
|
82
84
|
const isExtraTokenWithAPY = (t) => {
|
|
83
85
|
if (typeof t !== "string")
|
|
@@ -24,9 +24,7 @@ export declare class CreditSession {
|
|
|
24
24
|
readonly underlyingToken: Address;
|
|
25
25
|
readonly version: number;
|
|
26
26
|
readonly since: number;
|
|
27
|
-
readonly sinceDate: string;
|
|
28
27
|
readonly closedAt: number;
|
|
29
|
-
readonly closedAtDate: string;
|
|
30
28
|
readonly initialAmount: bigint;
|
|
31
29
|
readonly borrowedAmount: bigint;
|
|
32
30
|
readonly totalValue: bigint;
|
|
@@ -74,9 +72,7 @@ export declare class CreditSessionFiltered {
|
|
|
74
72
|
readonly underlyingToken: Address;
|
|
75
73
|
readonly status: CreditSessionStatus;
|
|
76
74
|
readonly since: number;
|
|
77
|
-
readonly sinceDate: string;
|
|
78
75
|
readonly closedAt: number;
|
|
79
|
-
readonly closedAtDate: string;
|
|
80
76
|
readonly sinceTimestamp: number;
|
|
81
77
|
readonly closedAtTimestamp: number;
|
|
82
78
|
readonly healthFactor: number;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.UserCreditSessionsBuilder = exports.CreditSessionFiltered = exports.CreditSession = exports.CREDIT_SESSION_ID_BY_STATUS = exports.CREDIT_SESSION_STATUS_BY_ID = void 0;
|
|
7
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
8
|
-
const moment_1 = __importDefault(require("moment"));
|
|
9
5
|
exports.CREDIT_SESSION_STATUS_BY_ID = {
|
|
10
6
|
0: "active",
|
|
11
7
|
1: "closed",
|
|
@@ -24,9 +20,7 @@ class CreditSession {
|
|
|
24
20
|
underlyingToken;
|
|
25
21
|
version;
|
|
26
22
|
since;
|
|
27
|
-
sinceDate;
|
|
28
23
|
closedAt;
|
|
29
|
-
closedAtDate;
|
|
30
24
|
initialAmount;
|
|
31
25
|
borrowedAmount;
|
|
32
26
|
totalValue;
|
|
@@ -79,8 +73,6 @@ class CreditSession {
|
|
|
79
73
|
this.healthFactor = Number((0, sdk_gov_1.toBigInt)(payload.healthFactor || 0));
|
|
80
74
|
this.since = payload.since || 0;
|
|
81
75
|
this.closedAt = payload.closedAt || 0;
|
|
82
|
-
this.sinceDate = (0, moment_1.default)((payload.sinceTimestamp || 0) * 1000).format("Do MMM YYYY");
|
|
83
|
-
this.closedAtDate = (0, moment_1.default)((payload.closedAtTimestamp || 0) * 1000).format("Do MMM YYYY");
|
|
84
76
|
this.sinceTimestamp = payload.sinceTimestamp || 0;
|
|
85
77
|
this.closedAtTimestamp = payload.closedAtTimestamp || 0;
|
|
86
78
|
this.profitInUSD = payload.profitInUSD || 0;
|
|
@@ -149,9 +141,7 @@ class CreditSessionFiltered {
|
|
|
149
141
|
underlyingToken;
|
|
150
142
|
status;
|
|
151
143
|
since;
|
|
152
|
-
sinceDate;
|
|
153
144
|
closedAt;
|
|
154
|
-
closedAtDate;
|
|
155
145
|
sinceTimestamp;
|
|
156
146
|
closedAtTimestamp;
|
|
157
147
|
healthFactor;
|
|
@@ -175,8 +165,6 @@ class CreditSessionFiltered {
|
|
|
175
165
|
this.status = exports.CREDIT_SESSION_STATUS_BY_ID[payload.status || 0];
|
|
176
166
|
this.since = payload.since || 0;
|
|
177
167
|
this.closedAt = payload.closedAt || 0;
|
|
178
|
-
this.sinceDate = (0, moment_1.default)((payload.since || 0) * 1000).format("Do MMM YYYY");
|
|
179
|
-
this.closedAtDate = (0, moment_1.default)((payload.closedAt || 0) * 1000).format("Do MMM YYYY");
|
|
180
168
|
this.sinceTimestamp = payload.sinceTimestamp || 0;
|
|
181
169
|
this.closedAtTimestamp = payload.closedAtTimestamp || 0;
|
|
182
170
|
this.healthFactor = Number((0, sdk_gov_1.toBigInt)(payload.healthFactor || 0));
|
package/lib/core/endpoint.js
CHANGED
|
@@ -32,7 +32,8 @@ const LEADERBOARD_APIS = {
|
|
|
32
32
|
[exports.TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation/gpointbot",
|
|
33
33
|
[exports.TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation/gpointbot",
|
|
34
34
|
[exports.TESTNET_CHAINS.Arbitrum]: "https://testnet.gearbox.foundation/gpointbot",
|
|
35
|
-
|
|
35
|
+
[exports.TESTNET_CHAINS.Base]: "https://testnet.gearbox.foundation/gpointbot",
|
|
36
|
+
[exports.TESTNET_CHAINS.Sonic]: "https://testnet.gearbox.foundation/gpointbot",
|
|
36
37
|
};
|
|
37
38
|
const REFERRAL_API = "https://referral-gen.fly.dev/generate";
|
|
38
39
|
class GearboxBackendApi {
|
package/lib/core/protocols.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ interface ProtocolData {
|
|
|
3
3
|
name: string;
|
|
4
4
|
icon: string;
|
|
5
5
|
}
|
|
6
|
-
export type ExtendedProtocols = keyof typeof Protocols | "Stakewise" | "Etherfi" | "Rocketpool" | "Renzo" | "Coinbase" | "Kelp" | "Swell" | "Puffer" | "Mellow" | "Lombard" | "pumpBTC" | "Stakestone" | "Treehouse" | "Coinshift";
|
|
6
|
+
export type ExtendedProtocols = keyof typeof Protocols | "Stakewise" | "Etherfi" | "Rocketpool" | "Renzo" | "Coinbase" | "Kelp" | "Swell" | "Puffer" | "Mellow" | "Lombard" | "pumpBTC" | "Stakestone" | "Treehouse" | "Coinshift" | "Rings";
|
|
7
7
|
export declare const isExtendedProtocol: (t: unknown) => t is ExtendedProtocols;
|
|
8
8
|
export declare function getProtocolData(t: string): ProtocolData;
|
|
9
9
|
export {};
|
package/lib/core/protocols.js
CHANGED
|
@@ -166,6 +166,10 @@ const PROTOCOL_DATA = {
|
|
|
166
166
|
name: "coinshift",
|
|
167
167
|
icon: "/protocols/coinshift.svg",
|
|
168
168
|
},
|
|
169
|
+
Rings: {
|
|
170
|
+
name: "rings",
|
|
171
|
+
icon: "/protocols/rings.svg",
|
|
172
|
+
},
|
|
169
173
|
};
|
|
170
174
|
const isExtendedProtocol = (t) => typeof t === "string" && !!PROTOCOL_DATA[t];
|
|
171
175
|
exports.isExtendedProtocol = isExtendedProtocol;
|
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from "./core/creditManager";
|
|
|
7
7
|
export * from "./core/creditSession";
|
|
8
8
|
export * from "./core/endpoint";
|
|
9
9
|
export * from "./core/eventOrTx";
|
|
10
|
-
export * from "./core/events";
|
|
11
10
|
export * from "./core/gauge";
|
|
12
11
|
export * from "./core/gaugeMath";
|
|
13
12
|
export * from "./core/pool";
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,6 @@ __exportStar(require("./core/creditManager"), exports);
|
|
|
23
23
|
__exportStar(require("./core/creditSession"), exports);
|
|
24
24
|
__exportStar(require("./core/endpoint"), exports);
|
|
25
25
|
__exportStar(require("./core/eventOrTx"), exports);
|
|
26
|
-
__exportStar(require("./core/events"), exports);
|
|
27
26
|
__exportStar(require("./core/gauge"), exports);
|
|
28
27
|
__exportStar(require("./core/gaugeMath"), exports);
|
|
29
28
|
__exportStar(require("./core/pool"), exports);
|
package/lib/redstone/api.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedstoneApi = exports.REDSTONE_SIGNERS_THRESHOLD = exports.DEFAULT_DATA_SERVICE_ID = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
-
const
|
|
5
|
+
const evm_connector_1 = require("@redstone-finance/evm-connector");
|
|
6
6
|
const redstone_protocol_1 = require("redstone-protocol");
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const types_1 = require("../types");
|
|
@@ -17,7 +17,7 @@ class RedstoneApi {
|
|
|
17
17
|
return pricesOnDemand;
|
|
18
18
|
}
|
|
19
19
|
static getRedstonePayloadForManualUsage = async (dataServiceId, dataFeeds, uniqueSignersCount) => {
|
|
20
|
-
const wrapper = new
|
|
20
|
+
const wrapper = new evm_connector_1.DataServiceWrapper({
|
|
21
21
|
dataServiceId,
|
|
22
22
|
dataPackagesIds: [dataFeeds],
|
|
23
23
|
uniqueSignersCount,
|
|
@@ -74,7 +74,7 @@ class RedstoneApi {
|
|
|
74
74
|
return respRecord;
|
|
75
75
|
}
|
|
76
76
|
static getDataPackages = async (dataServiceId, dataFeeds, uniqueSignersCount) => {
|
|
77
|
-
const wrapper = new
|
|
77
|
+
const wrapper = new evm_connector_1.DataServiceWrapper({
|
|
78
78
|
dataServiceId: dataServiceId,
|
|
79
79
|
dataPackagesIds: dataFeeds,
|
|
80
80
|
uniqueSignersCount: uniqueSignersCount,
|
package/lib/utils/formatter.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export declare function shortHash(address?: string): string;
|
|
|
8
8
|
export declare function formatDate(date: Date): string;
|
|
9
9
|
export declare function formatPercentage(healthFactor: number, decimals?: number): string;
|
|
10
10
|
export declare function formatLeverage(leverage: number, decimals?: number): string;
|
|
11
|
-
export declare function formatDateTime(timestamp: number): string;
|
package/lib/utils/formatter.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.formatLeverage = exports.formatPercentage = exports.formatDate = exports.shortHash = exports.shortAddress = exports.toBN = exports.toSignificant = exports.formatRAY = exports.rayToNumber = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const decimal_js_light_1 = require("decimal.js-light");
|
|
6
|
-
const moment_1 = require("moment");
|
|
7
6
|
function rayToNumber(num) {
|
|
8
7
|
return Number((0, sdk_gov_1.toBigInt)(num) / 10n ** 21n) / 1000000;
|
|
9
8
|
}
|
|
@@ -58,7 +57,3 @@ function formatLeverage(leverage, decimals = 2) {
|
|
|
58
57
|
return (leverage / Number(sdk_gov_1.LEVERAGE_DECIMALS)).toFixed(decimals);
|
|
59
58
|
}
|
|
60
59
|
exports.formatLeverage = formatLeverage;
|
|
61
|
-
function formatDateTime(timestamp) {
|
|
62
|
-
return `${(0, moment_1.unix)(timestamp).format("Do MMM YYYY HH:mm")} UTC`;
|
|
63
|
-
}
|
|
64
|
-
exports.formatDateTime = formatDateTime;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-draft.
|
|
3
|
+
"version": "3.0.0-draft.9",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"@wagmi/cli": "^2.1.13",
|
|
33
33
|
"axios": "^1.2.6",
|
|
34
34
|
"decimal.js-light": "^2.5.1",
|
|
35
|
-
"deep-eql": "^4.1.0"
|
|
36
|
-
"moment": "^2.29.4"
|
|
35
|
+
"deep-eql": "^4.1.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
38
|
"@1inch/farming": "^3.1.0",
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
"@redstone-finance/evm-connector": "^0.7.3",
|
|
55
54
|
"@types/chai": "^4.3.3",
|
|
56
55
|
"@types/deep-eql": "^4.0.0",
|
|
57
|
-
"@types/jest": "^
|
|
56
|
+
"@types/jest": "^29.5.14",
|
|
58
57
|
"@types/mocha": "^10.0.1",
|
|
59
58
|
"@types/node": "^18.7.6",
|
|
60
59
|
"@types/rimraf": "^3.0.2",
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"dotenv": "^16.0.1",
|
|
63
62
|
"eslint": "^8.46.0",
|
|
64
63
|
"husky": ">=6",
|
|
65
|
-
"jest": "^
|
|
64
|
+
"jest": "^29.7.0",
|
|
66
65
|
"lint-staged": "^13.2.3",
|
|
67
66
|
"mocha": "^10.0.0",
|
|
68
67
|
"prettier": "^2.7.1",
|
|
@@ -80,5 +79,8 @@
|
|
|
80
79
|
"prettier --write"
|
|
81
80
|
],
|
|
82
81
|
"*.{json,md}": "prettier --write"
|
|
82
|
+
},
|
|
83
|
+
"jest": {
|
|
84
|
+
"rootDir": "src"
|
|
83
85
|
}
|
|
84
86
|
}
|