@gearbox-protocol/sdk 14.10.2 → 14.10.3-next.1
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/dist/cjs/dev/AccountOpener.js +4 -5
- package/dist/cjs/sdk/market/index.js +3 -1
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +20 -0
- package/dist/cjs/sdk/market/zapper/IERC20ZapperDepositsContract.js +54 -0
- package/dist/cjs/sdk/market/zapper/IETHZapperDepositsContract.js +45 -0
- package/dist/cjs/sdk/market/zapper/IZapperContract.js +54 -0
- package/dist/cjs/sdk/market/zapper/index.js +26 -0
- package/dist/cjs/sdk/pools/PoolService.js +67 -57
- package/dist/esm/dev/AccountOpener.js +4 -5
- package/dist/esm/sdk/market/index.js +1 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +20 -0
- package/dist/esm/sdk/market/zapper/IERC20ZapperDepositsContract.js +30 -0
- package/dist/esm/sdk/market/zapper/IETHZapperDepositsContract.js +21 -0
- package/dist/esm/sdk/market/zapper/IZapperContract.js +30 -0
- package/dist/esm/sdk/market/zapper/index.js +3 -0
- package/dist/esm/sdk/pools/PoolService.js +72 -57
- package/dist/types/sdk/market/index.d.ts +1 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +12 -2
- package/dist/types/sdk/market/zapper/IERC20ZapperDepositsContract.d.ts +211 -0
- package/dist/types/sdk/market/zapper/IETHZapperDepositsContract.d.ts +47 -0
- package/dist/types/sdk/market/zapper/IZapperContract.d.ts +139 -0
- package/dist/types/sdk/market/zapper/index.d.ts +3 -0
- package/dist/types/sdk/pools/PoolService.d.ts +3 -3
- package/dist/types/sdk/pools/types.d.ts +7 -2
- package/package.json +1 -1
|
@@ -524,12 +524,11 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
524
524
|
if (!depositCall) {
|
|
525
525
|
throw new Error(`no deposit call could be created for ${poolName}`);
|
|
526
526
|
}
|
|
527
|
-
txHash = await this.#anvil.
|
|
527
|
+
txHash = await this.#anvil.sendTransaction({
|
|
528
528
|
account: depositor,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
args: depositCall.args,
|
|
529
|
+
to: depositCall.tx.to,
|
|
530
|
+
data: depositCall.tx.callData,
|
|
531
|
+
value: BigInt(depositCall.tx.value ?? "0"),
|
|
533
532
|
chain: this.#anvil.chain
|
|
534
533
|
});
|
|
535
534
|
receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });
|
|
@@ -24,6 +24,7 @@ __reExport(market_exports, require("./pool/index.js"), module.exports);
|
|
|
24
24
|
__reExport(market_exports, require("./pricefeeds/index.js"), module.exports);
|
|
25
25
|
__reExport(market_exports, require("./rwa/index.js"), module.exports);
|
|
26
26
|
__reExport(market_exports, require("./types.js"), module.exports);
|
|
27
|
+
__reExport(market_exports, require("./zapper/index.js"), module.exports);
|
|
27
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
29
|
0 && (module.exports = {
|
|
29
30
|
...require("./adapters/index.js"),
|
|
@@ -34,5 +35,6 @@ __reExport(market_exports, require("./types.js"), module.exports);
|
|
|
34
35
|
...require("./pool/index.js"),
|
|
35
36
|
...require("./pricefeeds/index.js"),
|
|
36
37
|
...require("./rwa/index.js"),
|
|
37
|
-
...require("./types.js")
|
|
38
|
+
...require("./types.js"),
|
|
39
|
+
...require("./zapper/index.js")
|
|
38
40
|
});
|
|
@@ -127,6 +127,26 @@ class PoolV310Contract extends import_base.BaseContract {
|
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Deposits underlying assets into the pool on behalf of a user with a
|
|
132
|
+
* referral code.
|
|
133
|
+
*/
|
|
134
|
+
depositWithReferral(amount, onBehalfOf, referralCode) {
|
|
135
|
+
return this.createRawTx({
|
|
136
|
+
functionName: "depositWithReferral",
|
|
137
|
+
args: [amount, onBehalfOf, referralCode]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Redeems pool shares from the owner and sends the underlying assets to
|
|
142
|
+
* the receiver.
|
|
143
|
+
*/
|
|
144
|
+
redeem(amount, owner, receiver) {
|
|
145
|
+
return this.createRawTx({
|
|
146
|
+
functionName: "redeem",
|
|
147
|
+
args: [amount, owner, receiver]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
130
150
|
stringifyFunctionParams(params) {
|
|
131
151
|
switch (params.functionName) {
|
|
132
152
|
case "deposit": {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var IERC20ZapperDepositsContract_exports = {};
|
|
20
|
+
__export(IERC20ZapperDepositsContract_exports, {
|
|
21
|
+
IERC20ZapperDepositsContract: () => IERC20ZapperDepositsContract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(IERC20ZapperDepositsContract_exports);
|
|
24
|
+
var import_iERC20ZapperDeposits = require("../../../abi/iERC20ZapperDeposits.js");
|
|
25
|
+
var import_base = require("../../base/index.js");
|
|
26
|
+
const abi = import_iERC20ZapperDeposits.ierc20ZapperDepositsAbi;
|
|
27
|
+
class IERC20ZapperDepositsContract extends import_base.BaseContract {
|
|
28
|
+
constructor(options, args) {
|
|
29
|
+
super(options, { ...args, abi });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deposits ERC20 tokens into the pool via this zapper using a referral code.
|
|
33
|
+
*/
|
|
34
|
+
depositWithReferral(tokenInAmount, receiver, referralCode) {
|
|
35
|
+
return this.createRawTx({
|
|
36
|
+
functionName: "depositWithReferral",
|
|
37
|
+
args: [tokenInAmount, receiver, referralCode]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Deposits ERC20 tokens via this zapper with a referral code and an
|
|
42
|
+
* EIP-2612 permit signature, skipping a separate approve transaction.
|
|
43
|
+
*/
|
|
44
|
+
depositWithReferralAndPermit(tokenInAmount, receiver, referralCode, deadline, v, r, s) {
|
|
45
|
+
return this.createRawTx({
|
|
46
|
+
functionName: "depositWithReferralAndPermit",
|
|
47
|
+
args: [tokenInAmount, receiver, referralCode, deadline, v, r, s]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
IERC20ZapperDepositsContract
|
|
54
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var IETHZapperDepositsContract_exports = {};
|
|
20
|
+
__export(IETHZapperDepositsContract_exports, {
|
|
21
|
+
IETHZapperDepositsContract: () => IETHZapperDepositsContract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(IETHZapperDepositsContract_exports);
|
|
24
|
+
var import_iETHZapperDeposits = require("../../../abi/iETHZapperDeposits.js");
|
|
25
|
+
var import_base = require("../../base/index.js");
|
|
26
|
+
const abi = import_iETHZapperDeposits.iethZapperDepositsAbi;
|
|
27
|
+
class IETHZapperDepositsContract extends import_base.BaseContract {
|
|
28
|
+
constructor(options, args) {
|
|
29
|
+
super(options, { ...args, abi });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deposits native ETH into the pool via this zapper using a referral code.
|
|
33
|
+
* The caller must attach the deposit amount as msg.value.
|
|
34
|
+
*/
|
|
35
|
+
depositWithReferral(receiver, referralCode) {
|
|
36
|
+
return this.createRawTx({
|
|
37
|
+
functionName: "depositWithReferral",
|
|
38
|
+
args: [receiver, referralCode]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
IETHZapperDepositsContract
|
|
45
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var IZapperContract_exports = {};
|
|
20
|
+
__export(IZapperContract_exports, {
|
|
21
|
+
IZapperContract: () => IZapperContract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(IZapperContract_exports);
|
|
24
|
+
var import_iZapper = require("../../../abi/iZapper.js");
|
|
25
|
+
var import_base = require("../../base/index.js");
|
|
26
|
+
const abi = import_iZapper.iZapperAbi;
|
|
27
|
+
class IZapperContract extends import_base.BaseContract {
|
|
28
|
+
constructor(options, args) {
|
|
29
|
+
super(options, { ...args, abi });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Redeems pool shares (diesel tokens) for the underlying asset via this zapper.
|
|
33
|
+
*/
|
|
34
|
+
redeem(tokenInAmount, receiver) {
|
|
35
|
+
return this.createRawTx({
|
|
36
|
+
functionName: "redeem",
|
|
37
|
+
args: [tokenInAmount, receiver]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Redeems pool shares via this zapper with an EIP-2612 permit signature,
|
|
42
|
+
* skipping a separate approve transaction.
|
|
43
|
+
*/
|
|
44
|
+
redeemWithPermit(tokenInAmount, receiver, deadline, v, r, s) {
|
|
45
|
+
return this.createRawTx({
|
|
46
|
+
functionName: "redeemWithPermit",
|
|
47
|
+
args: [tokenInAmount, receiver, deadline, v, r, s]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
IZapperContract
|
|
54
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var zapper_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(zapper_exports);
|
|
18
|
+
__reExport(zapper_exports, require("./IERC20ZapperDepositsContract.js"), module.exports);
|
|
19
|
+
__reExport(zapper_exports, require("./IETHZapperDepositsContract.js"), module.exports);
|
|
20
|
+
__reExport(zapper_exports, require("./IZapperContract.js"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./IERC20ZapperDepositsContract.js"),
|
|
24
|
+
...require("./IETHZapperDepositsContract.js"),
|
|
25
|
+
...require("./IZapperContract.js")
|
|
26
|
+
});
|
|
@@ -21,13 +21,10 @@ __export(PoolService_exports, {
|
|
|
21
21
|
PoolService: () => PoolService
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PoolService_exports);
|
|
24
|
-
var import_generated = require("../../abi/310/generated.js");
|
|
25
24
|
var import_iERC20 = require("../../abi/iERC20.js");
|
|
26
|
-
var import_iERC20ZapperDeposits = require("../../abi/iERC20ZapperDeposits.js");
|
|
27
|
-
var import_iETHZapperDeposits = require("../../abi/iETHZapperDeposits.js");
|
|
28
|
-
var import_iZapper = require("../../abi/iZapper.js");
|
|
29
25
|
var import_base = require("../base/index.js");
|
|
30
26
|
var import_constants = require("../constants/index.js");
|
|
27
|
+
var import_zapper = require("../market/zapper/index.js");
|
|
31
28
|
var import_utils = require("../utils/index.js");
|
|
32
29
|
class PoolService extends import_base.SDKConstruct {
|
|
33
30
|
/**
|
|
@@ -100,41 +97,49 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
100
97
|
}
|
|
101
98
|
const { zapper } = meta;
|
|
102
99
|
if (zapper && (0, import_utils.hexEq)(zapper.tokenIn.addr, import_constants.NATIVE_ADDRESS)) {
|
|
100
|
+
const zapperContract = new import_zapper.IETHZapperDepositsContract(this.sdk, {
|
|
101
|
+
addr: zapper.baseParams.addr,
|
|
102
|
+
name: `ETHZapper(${this.labelAddress(zapper.baseParams.addr)})`
|
|
103
|
+
});
|
|
104
|
+
const tx2 = zapperContract.depositWithReferral(wallet, referralCode ?? 0n);
|
|
105
|
+
tx2.value = collateral.balance.toString();
|
|
103
106
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
functionName: "depositWithReferral",
|
|
107
|
-
args: [wallet, referralCode],
|
|
108
|
-
value: collateral.balance
|
|
107
|
+
tx: tx2,
|
|
108
|
+
calls: [{ target: zapper.baseParams.addr, callData: tx2.callData }]
|
|
109
109
|
};
|
|
110
110
|
} else if (zapper) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
args: [collateral.balance, wallet, referralCode]
|
|
129
|
-
};
|
|
130
|
-
} else {
|
|
111
|
+
const zapperContract = new import_zapper.IERC20ZapperDepositsContract(this.sdk, {
|
|
112
|
+
addr: zapper.baseParams.addr,
|
|
113
|
+
name: `ERC20Zapper(${this.labelAddress(zapper.baseParams.addr)})`
|
|
114
|
+
});
|
|
115
|
+
const tx2 = permit ? zapperContract.depositWithReferralAndPermit(
|
|
116
|
+
collateral.balance,
|
|
117
|
+
wallet,
|
|
118
|
+
referralCode ?? 0n,
|
|
119
|
+
permit.deadline,
|
|
120
|
+
permit.v,
|
|
121
|
+
permit.r,
|
|
122
|
+
permit.s
|
|
123
|
+
) : zapperContract.depositWithReferral(
|
|
124
|
+
collateral.balance,
|
|
125
|
+
wallet,
|
|
126
|
+
referralCode ?? 0n
|
|
127
|
+
);
|
|
131
128
|
return {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
functionName: "depositWithReferral",
|
|
135
|
-
args: [collateral.balance, wallet, referralCode]
|
|
129
|
+
tx: tx2,
|
|
130
|
+
calls: [{ target: zapper.baseParams.addr, callData: tx2.callData }]
|
|
136
131
|
};
|
|
137
132
|
}
|
|
133
|
+
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
134
|
+
const tx = poolContract.depositWithReferral(
|
|
135
|
+
collateral.balance,
|
|
136
|
+
wallet,
|
|
137
|
+
referralCode ?? 0n
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
tx,
|
|
141
|
+
calls: [{ target: pool, callData: tx.callData }]
|
|
142
|
+
};
|
|
138
143
|
}
|
|
139
144
|
/**
|
|
140
145
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
@@ -174,39 +179,44 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
174
179
|
const underlying = this.#describeUnderlying(pool);
|
|
175
180
|
if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
|
|
176
181
|
if (underlying.contractType === import_base.RWA_UNDERLYING_ON_DEMAND) {
|
|
177
|
-
|
|
182
|
+
const tokenContract = new import_base.BaseContract(this.sdk, {
|
|
183
|
+
addr: underlying.asset,
|
|
178
184
|
abi: import_iERC20.ierc20Abi,
|
|
185
|
+
name: "ERC20"
|
|
186
|
+
});
|
|
187
|
+
const tx2 = tokenContract.createRawTx({
|
|
179
188
|
functionName: "approve",
|
|
180
|
-
args: [underlying.liquidityProvider, 0n]
|
|
181
|
-
|
|
189
|
+
args: [underlying.liquidityProvider.addr, 0n]
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
tx: tx2,
|
|
193
|
+
calls: [{ target: underlying.asset, callData: tx2.callData }]
|
|
182
194
|
};
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
if (meta.zapper) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
functionName: "redeem",
|
|
202
|
-
args: [amount, wallet]
|
|
198
|
+
const zapperContract = new import_zapper.IZapperContract(this.sdk, {
|
|
199
|
+
addr: meta.zapper.baseParams.addr,
|
|
200
|
+
name: `Zapper(${this.labelAddress(meta.zapper.baseParams.addr)})`
|
|
201
|
+
});
|
|
202
|
+
const tx2 = permit ? zapperContract.redeemWithPermit(
|
|
203
|
+
amount,
|
|
204
|
+
wallet,
|
|
205
|
+
permit.deadline,
|
|
206
|
+
permit.v,
|
|
207
|
+
permit.r,
|
|
208
|
+
permit.s
|
|
209
|
+
) : zapperContract.redeem(amount, wallet);
|
|
210
|
+
return {
|
|
211
|
+
tx: tx2,
|
|
212
|
+
calls: [{ target: meta.zapper.baseParams.addr, callData: tx2.callData }]
|
|
203
213
|
};
|
|
204
214
|
}
|
|
215
|
+
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
216
|
+
const tx = poolContract.redeem(amount, wallet, wallet);
|
|
205
217
|
return {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
functionName: "redeem",
|
|
209
|
-
args: [amount, wallet, wallet]
|
|
218
|
+
tx,
|
|
219
|
+
calls: [{ target: pool, callData: tx.callData }]
|
|
210
220
|
};
|
|
211
221
|
}
|
|
212
222
|
/**
|
|
@@ -516,12 +516,11 @@ class AccountOpener extends SDKConstruct {
|
|
|
516
516
|
if (!depositCall) {
|
|
517
517
|
throw new Error(`no deposit call could be created for ${poolName}`);
|
|
518
518
|
}
|
|
519
|
-
txHash = await this.#anvil.
|
|
519
|
+
txHash = await this.#anvil.sendTransaction({
|
|
520
520
|
account: depositor,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
args: depositCall.args,
|
|
521
|
+
to: depositCall.tx.to,
|
|
522
|
+
data: depositCall.tx.callData,
|
|
523
|
+
value: BigInt(depositCall.tx.value ?? "0"),
|
|
525
524
|
chain: this.#anvil.chain
|
|
526
525
|
});
|
|
527
526
|
receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });
|
|
@@ -109,6 +109,26 @@ class PoolV310Contract extends BaseContract {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Deposits underlying assets into the pool on behalf of a user with a
|
|
114
|
+
* referral code.
|
|
115
|
+
*/
|
|
116
|
+
depositWithReferral(amount, onBehalfOf, referralCode) {
|
|
117
|
+
return this.createRawTx({
|
|
118
|
+
functionName: "depositWithReferral",
|
|
119
|
+
args: [amount, onBehalfOf, referralCode]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Redeems pool shares from the owner and sends the underlying assets to
|
|
124
|
+
* the receiver.
|
|
125
|
+
*/
|
|
126
|
+
redeem(amount, owner, receiver) {
|
|
127
|
+
return this.createRawTx({
|
|
128
|
+
functionName: "redeem",
|
|
129
|
+
args: [amount, owner, receiver]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
112
132
|
stringifyFunctionParams(params) {
|
|
113
133
|
switch (params.functionName) {
|
|
114
134
|
case "deposit": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ierc20ZapperDepositsAbi } from "../../../abi/iERC20ZapperDeposits.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
const abi = ierc20ZapperDepositsAbi;
|
|
4
|
+
class IERC20ZapperDepositsContract extends BaseContract {
|
|
5
|
+
constructor(options, args) {
|
|
6
|
+
super(options, { ...args, abi });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Deposits ERC20 tokens into the pool via this zapper using a referral code.
|
|
10
|
+
*/
|
|
11
|
+
depositWithReferral(tokenInAmount, receiver, referralCode) {
|
|
12
|
+
return this.createRawTx({
|
|
13
|
+
functionName: "depositWithReferral",
|
|
14
|
+
args: [tokenInAmount, receiver, referralCode]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Deposits ERC20 tokens via this zapper with a referral code and an
|
|
19
|
+
* EIP-2612 permit signature, skipping a separate approve transaction.
|
|
20
|
+
*/
|
|
21
|
+
depositWithReferralAndPermit(tokenInAmount, receiver, referralCode, deadline, v, r, s) {
|
|
22
|
+
return this.createRawTx({
|
|
23
|
+
functionName: "depositWithReferralAndPermit",
|
|
24
|
+
args: [tokenInAmount, receiver, referralCode, deadline, v, r, s]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
IERC20ZapperDepositsContract
|
|
30
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { iethZapperDepositsAbi } from "../../../abi/iETHZapperDeposits.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
const abi = iethZapperDepositsAbi;
|
|
4
|
+
class IETHZapperDepositsContract extends BaseContract {
|
|
5
|
+
constructor(options, args) {
|
|
6
|
+
super(options, { ...args, abi });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Deposits native ETH into the pool via this zapper using a referral code.
|
|
10
|
+
* The caller must attach the deposit amount as msg.value.
|
|
11
|
+
*/
|
|
12
|
+
depositWithReferral(receiver, referralCode) {
|
|
13
|
+
return this.createRawTx({
|
|
14
|
+
functionName: "depositWithReferral",
|
|
15
|
+
args: [receiver, referralCode]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
IETHZapperDepositsContract
|
|
21
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
const abi = iZapperAbi;
|
|
4
|
+
class IZapperContract extends BaseContract {
|
|
5
|
+
constructor(options, args) {
|
|
6
|
+
super(options, { ...args, abi });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Redeems pool shares (diesel tokens) for the underlying asset via this zapper.
|
|
10
|
+
*/
|
|
11
|
+
redeem(tokenInAmount, receiver) {
|
|
12
|
+
return this.createRawTx({
|
|
13
|
+
functionName: "redeem",
|
|
14
|
+
args: [tokenInAmount, receiver]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Redeems pool shares via this zapper with an EIP-2612 permit signature,
|
|
19
|
+
* skipping a separate approve transaction.
|
|
20
|
+
*/
|
|
21
|
+
redeemWithPermit(tokenInAmount, receiver, deadline, v, r, s) {
|
|
22
|
+
return this.createRawTx({
|
|
23
|
+
functionName: "redeemWithPermit",
|
|
24
|
+
args: [tokenInAmount, receiver, deadline, v, r, s]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
IZapperContract
|
|
30
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
|
-
import { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
4
|
-
import { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
5
|
-
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
6
2
|
import {
|
|
3
|
+
BaseContract,
|
|
7
4
|
RWA_UNDERLYING_DEFAULT,
|
|
8
5
|
RWA_UNDERLYING_ON_DEMAND,
|
|
9
6
|
SDKConstruct
|
|
10
7
|
} from "../base/index.js";
|
|
11
8
|
import { NATIVE_ADDRESS } from "../constants/index.js";
|
|
9
|
+
import {
|
|
10
|
+
IERC20ZapperDepositsContract,
|
|
11
|
+
IETHZapperDepositsContract,
|
|
12
|
+
IZapperContract
|
|
13
|
+
} from "../market/zapper/index.js";
|
|
12
14
|
import { AddressSet, hexEq } from "../utils/index.js";
|
|
13
15
|
class PoolService extends SDKConstruct {
|
|
14
16
|
/**
|
|
@@ -81,41 +83,49 @@ class PoolService extends SDKConstruct {
|
|
|
81
83
|
}
|
|
82
84
|
const { zapper } = meta;
|
|
83
85
|
if (zapper && hexEq(zapper.tokenIn.addr, NATIVE_ADDRESS)) {
|
|
86
|
+
const zapperContract = new IETHZapperDepositsContract(this.sdk, {
|
|
87
|
+
addr: zapper.baseParams.addr,
|
|
88
|
+
name: `ETHZapper(${this.labelAddress(zapper.baseParams.addr)})`
|
|
89
|
+
});
|
|
90
|
+
const tx2 = zapperContract.depositWithReferral(wallet, referralCode ?? 0n);
|
|
91
|
+
tx2.value = collateral.balance.toString();
|
|
84
92
|
return {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
functionName: "depositWithReferral",
|
|
88
|
-
args: [wallet, referralCode],
|
|
89
|
-
value: collateral.balance
|
|
93
|
+
tx: tx2,
|
|
94
|
+
calls: [{ target: zapper.baseParams.addr, callData: tx2.callData }]
|
|
90
95
|
};
|
|
91
96
|
} else if (zapper) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
args: [collateral.balance, wallet, referralCode]
|
|
110
|
-
};
|
|
111
|
-
} else {
|
|
97
|
+
const zapperContract = new IERC20ZapperDepositsContract(this.sdk, {
|
|
98
|
+
addr: zapper.baseParams.addr,
|
|
99
|
+
name: `ERC20Zapper(${this.labelAddress(zapper.baseParams.addr)})`
|
|
100
|
+
});
|
|
101
|
+
const tx2 = permit ? zapperContract.depositWithReferralAndPermit(
|
|
102
|
+
collateral.balance,
|
|
103
|
+
wallet,
|
|
104
|
+
referralCode ?? 0n,
|
|
105
|
+
permit.deadline,
|
|
106
|
+
permit.v,
|
|
107
|
+
permit.r,
|
|
108
|
+
permit.s
|
|
109
|
+
) : zapperContract.depositWithReferral(
|
|
110
|
+
collateral.balance,
|
|
111
|
+
wallet,
|
|
112
|
+
referralCode ?? 0n
|
|
113
|
+
);
|
|
112
114
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
functionName: "depositWithReferral",
|
|
116
|
-
args: [collateral.balance, wallet, referralCode]
|
|
115
|
+
tx: tx2,
|
|
116
|
+
calls: [{ target: zapper.baseParams.addr, callData: tx2.callData }]
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
+
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
120
|
+
const tx = poolContract.depositWithReferral(
|
|
121
|
+
collateral.balance,
|
|
122
|
+
wallet,
|
|
123
|
+
referralCode ?? 0n
|
|
124
|
+
);
|
|
125
|
+
return {
|
|
126
|
+
tx,
|
|
127
|
+
calls: [{ target: pool, callData: tx.callData }]
|
|
128
|
+
};
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
121
131
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
@@ -155,39 +165,44 @@ class PoolService extends SDKConstruct {
|
|
|
155
165
|
const underlying = this.#describeUnderlying(pool);
|
|
156
166
|
if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
|
|
157
167
|
if (underlying.contractType === RWA_UNDERLYING_ON_DEMAND) {
|
|
158
|
-
|
|
168
|
+
const tokenContract = new BaseContract(this.sdk, {
|
|
169
|
+
addr: underlying.asset,
|
|
159
170
|
abi: ierc20Abi,
|
|
171
|
+
name: "ERC20"
|
|
172
|
+
});
|
|
173
|
+
const tx2 = tokenContract.createRawTx({
|
|
160
174
|
functionName: "approve",
|
|
161
|
-
args: [underlying.liquidityProvider, 0n]
|
|
162
|
-
|
|
175
|
+
args: [underlying.liquidityProvider.addr, 0n]
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
tx: tx2,
|
|
179
|
+
calls: [{ target: underlying.asset, callData: tx2.callData }]
|
|
163
180
|
};
|
|
164
181
|
}
|
|
165
182
|
}
|
|
166
183
|
if (meta.zapper) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
functionName: "redeem",
|
|
183
|
-
args: [amount, wallet]
|
|
184
|
+
const zapperContract = new IZapperContract(this.sdk, {
|
|
185
|
+
addr: meta.zapper.baseParams.addr,
|
|
186
|
+
name: `Zapper(${this.labelAddress(meta.zapper.baseParams.addr)})`
|
|
187
|
+
});
|
|
188
|
+
const tx2 = permit ? zapperContract.redeemWithPermit(
|
|
189
|
+
amount,
|
|
190
|
+
wallet,
|
|
191
|
+
permit.deadline,
|
|
192
|
+
permit.v,
|
|
193
|
+
permit.r,
|
|
194
|
+
permit.s
|
|
195
|
+
) : zapperContract.redeem(amount, wallet);
|
|
196
|
+
return {
|
|
197
|
+
tx: tx2,
|
|
198
|
+
calls: [{ target: meta.zapper.baseParams.addr, callData: tx2.callData }]
|
|
184
199
|
};
|
|
185
200
|
}
|
|
201
|
+
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
202
|
+
const tx = poolContract.redeem(amount, wallet, wallet);
|
|
186
203
|
return {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
functionName: "redeem",
|
|
190
|
-
args: [amount, wallet, wallet]
|
|
204
|
+
tx,
|
|
205
|
+
calls: [{ target: pool, callData: tx.callData }]
|
|
191
206
|
};
|
|
192
207
|
}
|
|
193
208
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
1
|
+
import type { Address, ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
2
2
|
import type { CreditManagerDebtParams, PoolState } from "../../base/index.js";
|
|
3
3
|
import { BaseContract } from "../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
|
-
import type { PoolStateHuman } from "../../types/index.js";
|
|
5
|
+
import type { PoolStateHuman, RawTx } from "../../types/index.js";
|
|
6
6
|
import { AddressMap } from "../../utils/index.js";
|
|
7
7
|
import type { IRWAFactory } from "../rwa/types.js";
|
|
8
8
|
declare const abi: readonly [{
|
|
@@ -1138,6 +1138,16 @@ export declare class PoolV310Contract extends BaseContract<abi> {
|
|
|
1138
1138
|
get rwaFactory(): IRWAFactory | undefined;
|
|
1139
1139
|
stateHuman(raw?: boolean): PoolStateHuman;
|
|
1140
1140
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
1141
|
+
/**
|
|
1142
|
+
* Deposits underlying assets into the pool on behalf of a user with a
|
|
1143
|
+
* referral code.
|
|
1144
|
+
*/
|
|
1145
|
+
depositWithReferral(amount: bigint, onBehalfOf: Address, referralCode: bigint): RawTx;
|
|
1146
|
+
/**
|
|
1147
|
+
* Redeems pool shares from the owner and sends the underlying assets to
|
|
1148
|
+
* the receiver.
|
|
1149
|
+
*/
|
|
1150
|
+
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
1141
1151
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
1142
1152
|
}
|
|
1143
1153
|
export {};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { BaseContractArgs, ConstructOptions } from "../../base/index.js";
|
|
3
|
+
import { BaseContract } from "../../base/index.js";
|
|
4
|
+
import type { RawTx } from "../../types/index.js";
|
|
5
|
+
declare const abi: readonly [{
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly name: "tokenInAmount";
|
|
9
|
+
readonly internalType: "uint256";
|
|
10
|
+
readonly type: "uint256";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "receiver";
|
|
13
|
+
readonly internalType: "address";
|
|
14
|
+
readonly type: "address";
|
|
15
|
+
}];
|
|
16
|
+
readonly name: "deposit";
|
|
17
|
+
readonly outputs: readonly [{
|
|
18
|
+
readonly name: "tokenOutAmount";
|
|
19
|
+
readonly internalType: "uint256";
|
|
20
|
+
readonly type: "uint256";
|
|
21
|
+
}];
|
|
22
|
+
readonly stateMutability: "nonpayable";
|
|
23
|
+
}, {
|
|
24
|
+
readonly type: "function";
|
|
25
|
+
readonly inputs: readonly [{
|
|
26
|
+
readonly name: "tokenInAmount";
|
|
27
|
+
readonly internalType: "uint256";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "receiver";
|
|
31
|
+
readonly internalType: "address";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "deadline";
|
|
35
|
+
readonly internalType: "uint256";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "v";
|
|
39
|
+
readonly internalType: "uint8";
|
|
40
|
+
readonly type: "uint8";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "r";
|
|
43
|
+
readonly internalType: "bytes32";
|
|
44
|
+
readonly type: "bytes32";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "s";
|
|
47
|
+
readonly internalType: "bytes32";
|
|
48
|
+
readonly type: "bytes32";
|
|
49
|
+
}];
|
|
50
|
+
readonly name: "depositWithPermit";
|
|
51
|
+
readonly outputs: readonly [{
|
|
52
|
+
readonly name: "tokenOutAmount";
|
|
53
|
+
readonly internalType: "uint256";
|
|
54
|
+
readonly type: "uint256";
|
|
55
|
+
}];
|
|
56
|
+
readonly stateMutability: "nonpayable";
|
|
57
|
+
}, {
|
|
58
|
+
readonly type: "function";
|
|
59
|
+
readonly inputs: readonly [{
|
|
60
|
+
readonly name: "tokenInAmount";
|
|
61
|
+
readonly internalType: "uint256";
|
|
62
|
+
readonly type: "uint256";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "receiver";
|
|
65
|
+
readonly internalType: "address";
|
|
66
|
+
readonly type: "address";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "nonce";
|
|
69
|
+
readonly internalType: "uint256";
|
|
70
|
+
readonly type: "uint256";
|
|
71
|
+
}, {
|
|
72
|
+
readonly name: "expiry";
|
|
73
|
+
readonly internalType: "uint256";
|
|
74
|
+
readonly type: "uint256";
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "v";
|
|
77
|
+
readonly internalType: "uint8";
|
|
78
|
+
readonly type: "uint8";
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "r";
|
|
81
|
+
readonly internalType: "bytes32";
|
|
82
|
+
readonly type: "bytes32";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "s";
|
|
85
|
+
readonly internalType: "bytes32";
|
|
86
|
+
readonly type: "bytes32";
|
|
87
|
+
}];
|
|
88
|
+
readonly name: "depositWithPermitAllowed";
|
|
89
|
+
readonly outputs: readonly [{
|
|
90
|
+
readonly name: "tokenOutAmount";
|
|
91
|
+
readonly internalType: "uint256";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
}];
|
|
94
|
+
readonly stateMutability: "nonpayable";
|
|
95
|
+
}, {
|
|
96
|
+
readonly type: "function";
|
|
97
|
+
readonly inputs: readonly [{
|
|
98
|
+
readonly name: "tokenInAmount";
|
|
99
|
+
readonly internalType: "uint256";
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "receiver";
|
|
103
|
+
readonly internalType: "address";
|
|
104
|
+
readonly type: "address";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "referralCode";
|
|
107
|
+
readonly internalType: "uint256";
|
|
108
|
+
readonly type: "uint256";
|
|
109
|
+
}];
|
|
110
|
+
readonly name: "depositWithReferral";
|
|
111
|
+
readonly outputs: readonly [{
|
|
112
|
+
readonly name: "tokenOutAmount";
|
|
113
|
+
readonly internalType: "uint256";
|
|
114
|
+
readonly type: "uint256";
|
|
115
|
+
}];
|
|
116
|
+
readonly stateMutability: "nonpayable";
|
|
117
|
+
}, {
|
|
118
|
+
readonly type: "function";
|
|
119
|
+
readonly inputs: readonly [{
|
|
120
|
+
readonly name: "tokenInAmount";
|
|
121
|
+
readonly internalType: "uint256";
|
|
122
|
+
readonly type: "uint256";
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "receiver";
|
|
125
|
+
readonly internalType: "address";
|
|
126
|
+
readonly type: "address";
|
|
127
|
+
}, {
|
|
128
|
+
readonly name: "referralCode";
|
|
129
|
+
readonly internalType: "uint256";
|
|
130
|
+
readonly type: "uint256";
|
|
131
|
+
}, {
|
|
132
|
+
readonly name: "deadline";
|
|
133
|
+
readonly internalType: "uint256";
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
}, {
|
|
136
|
+
readonly name: "v";
|
|
137
|
+
readonly internalType: "uint8";
|
|
138
|
+
readonly type: "uint8";
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "r";
|
|
141
|
+
readonly internalType: "bytes32";
|
|
142
|
+
readonly type: "bytes32";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "s";
|
|
145
|
+
readonly internalType: "bytes32";
|
|
146
|
+
readonly type: "bytes32";
|
|
147
|
+
}];
|
|
148
|
+
readonly name: "depositWithReferralAndPermit";
|
|
149
|
+
readonly outputs: readonly [{
|
|
150
|
+
readonly name: "tokenOutAmount";
|
|
151
|
+
readonly internalType: "uint256";
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
}];
|
|
154
|
+
readonly stateMutability: "nonpayable";
|
|
155
|
+
}, {
|
|
156
|
+
readonly type: "function";
|
|
157
|
+
readonly inputs: readonly [{
|
|
158
|
+
readonly name: "tokenInAmount";
|
|
159
|
+
readonly internalType: "uint256";
|
|
160
|
+
readonly type: "uint256";
|
|
161
|
+
}, {
|
|
162
|
+
readonly name: "receiver";
|
|
163
|
+
readonly internalType: "address";
|
|
164
|
+
readonly type: "address";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "referralCode";
|
|
167
|
+
readonly internalType: "uint256";
|
|
168
|
+
readonly type: "uint256";
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: "nonce";
|
|
171
|
+
readonly internalType: "uint256";
|
|
172
|
+
readonly type: "uint256";
|
|
173
|
+
}, {
|
|
174
|
+
readonly name: "expiry";
|
|
175
|
+
readonly internalType: "uint256";
|
|
176
|
+
readonly type: "uint256";
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "v";
|
|
179
|
+
readonly internalType: "uint8";
|
|
180
|
+
readonly type: "uint8";
|
|
181
|
+
}, {
|
|
182
|
+
readonly name: "r";
|
|
183
|
+
readonly internalType: "bytes32";
|
|
184
|
+
readonly type: "bytes32";
|
|
185
|
+
}, {
|
|
186
|
+
readonly name: "s";
|
|
187
|
+
readonly internalType: "bytes32";
|
|
188
|
+
readonly type: "bytes32";
|
|
189
|
+
}];
|
|
190
|
+
readonly name: "depositWithReferralAndPermitAllowed";
|
|
191
|
+
readonly outputs: readonly [{
|
|
192
|
+
readonly name: "tokenOutAmount";
|
|
193
|
+
readonly internalType: "uint256";
|
|
194
|
+
readonly type: "uint256";
|
|
195
|
+
}];
|
|
196
|
+
readonly stateMutability: "nonpayable";
|
|
197
|
+
}];
|
|
198
|
+
type abi = typeof abi;
|
|
199
|
+
export declare class IERC20ZapperDepositsContract extends BaseContract<abi> {
|
|
200
|
+
constructor(options: ConstructOptions, args: Omit<BaseContractArgs<abi>, "abi">);
|
|
201
|
+
/**
|
|
202
|
+
* Deposits ERC20 tokens into the pool via this zapper using a referral code.
|
|
203
|
+
*/
|
|
204
|
+
depositWithReferral(tokenInAmount: bigint, receiver: Address, referralCode: bigint): RawTx;
|
|
205
|
+
/**
|
|
206
|
+
* Deposits ERC20 tokens via this zapper with a referral code and an
|
|
207
|
+
* EIP-2612 permit signature, skipping a separate approve transaction.
|
|
208
|
+
*/
|
|
209
|
+
depositWithReferralAndPermit(tokenInAmount: bigint, receiver: Address, referralCode: bigint, deadline: bigint, v: number, r: Hex, s: Hex): RawTx;
|
|
210
|
+
}
|
|
211
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { BaseContractArgs, ConstructOptions } from "../../base/index.js";
|
|
3
|
+
import { BaseContract } from "../../base/index.js";
|
|
4
|
+
import type { RawTx } from "../../types/index.js";
|
|
5
|
+
declare const abi: readonly [{
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly name: "receiver";
|
|
9
|
+
readonly internalType: "address";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
}];
|
|
12
|
+
readonly name: "deposit";
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly name: "tokenOutAmount";
|
|
15
|
+
readonly internalType: "uint256";
|
|
16
|
+
readonly type: "uint256";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "payable";
|
|
19
|
+
}, {
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
readonly inputs: readonly [{
|
|
22
|
+
readonly name: "receiver";
|
|
23
|
+
readonly internalType: "address";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "referralCode";
|
|
27
|
+
readonly internalType: "uint256";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
}];
|
|
30
|
+
readonly name: "depositWithReferral";
|
|
31
|
+
readonly outputs: readonly [{
|
|
32
|
+
readonly name: "tokenOutAmount";
|
|
33
|
+
readonly internalType: "uint256";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}];
|
|
36
|
+
readonly stateMutability: "payable";
|
|
37
|
+
}];
|
|
38
|
+
type abi = typeof abi;
|
|
39
|
+
export declare class IETHZapperDepositsContract extends BaseContract<abi> {
|
|
40
|
+
constructor(options: ConstructOptions, args: Omit<BaseContractArgs<abi>, "abi">);
|
|
41
|
+
/**
|
|
42
|
+
* Deposits native ETH into the pool via this zapper using a referral code.
|
|
43
|
+
* The caller must attach the deposit amount as msg.value.
|
|
44
|
+
*/
|
|
45
|
+
depositWithReferral(receiver: Address, referralCode: bigint): RawTx;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { BaseContractArgs, ConstructOptions } from "../../base/index.js";
|
|
3
|
+
import { BaseContract } from "../../base/index.js";
|
|
4
|
+
import type { RawTx } from "../../types/index.js";
|
|
5
|
+
declare const abi: readonly [{
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
readonly inputs: readonly [];
|
|
8
|
+
readonly name: "pool";
|
|
9
|
+
readonly outputs: readonly [{
|
|
10
|
+
readonly name: "";
|
|
11
|
+
readonly internalType: "address";
|
|
12
|
+
readonly type: "address";
|
|
13
|
+
}];
|
|
14
|
+
readonly stateMutability: "view";
|
|
15
|
+
}, {
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
readonly inputs: readonly [{
|
|
18
|
+
readonly name: "tokenInAmount";
|
|
19
|
+
readonly internalType: "uint256";
|
|
20
|
+
readonly type: "uint256";
|
|
21
|
+
}];
|
|
22
|
+
readonly name: "previewDeposit";
|
|
23
|
+
readonly outputs: readonly [{
|
|
24
|
+
readonly name: "tokenOutAmount";
|
|
25
|
+
readonly internalType: "uint256";
|
|
26
|
+
readonly type: "uint256";
|
|
27
|
+
}];
|
|
28
|
+
readonly stateMutability: "view";
|
|
29
|
+
}, {
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
readonly inputs: readonly [{
|
|
32
|
+
readonly name: "tokenOutAmount";
|
|
33
|
+
readonly internalType: "uint256";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}];
|
|
36
|
+
readonly name: "previewRedeem";
|
|
37
|
+
readonly outputs: readonly [{
|
|
38
|
+
readonly name: "tokenInAmount";
|
|
39
|
+
readonly internalType: "uint256";
|
|
40
|
+
readonly type: "uint256";
|
|
41
|
+
}];
|
|
42
|
+
readonly stateMutability: "view";
|
|
43
|
+
}, {
|
|
44
|
+
readonly type: "function";
|
|
45
|
+
readonly inputs: readonly [{
|
|
46
|
+
readonly name: "tokenOutAmount";
|
|
47
|
+
readonly internalType: "uint256";
|
|
48
|
+
readonly type: "uint256";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "receiver";
|
|
51
|
+
readonly internalType: "address";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
}];
|
|
54
|
+
readonly name: "redeem";
|
|
55
|
+
readonly outputs: readonly [{
|
|
56
|
+
readonly name: "tokenInAmount";
|
|
57
|
+
readonly internalType: "uint256";
|
|
58
|
+
readonly type: "uint256";
|
|
59
|
+
}];
|
|
60
|
+
readonly stateMutability: "nonpayable";
|
|
61
|
+
}, {
|
|
62
|
+
readonly type: "function";
|
|
63
|
+
readonly inputs: readonly [{
|
|
64
|
+
readonly name: "tokenOutAmount";
|
|
65
|
+
readonly internalType: "uint256";
|
|
66
|
+
readonly type: "uint256";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "receiver";
|
|
69
|
+
readonly internalType: "address";
|
|
70
|
+
readonly type: "address";
|
|
71
|
+
}, {
|
|
72
|
+
readonly name: "deadline";
|
|
73
|
+
readonly internalType: "uint256";
|
|
74
|
+
readonly type: "uint256";
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "v";
|
|
77
|
+
readonly internalType: "uint8";
|
|
78
|
+
readonly type: "uint8";
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "r";
|
|
81
|
+
readonly internalType: "bytes32";
|
|
82
|
+
readonly type: "bytes32";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "s";
|
|
85
|
+
readonly internalType: "bytes32";
|
|
86
|
+
readonly type: "bytes32";
|
|
87
|
+
}];
|
|
88
|
+
readonly name: "redeemWithPermit";
|
|
89
|
+
readonly outputs: readonly [{
|
|
90
|
+
readonly name: "tokenInAmount";
|
|
91
|
+
readonly internalType: "uint256";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
}];
|
|
94
|
+
readonly stateMutability: "nonpayable";
|
|
95
|
+
}, {
|
|
96
|
+
readonly type: "function";
|
|
97
|
+
readonly inputs: readonly [];
|
|
98
|
+
readonly name: "tokenIn";
|
|
99
|
+
readonly outputs: readonly [{
|
|
100
|
+
readonly name: "";
|
|
101
|
+
readonly internalType: "address";
|
|
102
|
+
readonly type: "address";
|
|
103
|
+
}];
|
|
104
|
+
readonly stateMutability: "view";
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "function";
|
|
107
|
+
readonly inputs: readonly [];
|
|
108
|
+
readonly name: "tokenOut";
|
|
109
|
+
readonly outputs: readonly [{
|
|
110
|
+
readonly name: "";
|
|
111
|
+
readonly internalType: "address";
|
|
112
|
+
readonly type: "address";
|
|
113
|
+
}];
|
|
114
|
+
readonly stateMutability: "view";
|
|
115
|
+
}, {
|
|
116
|
+
readonly type: "function";
|
|
117
|
+
readonly inputs: readonly [];
|
|
118
|
+
readonly name: "underlying";
|
|
119
|
+
readonly outputs: readonly [{
|
|
120
|
+
readonly name: "";
|
|
121
|
+
readonly internalType: "address";
|
|
122
|
+
readonly type: "address";
|
|
123
|
+
}];
|
|
124
|
+
readonly stateMutability: "view";
|
|
125
|
+
}];
|
|
126
|
+
type abi = typeof abi;
|
|
127
|
+
export declare class IZapperContract extends BaseContract<abi> {
|
|
128
|
+
constructor(options: ConstructOptions, args: Omit<BaseContractArgs<abi>, "abi">);
|
|
129
|
+
/**
|
|
130
|
+
* Redeems pool shares (diesel tokens) for the underlying asset via this zapper.
|
|
131
|
+
*/
|
|
132
|
+
redeem(tokenInAmount: bigint, receiver: Address): RawTx;
|
|
133
|
+
/**
|
|
134
|
+
* Redeems pool shares via this zapper with an EIP-2612 permit signature,
|
|
135
|
+
* skipping a separate approve transaction.
|
|
136
|
+
*/
|
|
137
|
+
redeemWithPermit(tokenInAmount: bigint, receiver: Address, deadline: bigint, v: number, r: Hex, s: Hex): RawTx;
|
|
138
|
+
}
|
|
139
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
import type { AddLiquidityProps, DepositMetadata, IPoolsService,
|
|
3
|
+
import type { AddLiquidityProps, DepositMetadata, IPoolsService, PoolServiceCallResult, RemoveLiquidityProps, WithdrawalMetadata } from "./types.js";
|
|
4
4
|
export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
5
5
|
#private;
|
|
6
6
|
/**
|
|
@@ -18,7 +18,7 @@ export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
18
18
|
/**
|
|
19
19
|
* {@inheritDoc IPoolsService.addLiquidity}
|
|
20
20
|
*/
|
|
21
|
-
addLiquidity(props: AddLiquidityProps):
|
|
21
|
+
addLiquidity(props: AddLiquidityProps): PoolServiceCallResult | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
24
24
|
*/
|
|
@@ -30,7 +30,7 @@ export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
30
30
|
/**
|
|
31
31
|
* {@inheritDoc IPoolsService.removeLiquidity}
|
|
32
32
|
*/
|
|
33
|
-
removeLiquidity(props: RemoveLiquidityProps):
|
|
33
|
+
removeLiquidity(props: RemoveLiquidityProps): PoolServiceCallResult;
|
|
34
34
|
/**
|
|
35
35
|
* {@inheritDoc IPoolsService.getWithdrawalMetadata}
|
|
36
36
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Abi, Address, ContractFunctionArgs, ContractFunctionName } from "viem";
|
|
2
2
|
import type { ZapperData } from "../market/index.js";
|
|
3
3
|
import type { Asset } from "../router/index.js";
|
|
4
|
+
import type { MultiCall, RawTx } from "../types/transactions.js";
|
|
4
5
|
interface PermitResult {
|
|
5
6
|
r: Address;
|
|
6
7
|
s: Address;
|
|
@@ -19,6 +20,10 @@ export type PoolServiceCall<abi extends Abi | readonly unknown[] = Abi, function
|
|
|
19
20
|
target: Address;
|
|
20
21
|
value?: bigint;
|
|
21
22
|
};
|
|
23
|
+
export interface PoolServiceCallResult {
|
|
24
|
+
tx: RawTx;
|
|
25
|
+
calls: Array<MultiCall>;
|
|
26
|
+
}
|
|
22
27
|
export interface AddLiquidityProps {
|
|
23
28
|
/**
|
|
24
29
|
* Token and amount to deposit.
|
|
@@ -146,13 +151,13 @@ export interface IPoolsService {
|
|
|
146
151
|
* @param props - {@link AddLiquidityProps}
|
|
147
152
|
* @returns - {@link AddLiquidityCall}
|
|
148
153
|
*/
|
|
149
|
-
addLiquidity(props: AddLiquidityProps):
|
|
154
|
+
addLiquidity(props: AddLiquidityProps): PoolServiceCallResult | undefined;
|
|
150
155
|
/**
|
|
151
156
|
* Construct a call to remove liquidity from a Gearbox lending pool.
|
|
152
157
|
*
|
|
153
158
|
* @param props - {@link RemoveLiquidityProps}
|
|
154
159
|
* @returns - {@link RemoveLiquidityCall}
|
|
155
160
|
*/
|
|
156
|
-
removeLiquidity(props: RemoveLiquidityProps):
|
|
161
|
+
removeLiquidity(props: RemoveLiquidityProps): PoolServiceCallResult;
|
|
157
162
|
}
|
|
158
163
|
export {};
|