@gearbox-protocol/sdk 3.0.0-next.183 → 3.0.0-next.185
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 +9 -4
- package/lib/apy/index.js +33 -10
- package/lib/core/creditAccount.d.ts +2 -2
- package/lib/core/strategy.d.ts +3 -3
- package/lib/core/transactions.d.ts +12 -1
- package/lib/core/transactions.js +22 -1
- package/package.json +2 -2
package/lib/apy/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export type
|
|
2
|
+
type AdditionalTokensWithAPY = Extract<SupportedToken, "STETH" | "rETH" | "osETH" | "cbETH" | "wstETH" | "sfrxETH">;
|
|
3
|
+
type AdditionalLPTokens = Extract<SupportedToken, "weETH" | "ezETH" | "sfrxETH" | "USDe" | "rsETH" | "rswETH" | "pufETH">;
|
|
4
|
+
export declare const isAdditionalLPToken: (t: unknown) => t is AdditionalLPTokens;
|
|
5
|
+
export type TokensWithAPY = LPTokens | AdditionalTokensWithAPY;
|
|
6
|
+
export type TokensWithApyRecord = PartialRecord<TokensWithAPY, number>;
|
|
7
|
+
export declare const isAdditionalTokenWithAPY: (t: unknown) => t is AdditionalTokensWithAPY;
|
|
8
|
+
export declare const isExtraFarmToken: (t: unknown) => boolean;
|
|
6
9
|
export declare const isTokenWithAPY: (t: unknown) => t is TokensWithAPY;
|
|
10
|
+
export type AllLPTokens = LPTokens | AdditionalLPTokens | AdditionalTokensWithAPY;
|
|
11
|
+
export declare const isFarmToken: (t: unknown) => t is AllLPTokens;
|
|
7
12
|
export * from "./convexAPY";
|
|
8
13
|
export * from "./curveAPY";
|
|
9
14
|
export * from "./defiLamaAPY";
|
package/lib/apy/index.js
CHANGED
|
@@ -14,26 +14,49 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isTokenWithAPY = exports.
|
|
17
|
+
exports.isFarmToken = exports.isTokenWithAPY = exports.isExtraFarmToken = exports.isAdditionalTokenWithAPY = exports.isAdditionalLPToken = void 0;
|
|
18
18
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
19
|
-
|
|
20
|
-
STETH: true,
|
|
19
|
+
const ADDITIONAL_LP_TOKENS = {
|
|
21
20
|
weETH: true,
|
|
22
|
-
osETH: true,
|
|
23
|
-
rETH: true,
|
|
24
|
-
wstETH: true,
|
|
25
21
|
ezETH: true,
|
|
26
|
-
cbETH: true,
|
|
27
22
|
sfrxETH: true,
|
|
28
23
|
USDe: true,
|
|
29
24
|
rsETH: true,
|
|
30
25
|
rswETH: true,
|
|
31
26
|
pufETH: true,
|
|
32
27
|
};
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const TOKENS_WITH_APY = {
|
|
29
|
+
STETH: true,
|
|
30
|
+
osETH: true,
|
|
31
|
+
rETH: true,
|
|
32
|
+
wstETH: true,
|
|
33
|
+
cbETH: true,
|
|
34
|
+
sfrxETH: true,
|
|
35
|
+
};
|
|
36
|
+
const isAdditionalLPToken = (t) => {
|
|
37
|
+
if (typeof t !== "string")
|
|
38
|
+
return false;
|
|
39
|
+
return !!ADDITIONAL_LP_TOKENS[t];
|
|
40
|
+
};
|
|
41
|
+
exports.isAdditionalLPToken = isAdditionalLPToken;
|
|
42
|
+
const isAdditionalTokenWithAPY = (t) => {
|
|
43
|
+
if (typeof t !== "string")
|
|
44
|
+
return false;
|
|
45
|
+
return !!TOKENS_WITH_APY[t];
|
|
46
|
+
};
|
|
47
|
+
exports.isAdditionalTokenWithAPY = isAdditionalTokenWithAPY;
|
|
48
|
+
const isExtraFarmToken = (t) => (0, exports.isAdditionalLPToken)(t) || (0, exports.isAdditionalTokenWithAPY)(t);
|
|
49
|
+
exports.isExtraFarmToken = isExtraFarmToken;
|
|
50
|
+
const isTokenWithAPY = (t) => {
|
|
51
|
+
if (typeof t !== "string")
|
|
52
|
+
return false;
|
|
53
|
+
return (0, sdk_gov_1.isLPToken)(t) || (0, exports.isAdditionalTokenWithAPY)(t);
|
|
54
|
+
};
|
|
36
55
|
exports.isTokenWithAPY = isTokenWithAPY;
|
|
56
|
+
const isFarmToken = (t) => {
|
|
57
|
+
return (0, sdk_gov_1.isLPToken)(t) || (0, exports.isExtraFarmToken)(t);
|
|
58
|
+
};
|
|
59
|
+
exports.isFarmToken = isFarmToken;
|
|
37
60
|
__exportStar(require("./convexAPY"), exports);
|
|
38
61
|
__exportStar(require("./curveAPY"), exports);
|
|
39
62
|
__exportStar(require("./defiLamaAPY"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokensWithApyRecord } from "../apy";
|
|
2
2
|
import { CaTokenBalance, CreditAccountDataPayload } from "../payload/creditAccount";
|
|
3
3
|
import { QuotaInfo } from "../payload/creditManager";
|
|
4
4
|
import { TokenData } from "../tokens/tokenData";
|
|
@@ -7,7 +7,7 @@ export declare const MIN_INT96 = -39614081257132168796771975168n;
|
|
|
7
7
|
export declare const MAX_UINT256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
|
|
8
8
|
export interface CalcOverallAPYProps {
|
|
9
9
|
caAssets: Array<Asset>;
|
|
10
|
-
lpAPY:
|
|
10
|
+
lpAPY: TokensWithApyRecord | undefined;
|
|
11
11
|
quotas: Record<string, Asset>;
|
|
12
12
|
quotaRates: Record<string, Pick<QuotaInfo, "isActive" | "rate">>;
|
|
13
13
|
feeInterest: number;
|
package/lib/core/strategy.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
import {
|
|
2
|
+
import { AllLPTokens } from "../apy";
|
|
3
3
|
import { CreditManagerData } from "./creditManager";
|
|
4
4
|
export interface StrategyPayload {
|
|
5
5
|
name: string;
|
|
6
|
-
lpTokenSymbol:
|
|
6
|
+
lpTokenSymbol: AllLPTokens;
|
|
7
7
|
protocolSymbol: string;
|
|
8
8
|
creditManagers: Array<string>;
|
|
9
9
|
collateralTokens: Array<SupportedToken>;
|
|
@@ -17,7 +17,7 @@ interface CalculateMaxAPYProps {
|
|
|
17
17
|
}
|
|
18
18
|
export declare class Strategy {
|
|
19
19
|
readonly name: string;
|
|
20
|
-
readonly lpTokenSymbol:
|
|
20
|
+
readonly lpTokenSymbol: AllLPTokens;
|
|
21
21
|
readonly protocolSymbol: string;
|
|
22
22
|
readonly collateralTokens: Array<SupportedToken>;
|
|
23
23
|
readonly liquidationTokens: Array<SupportedToken>;
|
|
@@ -10,7 +10,7 @@ interface PoolEvent {
|
|
|
10
10
|
readonly poolName?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface TxSerialized {
|
|
13
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot";
|
|
13
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot" | "TxLiquidateAccount";
|
|
14
14
|
content: string;
|
|
15
15
|
}
|
|
16
16
|
export declare class TxSerializer {
|
|
@@ -184,6 +184,17 @@ export declare class TxRepayAccount extends EVMTx implements CMEvent {
|
|
|
184
184
|
toString(): string;
|
|
185
185
|
serialize(): TxSerialized;
|
|
186
186
|
}
|
|
187
|
+
interface LiquidateAccountProps extends EVMTxProps {
|
|
188
|
+
creditManager: string;
|
|
189
|
+
creditManagerName?: string;
|
|
190
|
+
}
|
|
191
|
+
export declare class TxLiquidateAccount extends EVMTx implements CMEvent {
|
|
192
|
+
readonly creditManager: string;
|
|
193
|
+
readonly creditManagerName?: string;
|
|
194
|
+
constructor(opts: LiquidateAccountProps);
|
|
195
|
+
toString(): string;
|
|
196
|
+
serialize(): TxSerialized;
|
|
197
|
+
}
|
|
187
198
|
interface CloseAccountProps extends EVMTxProps {
|
|
188
199
|
creditManager: string;
|
|
189
200
|
creditManagerName?: string;
|
package/lib/core/transactions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TxRemoveBot = exports.TxAddBot = exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
3
|
+
exports.TxRemoveBot = exports.TxAddBot = exports.TxWithdrawCollateral = exports.TxGaugeVote = exports.TxGaugeClaim = exports.TxGaugeUnstake = exports.TxGaugeStake = exports.TxUpdateQuota = exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxLiquidateAccount = exports.TxRepayAccount = exports.TxClaimRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
6
6
|
const math_1 = require("../utils/math");
|
|
@@ -59,6 +59,8 @@ class TxSerializer {
|
|
|
59
59
|
return new TxAddBot(params);
|
|
60
60
|
case "TxRemoveBot":
|
|
61
61
|
return new TxRemoveBot(params);
|
|
62
|
+
case "TxLiquidateAccount":
|
|
63
|
+
return new TxLiquidateAccount(params);
|
|
62
64
|
default:
|
|
63
65
|
throw new Error(`Unknown transaction for parsing: ${e.type}`);
|
|
64
66
|
}
|
|
@@ -356,6 +358,25 @@ class TxRepayAccount extends eventOrTx_1.EVMTx {
|
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
360
|
exports.TxRepayAccount = TxRepayAccount;
|
|
361
|
+
class TxLiquidateAccount extends eventOrTx_1.EVMTx {
|
|
362
|
+
creditManager;
|
|
363
|
+
creditManagerName;
|
|
364
|
+
constructor(opts) {
|
|
365
|
+
super(opts);
|
|
366
|
+
this.creditManager = opts.creditManager;
|
|
367
|
+
this.creditManagerName = opts.creditManagerName;
|
|
368
|
+
}
|
|
369
|
+
toString() {
|
|
370
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: Liquidated`;
|
|
371
|
+
}
|
|
372
|
+
serialize() {
|
|
373
|
+
return {
|
|
374
|
+
type: "TxLiquidateAccount",
|
|
375
|
+
content: JSON.stringify(this),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
exports.TxLiquidateAccount = TxLiquidateAccount;
|
|
359
380
|
class TxCloseAccount extends eventOrTx_1.EVMTx {
|
|
360
381
|
creditManager;
|
|
361
382
|
creditManagerName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.185",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@gearbox-protocol/bots-v3": "^1.5.1",
|
|
34
|
-
"@gearbox-protocol/sdk-gov": "^2.
|
|
34
|
+
"@gearbox-protocol/sdk-gov": "^2.2.5",
|
|
35
35
|
"axios": "^1.2.6",
|
|
36
36
|
"decimal.js-light": "^2.5.1",
|
|
37
37
|
"deep-eql": "^4.1.0",
|