@gearbox-protocol/sdk 3.0.0-next.10 → 3.0.0-next.11
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/yearnAPY.js +1 -1
- package/lib/core/creditManager.d.ts +2 -0
- package/lib/core/creditManager.js +10 -1
- package/lib/parsers/creditFacadeParser.d.ts +2 -1
- package/lib/parsers/creditFacadeParser.js +15 -3
- package/lib/parsers/creditFacadeParser.spec.js +1 -1
- package/lib/parsers/txParser.d.ts +1 -1
- package/lib/parsers/txParser.js +2 -2
- package/package.json +1 -1
package/lib/apy/yearnAPY.js
CHANGED
|
@@ -8,7 +8,7 @@ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const formatter_1 = require("../utils/formatter");
|
|
10
10
|
const RESPONSE_DECIMALS = 1;
|
|
11
|
-
const URL = "https://api.
|
|
11
|
+
const URL = "https://api.yexporter.io/v1/chains/1/vaults/all";
|
|
12
12
|
const transformSymbol = (s) => s.replaceAll("_", "-").toLowerCase();
|
|
13
13
|
async function getYearnAPY() {
|
|
14
14
|
try {
|
|
@@ -31,6 +31,7 @@ export declare class CreditManagerData {
|
|
|
31
31
|
readonly quotas: Record<string, QuotaInfo>;
|
|
32
32
|
readonly interestModel: LinearModel;
|
|
33
33
|
constructor(payload: CreditManagerDataPayload);
|
|
34
|
+
isQuoted(token: string): boolean;
|
|
34
35
|
encodeAddCollateralV2(account: string, tokenAddress: string, amount: bigint): MultiCall;
|
|
35
36
|
encodeAddCollateralV3(tokenAddress: string, amount: bigint): MultiCall;
|
|
36
37
|
encodeIncreaseDebtV2(amount: bigint): MultiCall;
|
|
@@ -41,6 +42,7 @@ export declare class CreditManagerData {
|
|
|
41
42
|
encodeEnableTokenV3(token: string): MultiCall;
|
|
42
43
|
encodeDisableTokenV2(token: string): MultiCall;
|
|
43
44
|
encodeDisableTokenV3(token: string): MultiCall;
|
|
45
|
+
encodeUpdateQuotaV3(token: string, quotaChange: bigint, minQuota: bigint): MultiCall;
|
|
44
46
|
static withdrawAllAndUnwrap_Convex(address: string, claim: boolean): MultiCall;
|
|
45
47
|
get id(): string;
|
|
46
48
|
}
|
|
@@ -98,13 +98,16 @@ class CreditManagerData {
|
|
|
98
98
|
};
|
|
99
99
|
txParser_1.TxParser.addCreditManager(this.address, this.version);
|
|
100
100
|
if (this.creditFacade !== "" && this.creditFacade !== sdk_gov_1.ADDRESS_0X0) {
|
|
101
|
-
txParser_1.TxParser.addCreditFacade(this.creditFacade, sdk_gov_1.tokenSymbolByAddress[this.underlyingToken]);
|
|
101
|
+
txParser_1.TxParser.addCreditFacade(this.creditFacade, sdk_gov_1.tokenSymbolByAddress[this.underlyingToken], this.version);
|
|
102
102
|
txParser_1.TxParser.addAdapters(payload.adapters.map(a => ({
|
|
103
103
|
adapter: a.adapter,
|
|
104
104
|
contract: a.targetContract,
|
|
105
105
|
})));
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
isQuoted(token) {
|
|
109
|
+
return !!this.quotas[token];
|
|
110
|
+
}
|
|
108
111
|
encodeAddCollateralV2(account, tokenAddress, amount) {
|
|
109
112
|
return {
|
|
110
113
|
target: this.creditFacade,
|
|
@@ -165,6 +168,12 @@ class CreditManagerData {
|
|
|
165
168
|
callData: types_1.ICreditFacadeV3Multicall__factory.createInterface().encodeFunctionData("disableToken", [token]),
|
|
166
169
|
};
|
|
167
170
|
}
|
|
171
|
+
encodeUpdateQuotaV3(token, quotaChange, minQuota) {
|
|
172
|
+
return {
|
|
173
|
+
target: this.creditFacade,
|
|
174
|
+
callData: types_1.ICreditFacadeV3Multicall__factory.createInterface().encodeFunctionData("updateQuota", [token, quotaChange, minQuota]),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
168
177
|
static withdrawAllAndUnwrap_Convex(address, claim) {
|
|
169
178
|
return {
|
|
170
179
|
target: address,
|
|
@@ -3,7 +3,8 @@ import { BigNumberish } from "ethers";
|
|
|
3
3
|
import { AbstractParser } from "./abstractParser";
|
|
4
4
|
import { IParser } from "./iParser";
|
|
5
5
|
export declare class CreditFacadeParser extends AbstractParser implements IParser {
|
|
6
|
-
|
|
6
|
+
version: number;
|
|
7
|
+
constructor(token: SupportedToken, version: number);
|
|
7
8
|
parse(calldata: string): string;
|
|
8
9
|
formatAmount(amount: BigNumberish): string;
|
|
9
10
|
}
|
|
@@ -4,16 +4,24 @@ exports.CreditFacadeParser = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const abstractParser_1 = require("./abstractParser");
|
|
6
6
|
class CreditFacadeParser extends abstractParser_1.AbstractParser {
|
|
7
|
-
|
|
7
|
+
version;
|
|
8
|
+
constructor(token, version) {
|
|
8
9
|
super(token);
|
|
9
|
-
this.
|
|
10
|
+
this.version = version;
|
|
11
|
+
this.ifc =
|
|
12
|
+
version === 300
|
|
13
|
+
? types_1.ICreditFacadeV3Multicall__factory.createInterface()
|
|
14
|
+
: types_1.ICreditFacadeV2Extended__factory.createInterface();
|
|
10
15
|
this.adapterName = "CreditFacade";
|
|
11
16
|
}
|
|
12
17
|
parse(calldata) {
|
|
13
18
|
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
14
19
|
switch (functionFragment.name) {
|
|
15
20
|
case "addCollateral": {
|
|
16
|
-
const
|
|
21
|
+
const r = this.decodeFunctionData(functionFragment, calldata);
|
|
22
|
+
const onBehalf = this.version === 300 ? "none" : r[0];
|
|
23
|
+
const token = this.version === 300 ? r[0] : r[1];
|
|
24
|
+
const amount = this.version === 300 ? r[1] : r[2];
|
|
17
25
|
return `${functionName}(onBehalf: ${onBehalf}, token: ${this.tokenSymbol(token)}, amount: ${this.formatAmount(amount)})`;
|
|
18
26
|
}
|
|
19
27
|
case "increaseDebt":
|
|
@@ -26,6 +34,10 @@ class CreditFacadeParser extends abstractParser_1.AbstractParser {
|
|
|
26
34
|
const [address] = this.decodeFunctionData(functionFragment, calldata);
|
|
27
35
|
return `${functionName}(token: ${this.tokenSymbol(address)})`;
|
|
28
36
|
}
|
|
37
|
+
case "updateQuota": {
|
|
38
|
+
const [address, quotaUpdate, minQuota] = this.decodeFunctionData(functionFragment, calldata);
|
|
39
|
+
return `${functionName}(token: ${this.tokenSymbol(address)}, quotaUpdate: ${this.formatAmount(quotaUpdate)}, minQuota: ${this.formatAmount(minQuota)})`;
|
|
40
|
+
}
|
|
29
41
|
case "revertIfReceivedLessThan": {
|
|
30
42
|
const [balances] = this.decodeFunctionData(functionFragment, calldata);
|
|
31
43
|
const balancesStr = balances
|
|
@@ -6,7 +6,7 @@ const types_1 = require("../types");
|
|
|
6
6
|
const creditFacadeParser_1 = require("./creditFacadeParser");
|
|
7
7
|
describe("CreditFacadeParser test", () => {
|
|
8
8
|
it("all functions works well", () => {
|
|
9
|
-
let parser = new creditFacadeParser_1.CreditFacadeParser("DAI");
|
|
9
|
+
let parser = new creditFacadeParser_1.CreditFacadeParser("DAI", 1);
|
|
10
10
|
const ifc = types_1.ICreditFacadeV2Extended__factory.createInterface();
|
|
11
11
|
let parsed = parser.parse(ifc.encodeFunctionData("addCollateral", [
|
|
12
12
|
sdk_gov_1.DUMB_ADDRESS,
|
|
@@ -27,7 +27,7 @@ export declare class TxParser {
|
|
|
27
27
|
}[];
|
|
28
28
|
static addAdapters(adapters: Array<AdapterForParser>): void;
|
|
29
29
|
static addContracts(network: NetworkType): void;
|
|
30
|
-
static addCreditFacade(creditFacade: string, underlying: SupportedToken): void;
|
|
30
|
+
static addCreditFacade(creditFacade: string, underlying: SupportedToken, version: number): void;
|
|
31
31
|
static addTokens(network: NetworkType): void;
|
|
32
32
|
static addPriceOracle(address: string): void;
|
|
33
33
|
static addAddressProvider(address: string): void;
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -61,8 +61,8 @@ class TxParser {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
static addCreditFacade(creditFacade, underlying) {
|
|
65
|
-
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying));
|
|
64
|
+
static addCreditFacade(creditFacade, underlying, version) {
|
|
65
|
+
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying, version));
|
|
66
66
|
}
|
|
67
67
|
static addTokens(network) {
|
|
68
68
|
sdk_gov_1.TypedObjectUtils.entries(sdk_gov_1.tokenDataByNetwork[network]).forEach(([s, t]) => {
|