@gearbox-protocol/sdk 2.1.34 → 2.1.36
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/contracts/index.sol +8 -0
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/core/creditManager.d.ts +1 -1
- package/lib/core/creditManager.js +5 -5
- package/lib/parsers/creditFacadeParser.js +2 -2
- package/lib/parsers/creditFacadeParser.spec.js +1 -2
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/BalanceOps.d.ts +27 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/BalanceOps.js +2 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/index.d.ts +1 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/index.js +2 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade.d.ts +147 -80
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents.d.ts +35 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended.d.ts +7 -7
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeV2.d.ts +66 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeV2.js +2 -0
- package/lib/types/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/index.d.ts +1 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/BalanceOps__factory.d.ts +28 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/BalanceOps__factory.js +53 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/index.d.ts +1 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/Balances.sol/index.js +8 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeEvents__factory.js +45 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExceptions__factory.js +10 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +0 -5
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeV2__factory.d.ts +18 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacadeV2__factory.js +42 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/ICreditFacade__factory.js +198 -46
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/index.d.ts +1 -0
- package/lib/types/factories/@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol/index.js +3 -1
- package/package.json +7 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Foundation, 2023.
|
|
4
|
+
|
|
5
|
+
pragma solidity ^0.8.10;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import {ICreditFacadeExtended} from "@gearbox-protocol/core-v2/contracts/interfaces/ICreditFacade.sol";
|
package/lib/apy/yearnAPY.js
CHANGED
|
@@ -10,7 +10,7 @@ const yearn_1 = require("../tokens/yearn");
|
|
|
10
10
|
const formatter_1 = require("../utils/formatter");
|
|
11
11
|
const mappers_1 = require("../utils/mappers");
|
|
12
12
|
const RESPONSE_DECIMALS = 1;
|
|
13
|
-
const URL = "https://api.
|
|
13
|
+
const URL = "https://api.yexporter.io/v1/chains/1/vaults/all";
|
|
14
14
|
const transformSymbol = (s) => s.replaceAll("_", "-").toLowerCase();
|
|
15
15
|
async function getYearnAPY() {
|
|
16
16
|
try {
|
|
@@ -38,7 +38,7 @@ export declare class CreditManagerData {
|
|
|
38
38
|
constructor(payload: CreditManagerDataPayload);
|
|
39
39
|
getContractETH(signer: Signer | ethers.providers.Provider): ICreditManager;
|
|
40
40
|
contractToAdapter(contractAddress: string): string | undefined;
|
|
41
|
-
encodeAddCollateral(
|
|
41
|
+
encodeAddCollateral(tokenAddress: string, amount: bigint): MultiCall;
|
|
42
42
|
encodeIncreaseDebt(amount: bigint): MultiCall;
|
|
43
43
|
encodeDecreaseDebt(amount: bigint): MultiCall;
|
|
44
44
|
encodeEnableToken(token: string): MultiCall;
|
|
@@ -100,12 +100,12 @@ class CreditManagerData {
|
|
|
100
100
|
contractToAdapter(contractAddress) {
|
|
101
101
|
return this.adapters[contractAddress];
|
|
102
102
|
}
|
|
103
|
-
encodeAddCollateral(
|
|
103
|
+
encodeAddCollateral(tokenAddress, amount) {
|
|
104
104
|
if (this.version === 1)
|
|
105
105
|
throw new Error("Multicall is eligible only for version 2");
|
|
106
106
|
return {
|
|
107
107
|
target: this.creditFacade,
|
|
108
|
-
callData: types_1.
|
|
108
|
+
callData: types_1.ICreditFacadeExtended__factory.createInterface().encodeFunctionData("addCollateral", [tokenAddress, amount]),
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
encodeIncreaseDebt(amount) {
|
|
@@ -113,7 +113,7 @@ class CreditManagerData {
|
|
|
113
113
|
throw new Error("Multicall is eligible only for version 2");
|
|
114
114
|
return {
|
|
115
115
|
target: this.creditFacade,
|
|
116
|
-
callData: types_1.
|
|
116
|
+
callData: types_1.ICreditFacadeExtended__factory.createInterface().encodeFunctionData("increaseDebt", [amount]),
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
encodeDecreaseDebt(amount) {
|
|
@@ -121,7 +121,7 @@ class CreditManagerData {
|
|
|
121
121
|
throw new Error("Multicall is eligible only for version 2");
|
|
122
122
|
return {
|
|
123
123
|
target: this.creditFacade,
|
|
124
|
-
callData: types_1.
|
|
124
|
+
callData: types_1.ICreditFacadeExtended__factory.createInterface().encodeFunctionData("decreaseDebt", [amount]),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
encodeEnableToken(token) {
|
|
@@ -129,7 +129,7 @@ class CreditManagerData {
|
|
|
129
129
|
throw new Error("Multicall is eligible only for version 2");
|
|
130
130
|
return {
|
|
131
131
|
target: this.creditFacade,
|
|
132
|
-
callData: types_1.
|
|
132
|
+
callData: types_1.ICreditFacadeExtended__factory.createInterface().encodeFunctionData("enableToken", [token]),
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
encodeDisableToken(token) {
|
|
@@ -13,8 +13,8 @@ class CreditFacadeParser extends abstractParser_1.AbstractParser {
|
|
|
13
13
|
const { functionFragment, functionName } = this.parseSelector(calldata);
|
|
14
14
|
switch (functionFragment.name) {
|
|
15
15
|
case "addCollateral": {
|
|
16
|
-
const [
|
|
17
|
-
return `${functionName}(onBehalf:
|
|
16
|
+
const [token, amount] = this.decodeFunctionData(functionFragment, calldata);
|
|
17
|
+
return `${functionName}(onBehalf: none, token: ${this.tokenSymbol(token)}, amount: ${this.formatAmount(amount)})`;
|
|
18
18
|
}
|
|
19
19
|
case "increaseDebt":
|
|
20
20
|
case "decreaseDebt": {
|
|
@@ -10,11 +10,10 @@ describe("CreditFacadeParser test", () => {
|
|
|
10
10
|
let parser = new creditFacadeParser_1.CreditFacadeParser("DAI");
|
|
11
11
|
const ifc = types_1.ICreditFacadeExtended__factory.createInterface();
|
|
12
12
|
let parsed = parser.parse(ifc.encodeFunctionData("addCollateral", [
|
|
13
|
-
constants_1.DUMB_ADDRESS,
|
|
14
13
|
token_1.tokenDataByNetwork.Mainnet.WBTC,
|
|
15
14
|
(constants_1.WAD * 444n) / 10n,
|
|
16
15
|
]));
|
|
17
|
-
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].addCollateral(onBehalf:
|
|
16
|
+
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].addCollateral(onBehalf: none, token: WBTC, amount: 44.40 [44400000000000000000])", "Incorrect parse addCollateral");
|
|
18
17
|
parsed = parser.parse(ifc.encodeFunctionData("increaseDebt", [(constants_1.WAD * 414n) / 10n]));
|
|
19
18
|
(0, chai_1.expect)(parsed).to.be.eq("CreditFacade[DAI].increaseDebt(amount: 41.40 [41400000000000000000])", "Incorrect parse increaseDebt");
|
|
20
19
|
parsed = parser.parse(ifc.encodeFunctionData("decreaseDebt", [(constants_1.WAD * 334n) / 10n]));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BaseContract, Signer, utils } from "ethers";
|
|
2
|
+
import type { Listener, Provider } from "@ethersproject/providers";
|
|
3
|
+
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from "../../../../../common";
|
|
4
|
+
export interface BalanceOpsInterface extends utils.Interface {
|
|
5
|
+
functions: {};
|
|
6
|
+
events: {};
|
|
7
|
+
}
|
|
8
|
+
export interface BalanceOps extends BaseContract {
|
|
9
|
+
connect(signerOrProvider: Signer | Provider | string): this;
|
|
10
|
+
attach(addressOrName: string): this;
|
|
11
|
+
deployed(): Promise<this>;
|
|
12
|
+
interface: BalanceOpsInterface;
|
|
13
|
+
queryFilter<TEvent extends TypedEvent>(event: TypedEventFilter<TEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TEvent>>;
|
|
14
|
+
listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
|
|
15
|
+
listeners(eventName?: string): Array<Listener>;
|
|
16
|
+
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
|
|
17
|
+
removeAllListeners(eventName?: string): this;
|
|
18
|
+
off: OnEvent<this>;
|
|
19
|
+
on: OnEvent<this>;
|
|
20
|
+
once: OnEvent<this>;
|
|
21
|
+
removeListener: OnEvent<this>;
|
|
22
|
+
functions: {};
|
|
23
|
+
callStatic: {};
|
|
24
|
+
filters: {};
|
|
25
|
+
estimateGas: {};
|
|
26
|
+
populateTransaction: {};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { BalanceOps } from "./BalanceOps";
|