@morpho-org/bundler-sdk-viem 3.0.0-next.13 → 3.0.0-next.15
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/BundlerAction.d.ts +1 -1
- package/lib/BundlerAction.js +17 -11
- package/lib/actions.js +7 -6
- package/lib/operations.js +2 -2
- package/lib/types/actions.d.ts +0 -2
- package/package.json +6 -6
package/lib/BundlerAction.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare namespace BundlerAction {
|
|
|
88
88
|
* @param recipient The recipient of ERC20 tokens. Defaults to the chain's bundler3 general adapter.
|
|
89
89
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
90
90
|
*/
|
|
91
|
-
function transferFrom2(chainId: ChainId, asset: Address,
|
|
91
|
+
function transferFrom2(chainId: ChainId, asset: Address, amount: bigint, recipient?: Address, skipRevert?: boolean): BundlerCall[];
|
|
92
92
|
/**
|
|
93
93
|
* Encodes a call to the Adapter to wrap ERC20 tokens via the provided ERC20Wrapper.
|
|
94
94
|
* @param chainId The chain id for which to encode the call.
|
package/lib/BundlerAction.js
CHANGED
|
@@ -379,7 +379,7 @@ export var BundlerAction;
|
|
|
379
379
|
* @param skipRevert Whether to allow the permit to revert without making the whole bundle revert. Defaults to true.
|
|
380
380
|
*/
|
|
381
381
|
function approve2(chainId, owner, permitSingle, signature, skipRevert = true) {
|
|
382
|
-
const { permit2 } = getChainAddresses(chainId);
|
|
382
|
+
const { permit2, bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
383
383
|
if (permit2 == null)
|
|
384
384
|
throw new BundlerErrors.UnexpectedAction("approve2", chainId);
|
|
385
385
|
return [
|
|
@@ -388,7 +388,16 @@ export var BundlerAction;
|
|
|
388
388
|
data: encodeFunctionData({
|
|
389
389
|
abi: permit2Abi,
|
|
390
390
|
functionName: "permit",
|
|
391
|
-
args: [
|
|
391
|
+
args: [
|
|
392
|
+
owner,
|
|
393
|
+
{
|
|
394
|
+
...permitSingle,
|
|
395
|
+
// Never permit any other address than the GeneralAdapter1 otherwise
|
|
396
|
+
// the signature can be extracted and used independently.
|
|
397
|
+
spender: generalAdapter1,
|
|
398
|
+
},
|
|
399
|
+
signature,
|
|
400
|
+
],
|
|
392
401
|
}),
|
|
393
402
|
value: 0n,
|
|
394
403
|
skipRevert,
|
|
@@ -406,19 +415,16 @@ export var BundlerAction;
|
|
|
406
415
|
* @param recipient The recipient of ERC20 tokens. Defaults to the chain's bundler3 general adapter.
|
|
407
416
|
* @param skipRevert Whether to allow the transfer to revert without making the whole bundler revert. Defaults to false.
|
|
408
417
|
*/
|
|
409
|
-
function transferFrom2(chainId, asset,
|
|
410
|
-
const {
|
|
411
|
-
if (permit2 == null)
|
|
412
|
-
throw new BundlerErrors.UnexpectedAction("transferFrom2", chainId);
|
|
418
|
+
function transferFrom2(chainId, asset, amount, recipient, skipRevert = false) {
|
|
419
|
+
const { bundler3: { generalAdapter1 }, } = getChainAddresses(chainId);
|
|
413
420
|
recipient ??= generalAdapter1;
|
|
414
421
|
return [
|
|
415
422
|
{
|
|
416
|
-
to:
|
|
423
|
+
to: generalAdapter1,
|
|
417
424
|
data: encodeFunctionData({
|
|
418
|
-
abi:
|
|
419
|
-
functionName: "
|
|
420
|
-
|
|
421
|
-
args: [owner, recipient, amount, asset],
|
|
425
|
+
abi: generalAdapter1Abi,
|
|
426
|
+
functionName: "permit2TransferFrom",
|
|
427
|
+
args: [asset, recipient, amount],
|
|
422
428
|
}),
|
|
423
429
|
value: 0n,
|
|
424
430
|
skipRevert,
|
package/lib/actions.js
CHANGED
|
@@ -65,7 +65,7 @@ const encodeErc20Approval = (token, sender, spender, amount, data) => {
|
|
|
65
65
|
export const encodeOperation = (operation, dataBefore, supportsSignature = true, index = 0) => {
|
|
66
66
|
const { chainId } = dataBefore;
|
|
67
67
|
const deadline = Time.timestamp() + Time.s.from.h(24n);
|
|
68
|
-
const { morpho, bundler3: {
|
|
68
|
+
const { morpho, bundler3: { generalAdapter1 }, permit2, wNative, dai, wstEth, stEth, } = getChainAddresses(chainId);
|
|
69
69
|
const actions = [];
|
|
70
70
|
const requirements = new ActionBundleRequirements();
|
|
71
71
|
let callbackBundle;
|
|
@@ -255,7 +255,6 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
255
255
|
nonce: Number(nonce),
|
|
256
256
|
expiration: Number(expiration),
|
|
257
257
|
},
|
|
258
|
-
spender: bundler3,
|
|
259
258
|
sigDeadline: deadline,
|
|
260
259
|
},
|
|
261
260
|
null,
|
|
@@ -266,12 +265,14 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
266
265
|
requirements.signatures.push({
|
|
267
266
|
action,
|
|
268
267
|
async sign(client, account = client.account) {
|
|
269
|
-
const { details,
|
|
268
|
+
const { details, sigDeadline } = action.args[1];
|
|
270
269
|
let signature = action.args[2];
|
|
271
270
|
if (signature != null)
|
|
272
271
|
return signature; // action is already signed
|
|
273
272
|
const typedData = getPermit2PermitTypedData({
|
|
274
|
-
|
|
273
|
+
// Never permit any other address than the GeneralAdapter1 otherwise
|
|
274
|
+
// the signature can be used independently.
|
|
275
|
+
spender: generalAdapter1,
|
|
275
276
|
allowance: details.amount,
|
|
276
277
|
erc20: details.token,
|
|
277
278
|
nonce: details.nonce,
|
|
@@ -320,11 +321,11 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
|
|
|
320
321
|
break;
|
|
321
322
|
}
|
|
322
323
|
case "Erc20_Transfer2": {
|
|
323
|
-
const { amount,
|
|
324
|
+
const { amount, to } = operation.args;
|
|
324
325
|
if (supportsSignature) {
|
|
325
326
|
actions.push({
|
|
326
327
|
type: "transferFrom2",
|
|
327
|
-
args: [address,
|
|
328
|
+
args: [address, amount, to, operation.skipRevert],
|
|
328
329
|
});
|
|
329
330
|
break;
|
|
330
331
|
}
|
package/lib/operations.js
CHANGED
|
@@ -8,7 +8,7 @@ import { BundlerErrors } from "./errors.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const DEFAULT_SUPPLY_TARGET_UTILIZATION = 905000000000000000n;
|
|
10
10
|
export const populateInputTransfer = ({ address, args: { amount, from } }, data, { hasSimplePermit = false } = {}) => {
|
|
11
|
-
const { bundler3: {
|
|
11
|
+
const { bundler3: { generalAdapter1 }, permit2, } = getChainAddresses(data.chainId);
|
|
12
12
|
// If native token, it is expected to be sent along as call value.
|
|
13
13
|
if (address === NATIVE_ADDRESS)
|
|
14
14
|
return [
|
|
@@ -105,7 +105,7 @@ export const populateInputTransfer = ({ address, args: { amount, from } }, data,
|
|
|
105
105
|
});
|
|
106
106
|
operations.push({
|
|
107
107
|
type: "Erc20_Transfer2",
|
|
108
|
-
sender:
|
|
108
|
+
sender: generalAdapter1,
|
|
109
109
|
address,
|
|
110
110
|
args: {
|
|
111
111
|
amount,
|
package/lib/types/actions.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export interface Permit2PermitSingleDetails {
|
|
|
19
19
|
}
|
|
20
20
|
export interface Permit2PermitSingle {
|
|
21
21
|
details: Permit2PermitSingleDetails;
|
|
22
|
-
spender: Address;
|
|
23
22
|
sigDeadline: bigint;
|
|
24
23
|
}
|
|
25
24
|
export interface ActionArgs {
|
|
@@ -80,7 +79,6 @@ export interface ActionArgs {
|
|
|
80
79
|
];
|
|
81
80
|
transferFrom2: [
|
|
82
81
|
asset: Address,
|
|
83
|
-
owner: Address,
|
|
84
82
|
amount: bigint,
|
|
85
83
|
recipient?: Address,
|
|
86
84
|
skipRevert?: boolean
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/bundler-sdk-viem",
|
|
3
3
|
"description": "Viem-based extension of `@morpho-org/simulation-sdk` that exports utilities to transform simple interactions on Morpho (such as `Blue_Borrow`) and Morpho Vaults (such as `MetaMorpho_Deposit`) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain.",
|
|
4
|
-
"version": "3.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.15",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"viem": "^2.0.0",
|
|
23
23
|
"@morpho-org/blue-sdk": "^2.3.2",
|
|
24
24
|
"@morpho-org/blue-sdk-viem": "^2.2.2",
|
|
25
|
-
"@morpho-org/
|
|
26
|
-
"@morpho-org/
|
|
25
|
+
"@morpho-org/simulation-sdk": "^2.1.4",
|
|
26
|
+
"@morpho-org/morpho-ts": "^2.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@tanstack/query-core": "^5.62.16",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"vitest": "^3.0.5",
|
|
38
38
|
"@morpho-org/blue-sdk": "^2.3.2",
|
|
39
39
|
"@morpho-org/blue-sdk-viem": "^2.2.2",
|
|
40
|
+
"@morpho-org/morpho-test": "^2.2.1",
|
|
40
41
|
"@morpho-org/morpho-ts": "^2.2.0",
|
|
41
42
|
"@morpho-org/simulation-sdk": "^2.1.4",
|
|
42
|
-
"@morpho-org/
|
|
43
|
-
"@morpho-org/test": "^2.1.0",
|
|
43
|
+
"@morpho-org/simulation-sdk-wagmi": "^2.0.5",
|
|
44
44
|
"@morpho-org/test-wagmi": "^2.0.4",
|
|
45
|
-
"@morpho-org/
|
|
45
|
+
"@morpho-org/test": "^2.1.1"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"prepublish": "$npm_execpath build",
|