@gearbox-protocol/sdk 14.10.3-next.2 → 14.10.3-next.3
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.
|
@@ -21,18 +21,24 @@ __export(Zapper_exports, {
|
|
|
21
21
|
Zapper: () => Zapper
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(Zapper_exports);
|
|
24
|
+
var import_utils = require("../../utils/index.js");
|
|
24
25
|
class Zapper {
|
|
25
26
|
pool;
|
|
26
27
|
type;
|
|
27
28
|
baseParams;
|
|
28
29
|
tokenIn;
|
|
29
30
|
tokenOut;
|
|
31
|
+
contractType;
|
|
30
32
|
constructor(data) {
|
|
31
33
|
this.pool = data.pool;
|
|
32
34
|
this.type = data.type;
|
|
33
35
|
this.baseParams = data.baseParams;
|
|
34
36
|
this.tokenIn = data.tokenIn;
|
|
35
37
|
this.tokenOut = data.tokenOut;
|
|
38
|
+
this.contractType = Zapper.contractType(data.baseParams);
|
|
39
|
+
}
|
|
40
|
+
static contractType(baseParams) {
|
|
41
|
+
return (0, import_utils.bytes32ToString)(baseParams.contractType);
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -21,14 +21,21 @@ __export(createZapper_exports, {
|
|
|
21
21
|
createZapper: () => createZapper
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createZapper_exports);
|
|
24
|
-
var import_constants = require("../../constants/index.js");
|
|
25
|
-
var import_utils = require("../../utils/index.js");
|
|
26
24
|
var import_IERC20ZapperContract = require("./IERC20ZapperContract.js");
|
|
27
25
|
var import_IETHZapperContract = require("./IETHZapperContract.js");
|
|
28
26
|
var import_Zapper = require("./Zapper.js");
|
|
29
27
|
function createZapper(sdk, data) {
|
|
30
28
|
if (data.type === "base") {
|
|
31
|
-
|
|
29
|
+
const contractType = import_Zapper.Zapper.contractType(data.baseParams);
|
|
30
|
+
switch (contractType) {
|
|
31
|
+
case "ZAPPER::ERC4626_UNDERLYING":
|
|
32
|
+
return new import_IERC20ZapperContract.IERC20ZapperContract(sdk, data);
|
|
33
|
+
case "ZAPPER::WETH_DEPOSIT":
|
|
34
|
+
return new import_IETHZapperContract.IETHZapperContract(sdk, data);
|
|
35
|
+
default:
|
|
36
|
+
sdk.logger?.warn(`Unknown zapper contract type: ${contractType}`);
|
|
37
|
+
return new import_Zapper.Zapper(data);
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
return new import_Zapper.Zapper(data);
|
|
34
41
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { bytes32ToString } from "../../utils/index.js";
|
|
1
2
|
class Zapper {
|
|
2
3
|
pool;
|
|
3
4
|
type;
|
|
4
5
|
baseParams;
|
|
5
6
|
tokenIn;
|
|
6
7
|
tokenOut;
|
|
8
|
+
contractType;
|
|
7
9
|
constructor(data) {
|
|
8
10
|
this.pool = data.pool;
|
|
9
11
|
this.type = data.type;
|
|
10
12
|
this.baseParams = data.baseParams;
|
|
11
13
|
this.tokenIn = data.tokenIn;
|
|
12
14
|
this.tokenOut = data.tokenOut;
|
|
15
|
+
this.contractType = Zapper.contractType(data.baseParams);
|
|
16
|
+
}
|
|
17
|
+
static contractType(baseParams) {
|
|
18
|
+
return bytes32ToString(baseParams.contractType);
|
|
13
19
|
}
|
|
14
20
|
}
|
|
15
21
|
export {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { NATIVE_ADDRESS } from "../../constants/index.js";
|
|
2
|
-
import { hexEq } from "../../utils/index.js";
|
|
3
1
|
import { IERC20ZapperContract } from "./IERC20ZapperContract.js";
|
|
4
2
|
import { IETHZapperContract } from "./IETHZapperContract.js";
|
|
5
3
|
import { Zapper } from "./Zapper.js";
|
|
6
4
|
function createZapper(sdk, data) {
|
|
7
5
|
if (data.type === "base") {
|
|
8
|
-
|
|
6
|
+
const contractType = Zapper.contractType(data.baseParams);
|
|
7
|
+
switch (contractType) {
|
|
8
|
+
case "ZAPPER::ERC4626_UNDERLYING":
|
|
9
|
+
return new IERC20ZapperContract(sdk, data);
|
|
10
|
+
case "ZAPPER::WETH_DEPOSIT":
|
|
11
|
+
return new IETHZapperContract(sdk, data);
|
|
12
|
+
default:
|
|
13
|
+
sdk.logger?.warn(`Unknown zapper contract type: ${contractType}`);
|
|
14
|
+
return new Zapper(data);
|
|
15
|
+
}
|
|
9
16
|
}
|
|
10
17
|
return new Zapper(data);
|
|
11
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
import type { BaseParams } from "../../base/types.js";
|
|
2
3
|
import type { ZapperData } from "../types.js";
|
|
3
4
|
export declare class Zapper implements ZapperData {
|
|
4
5
|
readonly pool: Address;
|
|
@@ -6,5 +7,7 @@ export declare class Zapper implements ZapperData {
|
|
|
6
7
|
readonly baseParams: ZapperData["baseParams"];
|
|
7
8
|
readonly tokenIn: ZapperData["tokenIn"];
|
|
8
9
|
readonly tokenOut: ZapperData["tokenOut"];
|
|
10
|
+
readonly contractType: string;
|
|
9
11
|
constructor(data: ZapperData);
|
|
12
|
+
static contractType(baseParams: BaseParams): string;
|
|
10
13
|
}
|