@dev.sail.money/sailor 0.0.2-13 → 0.0.2-16

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/index.cjs +292 -11
  3. package/packages/sdk/dist/intelligence.d.ts +1 -1
  4. package/packages/sdk/dist/intelligence.js +1 -1
  5. package/packages/sdk/dist/templates/ammLiquidity.d.ts +24 -11
  6. package/packages/sdk/dist/templates/ammLiquidity.d.ts.map +1 -1
  7. package/packages/sdk/dist/templates/ammLiquidity.js +39 -31
  8. package/packages/sdk/dist/templates/ammLiquidity.js.map +1 -1
  9. package/packages/sdk/dist/templates/approveAndCallBatch.d.ts +24 -10
  10. package/packages/sdk/dist/templates/approveAndCallBatch.d.ts.map +1 -1
  11. package/packages/sdk/dist/templates/approveAndCallBatch.js +36 -23
  12. package/packages/sdk/dist/templates/approveAndCallBatch.js.map +1 -1
  13. package/packages/sdk/dist/templates/boundedBorrow.d.ts +19 -9
  14. package/packages/sdk/dist/templates/boundedBorrow.d.ts.map +1 -1
  15. package/packages/sdk/dist/templates/boundedBorrow.js +28 -19
  16. package/packages/sdk/dist/templates/boundedBorrow.js.map +1 -1
  17. package/packages/sdk/dist/templates/boundedSwap.d.ts +19 -9
  18. package/packages/sdk/dist/templates/boundedSwap.d.ts.map +1 -1
  19. package/packages/sdk/dist/templates/boundedSwap.js +30 -20
  20. package/packages/sdk/dist/templates/boundedSwap.js.map +1 -1
  21. package/packages/sdk/dist/templates/defiBundle.d.ts +35 -9
  22. package/packages/sdk/dist/templates/defiBundle.d.ts.map +1 -1
  23. package/packages/sdk/dist/templates/defiBundle.js +84 -22
  24. package/packages/sdk/dist/templates/defiBundle.js.map +1 -1
  25. package/packages/sdk/dist/templates/pendle.d.ts +23 -8
  26. package/packages/sdk/dist/templates/pendle.d.ts.map +1 -1
  27. package/packages/sdk/dist/templates/pendle.js +34 -14
  28. package/packages/sdk/dist/templates/pendle.js.map +1 -1
  29. package/packages/sdk/dist/templates/transferTarget.d.ts +11 -3
  30. package/packages/sdk/dist/templates/transferTarget.d.ts.map +1 -1
  31. package/packages/sdk/dist/templates/transferTarget.js +14 -7
  32. package/packages/sdk/dist/templates/transferTarget.js.map +1 -1
  33. package/packages/sdk/package.json +1 -0
@@ -1,49 +1,62 @@
1
1
  import { decodeAbiParameters, encodeAbiParameters } from "viem";
2
- const ABI = [
3
- { name: "allowedSpenders", type: "address[]" },
4
- { name: "allowedTokens", type: "address[]" },
5
- { name: "maxApprovalValueUsd", type: "uint256" },
6
- { name: "allowInfiniteApprovals", type: "bool" },
2
+ const CONFIG_COMPONENTS = [
3
+ { name: "tokens", type: "address[]" },
4
+ { name: "spenders", type: "address[]" },
5
+ { name: "consumingTargets", type: "address[]" },
6
+ { name: "consumingSelectors", type: "bytes4[]" },
7
+ { name: "maxApprovalAmounts", type: "uint256[]" },
8
+ { name: "requireAmountMatch", type: "bool" },
7
9
  ];
10
+ const ABI = [{ name: "config", type: "tuple", components: CONFIG_COMPONENTS }];
8
11
  export const approveAndCallBatchTemplate = {
9
12
  name: "SharedApproveAndCallBatchPermission",
10
13
  address: "0x0000000000000000000000000000000000000000",
11
14
  encoder: {
12
15
  encode(params) {
13
16
  return encodeAbiParameters(ABI, [
14
- params.allowedSpenders,
15
- params.allowedTokens,
16
- BigInt(Math.round(params.maxApprovalValueUsd)),
17
- params.allowInfiniteApprovals,
17
+ {
18
+ tokens: params.tokens,
19
+ spenders: params.spenders,
20
+ consumingTargets: params.consumingTargets,
21
+ consumingSelectors: params.consumingSelectors,
22
+ maxApprovalAmounts: params.maxApprovalAmounts,
23
+ requireAmountMatch: params.requireAmountMatch,
24
+ },
18
25
  ]);
19
26
  },
20
27
  decode(data) {
21
- const decoded = decodeAbiParameters(ABI, data);
28
+ const [config] = decodeAbiParameters(ABI, data);
22
29
  return {
23
- allowedSpenders: [...decoded[0]],
24
- allowedTokens: [...decoded[1]],
25
- maxApprovalValueUsd: Number(decoded[2]),
26
- allowInfiniteApprovals: decoded[3],
30
+ tokens: [...config.tokens],
31
+ spenders: [...config.spenders],
32
+ consumingTargets: [...config.consumingTargets],
33
+ consumingSelectors: [...config.consumingSelectors],
34
+ maxApprovalAmounts: [...config.maxApprovalAmounts],
35
+ requireAmountMatch: config.requireAmountMatch,
27
36
  };
28
37
  },
29
38
  },
30
39
  explainer: {
31
40
  explain(params) {
32
41
  const warnings = [];
33
- if (params.allowInfiniteApprovals) {
34
- warnings.push("Infinite approvals enabled spenders may pull tokens beyond the per-batch cap");
42
+ if (params.tokens.length !== params.maxApprovalAmounts.length) {
43
+ warnings.push("tokens and maxApprovalAmounts length mismatch configuration will revert on-chain");
35
44
  }
36
- if (params.allowedSpenders.length === 0) {
37
- warnings.push("No spenders specifiedall approvals will be blocked");
45
+ if (params.spenders.length === 0 || params.tokens.length === 0) {
46
+ warnings.push("Empty token or spender allowlist configuration will revert on-chain");
47
+ }
48
+ if (!params.requireAmountMatch) {
49
+ warnings.push("Amount-match disabled — the consuming call may move less than the approved amount");
38
50
  }
39
51
  return {
40
52
  templateName: "SharedApproveAndCallBatchPermission",
41
53
  humanReadable: [
42
- `ERC-20 approvals restricted to ${params.allowedSpenders.length} approved spender(s)`,
43
- `Allowed tokens: ${params.allowedTokens.join(", ")}`,
44
- `Maximum approval value per batch: $${params.maxApprovalValueUsd.toLocaleString()} USD`,
45
- `Infinite approvals: ${params.allowInfiniteApprovals ? "allowed" : "not allowed"}`,
46
- `Approved spenders: ${params.allowedSpenders.join(", ")}`,
54
+ `Approvable tokens (${params.tokens.length}): ${params.tokens.join(", ")}`,
55
+ `Approved spenders: ${params.spenders.join(", ")}`,
56
+ `Consuming targets: ${params.consumingTargets.join(", ")}`,
57
+ `Consuming selectors: ${params.consumingSelectors.join(", ")}`,
58
+ `Per-token approval caps: ${params.maxApprovalAmounts.map((a) => a.toString()).join(", ")}`,
59
+ `Require amount match: ${params.requireAmountMatch ? "yes" : "no"}`,
47
60
  ],
48
61
  warnings,
49
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"approveAndCallBatch.js","sourceRoot":"","sources":["../../src/templates/approveAndCallBatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAehE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE;IAC9C,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC5C,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,SAAS,EAAE;IAChD,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,EAAE;CACxC,CAAC;AAEX,MAAM,CAAC,MAAM,2BAA2B,GAAkD;IACxF,IAAI,EAAE,qCAAqC;IAC3C,OAAO,EAAE,4CAA4C;IAErD,OAAO,EAAE;QACP,MAAM,CAAC,MAAiC;YACtC,OAAO,mBAAmB,CAAC,GAAG,EAAE;gBAC9B,MAAM,CAAC,eAAe;gBACtB,MAAM,CAAC,aAAa;gBACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAC9C,MAAM,CAAC,sBAAsB;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,IAAS;YACd,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAO;gBACL,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAChC,aAAa,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC9B,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACvC,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;aACnC,CAAC;QACJ,CAAC;KACF;IAED,SAAS,EAAE;QACT,OAAO,CAAC,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Params for SharedBoundedBorrowPermission.
4
+ *
5
+ * Matches the on-chain `_applyConfig` decode exactly:
6
+ * abi.decode(params, (address[], address[], uint256, uint256, address, address, uint256))
7
+ * → protocols, assets, maxAmountPerTx, maxLtvBps, collateralOracle, borrowOracle, maxPriceAgeSec
8
+ */
3
9
  export type BoundedBorrowParams = {
4
- /** Maximum borrow amount in USD-equivalent (18-decimal WAD). */
5
- maxBorrowValueUsd: number;
10
+ /** Lending-protocol contract addresses the agent may call (Aave V3 / Morpho / Compound). */
11
+ protocols: Address[];
12
+ /** Allowed borrow asset addresses. */
13
+ assets: Address[];
14
+ /** Maximum borrow amount of a single tx, in the asset's base units. */
15
+ maxAmountPerTx: bigint;
6
16
  /** Maximum resulting LTV in basis points (e.g. 7500 = 75%). */
7
17
  maxLtvBps: number;
8
- /** Allowed collateral token addresses. */
9
- allowedCollateralTokens: Address[];
10
- /** Allowed debt token addresses. */
11
- allowedDebtTokens: Address[];
12
- /** Protocol identifiers allowed (e.g. ["aaveV3", "morpho"]). */
13
- allowedProtocols: string[];
18
+ /** Oracle pricing the collateral asset; `address(0)` disables the LTV check. */
19
+ collateralOracle: Address;
20
+ /** Oracle pricing the borrow asset; `address(0)` disables the LTV check. */
21
+ borrowOracle: Address;
22
+ /** Maximum oracle price age in seconds. Must be > 0 when both oracles are set. */
23
+ maxPriceAgeSec: number;
14
24
  };
15
25
  export declare const boundedBorrowTemplate: PermissionTemplate<BoundedBorrowParams>;
16
26
  //# sourceMappingURL=boundedBorrow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundedBorrow.d.ts","sourceRoot":"","sources":["../../src/templates/boundedBorrow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG;IAChC,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,uBAAuB,EAAE,OAAO,EAAE,CAAC;IACnC,oCAAoC;IACpC,iBAAiB,EAAE,OAAO,EAAE,CAAC;IAC7B,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAUF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,mBAAmB,CAgDzE,CAAC"}
1
+ {"version":3,"file":"boundedBorrow.d.ts","sourceRoot":"","sources":["../../src/templates/boundedBorrow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,4FAA4F;IAC5F,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,sCAAsC;IACtC,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4EAA4E;IAC5E,YAAY,EAAE,OAAO,CAAC;IACtB,kFAAkF;IAClF,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,mBAAmB,CAsDzE,CAAC"}
@@ -1,32 +1,39 @@
1
1
  import { decodeAbiParameters, encodeAbiParameters } from "viem";
2
2
  const ABI = [
3
- { name: "maxBorrowValueUsd", type: "uint256" },
3
+ { name: "protocols", type: "address[]" },
4
+ { name: "assets", type: "address[]" },
5
+ { name: "maxAmountPerTx", type: "uint256" },
4
6
  { name: "maxLtvBps", type: "uint256" },
5
- { name: "allowedCollateralTokens", type: "address[]" },
6
- { name: "allowedDebtTokens", type: "address[]" },
7
- { name: "allowedProtocols", type: "string[]" },
7
+ { name: "collateralOracle", type: "address" },
8
+ { name: "borrowOracle", type: "address" },
9
+ { name: "maxPriceAgeSec", type: "uint256" },
8
10
  ];
11
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
9
12
  export const boundedBorrowTemplate = {
10
13
  name: "SharedBoundedBorrowPermission",
11
14
  address: "0x0000000000000000000000000000000000000000",
12
15
  encoder: {
13
16
  encode(params) {
14
17
  return encodeAbiParameters(ABI, [
15
- BigInt(Math.round(params.maxBorrowValueUsd)),
18
+ params.protocols,
19
+ params.assets,
20
+ params.maxAmountPerTx,
16
21
  BigInt(params.maxLtvBps),
17
- params.allowedCollateralTokens,
18
- params.allowedDebtTokens,
19
- params.allowedProtocols,
22
+ params.collateralOracle,
23
+ params.borrowOracle,
24
+ BigInt(params.maxPriceAgeSec),
20
25
  ]);
21
26
  },
22
27
  decode(data) {
23
28
  const decoded = decodeAbiParameters(ABI, data);
24
29
  return {
25
- maxBorrowValueUsd: Number(decoded[0]),
26
- maxLtvBps: Number(decoded[1]),
27
- allowedCollateralTokens: [...decoded[2]],
28
- allowedDebtTokens: [...decoded[3]],
29
- allowedProtocols: [...decoded[4]],
30
+ protocols: [...decoded[0]],
31
+ assets: [...decoded[1]],
32
+ maxAmountPerTx: decoded[2],
33
+ maxLtvBps: Number(decoded[3]),
34
+ collateralOracle: decoded[4],
35
+ borrowOracle: decoded[5],
36
+ maxPriceAgeSec: Number(decoded[6]),
30
37
  };
31
38
  },
32
39
  },
@@ -36,17 +43,19 @@ export const boundedBorrowTemplate = {
36
43
  if (params.maxLtvBps > 8000) {
37
44
  warnings.push(`High LTV cap: ${params.maxLtvBps / 100}% — liquidation risk is elevated`);
38
45
  }
39
- if (params.maxBorrowValueUsd > 50_000) {
40
- warnings.push(`High borrow limit: $${params.maxBorrowValueUsd.toLocaleString()}`);
46
+ if (params.collateralOracle === ZERO_ADDRESS || params.borrowOracle === ZERO_ADDRESS) {
47
+ warnings.push("LTV not enforced — both collateral and borrow oracles must be set");
41
48
  }
42
49
  return {
43
50
  templateName: "SharedBoundedBorrowPermission",
44
51
  humanReadable: [
45
- `Maximum borrow size: $${params.maxBorrowValueUsd.toLocaleString()} USD`,
52
+ `Maximum borrow per tx: ${params.maxAmountPerTx.toString()} (asset base units)`,
46
53
  `Maximum LTV: ${params.maxLtvBps / 100}%`,
47
- `Allowed collateral tokens: ${params.allowedCollateralTokens.join(", ")}`,
48
- `Allowed debt tokens: ${params.allowedDebtTokens.join(", ")}`,
49
- `Allowed protocols: ${params.allowedProtocols.join(", ")}`,
54
+ `Allowed protocols: ${params.protocols.join(", ")}`,
55
+ `Allowed assets: ${params.assets.join(", ")}`,
56
+ `Collateral oracle: ${params.collateralOracle}`,
57
+ `Borrow oracle: ${params.borrowOracle}`,
58
+ `Max oracle price age: ${params.maxPriceAgeSec}s`,
50
59
  ],
51
60
  warnings,
52
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"boundedBorrow.js","sourceRoot":"","sources":["../../src/templates/boundedBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAiBhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC9C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,WAAW,EAAE;IACtD,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,WAAW,EAAE;IAChD,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE;CACtC,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAA4C;IAC5E,IAAI,EAAE,+BAA+B;IACrC,OAAO,EAAE,4CAA4C;IAErD,OAAO,EAAE;QACP,MAAM,CAAC,MAA2B;YAChC,OAAO,mBAAmB,CAAC,GAAG,EAAE;gBAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,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,CAAC,EAAE;oBACnD,mBAAmB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC7C,sBAAsB,MAAM,CAAC,gBAAgB,EAAE;oBAC/C,kBAAkB,MAAM,CAAC,YAAY,EAAE;oBACvC,yBAAyB,MAAM,CAAC,cAAc,GAAG;iBAClD;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -1,16 +1,26 @@
1
1
  import type { Address, PermissionTemplate } from "../types.js";
2
- /** Params for SharedBoundedSwapPermission. */
2
+ /**
3
+ * Params for SharedBoundedSwapPermission.
4
+ *
5
+ * Matches the on-chain `_applyConfig` decode exactly:
6
+ * abi.decode(params, (address[], address[], uint256, uint256, address, uint256))
7
+ * → routers, tokensIn, tokensOut, maxAmountPerTx, maxSlippageBps, priceOracle, maxPriceAgeSec
8
+ */
3
9
  export type BoundedSwapParams = {
4
- /** Maximum value of a single swap in USD-equivalent (18-decimal WAD). */
5
- maxSwapValueUsd: number;
6
- /** Maximum allowed slippage in basis points (e.g. 50 = 0.5%). */
7
- maxSlippageBps: number;
10
+ /** Router/aggregator addresses the agent may call (e.g. Uniswap V3 SwapRouter). */
11
+ routers: Address[];
8
12
  /** Token addresses allowed as swap input. */
9
- allowedInputTokens: Address[];
13
+ tokensIn: Address[];
10
14
  /** Token addresses allowed as swap output. */
11
- allowedOutputTokens: Address[];
12
- /** Protocol identifiers allowed (e.g. ["uniswapV3", "curve"]). */
13
- allowedProtocols: string[];
15
+ tokensOut: Address[];
16
+ /** Maximum input amount of a single swap, in the input token's base units. */
17
+ maxAmountPerTx: bigint;
18
+ /** Maximum allowed slippage in basis points (e.g. 50 = 0.5%). */
19
+ maxSlippageBps: number;
20
+ /** Price oracle used for the slippage check; `address(0)` disables it. */
21
+ priceOracle: Address;
22
+ /** Maximum oracle price age in seconds. Must be > 0 when `priceOracle` is set. */
23
+ maxPriceAgeSec: number;
14
24
  };
15
25
  export declare const boundedSwapTemplate: PermissionTemplate<BoundedSwapParams>;
16
26
  //# sourceMappingURL=boundedSwap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundedSwap.d.ts","sourceRoot":"","sources":["../../src/templates/boundedSwap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,kBAAkB,EAAE,OAAO,EAAE,CAAC;IAC9B,8CAA8C;IAC9C,mBAAmB,EAAE,OAAO,EAAE,CAAC;IAC/B,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAUF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,iBAAiB,CAgDrE,CAAC"}
1
+ {"version":3,"file":"boundedSwap.d.ts","sourceRoot":"","sources":["../../src/templates/boundedSwap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,mFAAmF;IACnF,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,8CAA8C;IAC9C,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,WAAW,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,iBAAiB,CAuDrE,CAAC"}
@@ -1,52 +1,62 @@
1
1
  import { decodeAbiParameters, encodeAbiParameters } from "viem";
2
2
  const ABI = [
3
- { name: "maxSwapValueUsd", type: "uint256" },
3
+ { name: "routers", type: "address[]" },
4
+ { name: "tokensIn", type: "address[]" },
5
+ { name: "tokensOut", type: "address[]" },
6
+ { name: "maxAmountPerTx", type: "uint256" },
4
7
  { name: "maxSlippageBps", type: "uint256" },
5
- { name: "allowedInputTokens", type: "address[]" },
6
- { name: "allowedOutputTokens", type: "address[]" },
7
- { name: "allowedProtocols", type: "string[]" },
8
+ { name: "priceOracle", type: "address" },
9
+ { name: "maxPriceAgeSec", type: "uint256" },
8
10
  ];
11
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
9
12
  export const boundedSwapTemplate = {
10
13
  name: "SharedBoundedSwapPermission",
11
14
  address: "0x0000000000000000000000000000000000000000",
12
15
  encoder: {
13
16
  encode(params) {
14
17
  return encodeAbiParameters(ABI, [
15
- BigInt(Math.round(params.maxSwapValueUsd)),
18
+ params.routers,
19
+ params.tokensIn,
20
+ params.tokensOut,
21
+ params.maxAmountPerTx,
16
22
  BigInt(params.maxSlippageBps),
17
- params.allowedInputTokens,
18
- params.allowedOutputTokens,
19
- params.allowedProtocols,
23
+ params.priceOracle,
24
+ BigInt(params.maxPriceAgeSec),
20
25
  ]);
21
26
  },
22
27
  decode(data) {
23
28
  const decoded = decodeAbiParameters(ABI, data);
24
29
  return {
25
- maxSwapValueUsd: Number(decoded[0]),
26
- maxSlippageBps: Number(decoded[1]),
27
- allowedInputTokens: [...decoded[2]],
28
- allowedOutputTokens: [...decoded[3]],
29
- allowedProtocols: [...decoded[4]],
30
+ routers: [...decoded[0]],
31
+ tokensIn: [...decoded[1]],
32
+ tokensOut: [...decoded[2]],
33
+ maxAmountPerTx: decoded[3],
34
+ maxSlippageBps: Number(decoded[4]),
35
+ priceOracle: decoded[5],
36
+ maxPriceAgeSec: Number(decoded[6]),
30
37
  };
31
38
  },
32
39
  },
33
40
  explainer: {
34
41
  explain(params) {
35
42
  const warnings = [];
36
- if (params.maxSwapValueUsd > 10_000) {
37
- warnings.push(`High per-swap limit: $${params.maxSwapValueUsd.toLocaleString()}`);
38
- }
39
43
  if (params.maxSlippageBps > 100) {
40
44
  warnings.push(`High slippage tolerance: ${params.maxSlippageBps / 100}%`);
41
45
  }
46
+ if (params.priceOracle === ZERO_ADDRESS) {
47
+ warnings.push("No price oracle configured — swaps are not checked against a reference price");
48
+ }
42
49
  return {
43
50
  templateName: "SharedBoundedSwapPermission",
44
51
  humanReadable: [
45
- `Maximum swap size: $${params.maxSwapValueUsd.toLocaleString()} USD per transaction`,
52
+ `Maximum input per swap: ${params.maxAmountPerTx.toString()} (input-token base units)`,
46
53
  `Maximum slippage: ${params.maxSlippageBps / 100}%`,
47
- `Allowed input tokens: ${params.allowedInputTokens.join(", ")}`,
48
- `Allowed output tokens: ${params.allowedOutputTokens.join(", ")}`,
49
- `Allowed protocols: ${params.allowedProtocols.join(", ")}`,
54
+ `Allowed routers: ${params.routers.join(", ")}`,
55
+ `Allowed input tokens: ${params.tokensIn.join(", ")}`,
56
+ `Allowed output tokens: ${params.tokensOut.join(", ")}`,
57
+ params.priceOracle === ZERO_ADDRESS
58
+ ? "Price oracle: none"
59
+ : `Price oracle: ${params.priceOracle} (max age ${params.maxPriceAgeSec}s)`,
50
60
  ],
51
61
  warnings,
52
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"boundedSwap.js","sourceRoot":"","sources":["../../src/templates/boundedSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAiBhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC5C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,WAAW,EAAE;I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,KAAK,YAAY,EAAE,CAAC;gBACxC,QAAQ,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;YAChG,CAAC;YACD,OAAO;gBACL,YAAY,EAAE,6BAA6B;gBAC3C,aAAa,EAAE;oBACb,2BAA2B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,2BAA2B;oBACtF,qBAAqB,MAAM,CAAC,cAAc,GAAG,GAAG,GAAG;oBACnD,oBAAoB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC/C,yBAAyB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACrD,0BAA0B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACvD,MAAM,CAAC,WAAW,KAAK,YAAY;wBACjC,CAAC,CAAC,oBAAoB;wBACtB,CAAC,CAAC,iBAAiB,MAAM,CAAC,WAAW,aAAa,MAAM,CAAC,cAAc,IAAI;iBAC9E;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -1,14 +1,40 @@
1
1
  import type { Address, PermissionTemplate } from "../types.js";
2
- /** Params for SharedDefiBundlePermission. */
2
+ /** Swap sub-domain config — mirrors the contract's `SwapConfig` struct. */
3
+ export type DefiBundleSwapConfig = {
4
+ routers: Address[];
5
+ tokensIn: Address[];
6
+ tokensOut: Address[];
7
+ maxAmountPerTx: bigint;
8
+ maxSlippageBps: number;
9
+ priceOracle: Address;
10
+ maxPriceAgeSec: number;
11
+ };
12
+ /** Borrow sub-domain config — mirrors the contract's `BorrowConfig` struct. */
13
+ export type DefiBundleBorrowConfig = {
14
+ protocols: Address[];
15
+ assets: Address[];
16
+ maxAmountPerTx: bigint;
17
+ maxLtvBps: number;
18
+ collateralOracle: Address;
19
+ borrowOracle: Address;
20
+ maxPriceAgeSec: number;
21
+ };
22
+ /** Transfer sub-domain config — mirrors the contract's `TransferConfig` struct. */
23
+ export type DefiBundleTransferConfig = {
24
+ recipients: Address[];
25
+ tokens: Address[];
26
+ maxAmountPerTx: bigint;
27
+ };
28
+ /**
29
+ * Params for SharedDeFiBundlePermission.
30
+ *
31
+ * Matches the on-chain `_applyConfig` decode exactly:
32
+ * abi.decode(params, (SwapConfig, BorrowConfig, TransferConfig))
33
+ */
3
34
  export type DefiBundleParams = {
4
- /** Maximum total value of the bundle in USD-equivalent (18-decimal WAD). */
5
- maxBundleValueUsd: number;
6
- /** Allowed protocol identifiers that may appear in the bundle. */
7
- allowedProtocols: string[];
8
- /** Allowed action types within the bundle (e.g. ["swap", "deposit", "borrow"]). */
9
- allowedActions: string[];
10
- /** Allowed token addresses that the bundle may interact with. */
11
- allowedTokens: Address[];
35
+ swap: DefiBundleSwapConfig;
36
+ borrow: DefiBundleBorrowConfig;
37
+ transfer: DefiBundleTransferConfig;
12
38
  };
13
39
  export declare const defiBundleTemplate: PermissionTemplate<DefiBundleParams>;
14
40
  //# sourceMappingURL=defiBundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defiBundle.d.ts","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,6CAA6C;AAC7C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4EAA4E;IAC5E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mFAAmF;IACnF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iEAAiE;IACjE,aAAa,EAAE,OAAO,EAAE,CAAC;CAC1B,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,gBAAgB,CA6CnE,CAAC"}
1
+ {"version":3,"file":"defiBundle.d.ts","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAkCF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,gBAAgB,CAqFnE,CAAC"}
@@ -1,48 +1,110 @@
1
1
  import { decodeAbiParameters, encodeAbiParameters } from "viem";
2
+ const SWAP_COMPONENTS = [
3
+ { name: "routers", type: "address[]" },
4
+ { name: "tokensIn", type: "address[]" },
5
+ { name: "tokensOut", type: "address[]" },
6
+ { name: "maxAmountPerTx", type: "uint256" },
7
+ { name: "maxSlippageBps", type: "uint256" },
8
+ { name: "priceOracle", type: "address" },
9
+ { name: "maxPriceAgeSec", type: "uint256" },
10
+ ];
11
+ const BORROW_COMPONENTS = [
12
+ { name: "protocols", type: "address[]" },
13
+ { name: "assets", type: "address[]" },
14
+ { name: "maxAmountPerTx", type: "uint256" },
15
+ { name: "maxLtvBps", type: "uint256" },
16
+ { name: "collateralOracle", type: "address" },
17
+ { name: "borrowOracle", type: "address" },
18
+ { name: "maxPriceAgeSec", type: "uint256" },
19
+ ];
20
+ const TRANSFER_COMPONENTS = [
21
+ { name: "recipients", type: "address[]" },
22
+ { name: "tokens", type: "address[]" },
23
+ { name: "maxAmountPerTx", type: "uint256" },
24
+ ];
2
25
  const ABI = [
3
- { name: "maxBundleValueUsd", type: "uint256" },
4
- { name: "allowedProtocols", type: "string[]" },
5
- { name: "allowedActions", type: "string[]" },
6
- { name: "allowedTokens", type: "address[]" },
26
+ { name: "swap", type: "tuple", components: SWAP_COMPONENTS },
27
+ { name: "borrow", type: "tuple", components: BORROW_COMPONENTS },
28
+ { name: "transfer", type: "tuple", components: TRANSFER_COMPONENTS },
7
29
  ];
8
30
  export const defiBundleTemplate = {
9
- name: "SharedDefiBundlePermission",
31
+ name: "SharedDeFiBundlePermission",
10
32
  address: "0x0000000000000000000000000000000000000000",
11
33
  encoder: {
12
34
  encode(params) {
13
35
  return encodeAbiParameters(ABI, [
14
- BigInt(Math.round(params.maxBundleValueUsd)),
15
- params.allowedProtocols,
16
- params.allowedActions,
17
- params.allowedTokens,
36
+ {
37
+ routers: params.swap.routers,
38
+ tokensIn: params.swap.tokensIn,
39
+ tokensOut: params.swap.tokensOut,
40
+ maxAmountPerTx: params.swap.maxAmountPerTx,
41
+ maxSlippageBps: BigInt(params.swap.maxSlippageBps),
42
+ priceOracle: params.swap.priceOracle,
43
+ maxPriceAgeSec: BigInt(params.swap.maxPriceAgeSec),
44
+ },
45
+ {
46
+ protocols: params.borrow.protocols,
47
+ assets: params.borrow.assets,
48
+ maxAmountPerTx: params.borrow.maxAmountPerTx,
49
+ maxLtvBps: BigInt(params.borrow.maxLtvBps),
50
+ collateralOracle: params.borrow.collateralOracle,
51
+ borrowOracle: params.borrow.borrowOracle,
52
+ maxPriceAgeSec: BigInt(params.borrow.maxPriceAgeSec),
53
+ },
54
+ {
55
+ recipients: params.transfer.recipients,
56
+ tokens: params.transfer.tokens,
57
+ maxAmountPerTx: params.transfer.maxAmountPerTx,
58
+ },
18
59
  ]);
19
60
  },
20
61
  decode(data) {
21
- const decoded = decodeAbiParameters(ABI, data);
62
+ const [swap, borrow, transfer] = decodeAbiParameters(ABI, data);
22
63
  return {
23
- maxBundleValueUsd: Number(decoded[0]),
24
- allowedProtocols: [...decoded[1]],
25
- allowedActions: [...decoded[2]],
26
- allowedTokens: [...decoded[3]],
64
+ swap: {
65
+ routers: [...swap.routers],
66
+ tokensIn: [...swap.tokensIn],
67
+ tokensOut: [...swap.tokensOut],
68
+ maxAmountPerTx: swap.maxAmountPerTx,
69
+ maxSlippageBps: Number(swap.maxSlippageBps),
70
+ priceOracle: swap.priceOracle,
71
+ maxPriceAgeSec: Number(swap.maxPriceAgeSec),
72
+ },
73
+ borrow: {
74
+ protocols: [...borrow.protocols],
75
+ assets: [...borrow.assets],
76
+ maxAmountPerTx: borrow.maxAmountPerTx,
77
+ maxLtvBps: Number(borrow.maxLtvBps),
78
+ collateralOracle: borrow.collateralOracle,
79
+ borrowOracle: borrow.borrowOracle,
80
+ maxPriceAgeSec: Number(borrow.maxPriceAgeSec),
81
+ },
82
+ transfer: {
83
+ recipients: [...transfer.recipients],
84
+ tokens: [...transfer.tokens],
85
+ maxAmountPerTx: transfer.maxAmountPerTx,
86
+ },
27
87
  };
28
88
  },
29
89
  },
30
90
  explainer: {
31
91
  explain(params) {
32
92
  const warnings = [];
33
- if (params.maxBundleValueUsd > 100_000) {
34
- warnings.push(`Large bundle value cap: $${params.maxBundleValueUsd.toLocaleString()}`);
93
+ if (params.swap.maxSlippageBps > 100) {
94
+ warnings.push(`High swap slippage tolerance: ${params.swap.maxSlippageBps / 100}%`);
95
+ }
96
+ if (params.borrow.maxLtvBps > 8000) {
97
+ warnings.push(`High borrow LTV cap: ${params.borrow.maxLtvBps / 100}%`);
35
98
  }
36
- if (params.allowedActions.includes("borrow") && params.allowedActions.includes("swap")) {
99
+ if (params.borrow.protocols.length > 0 && params.swap.routers.length > 0) {
37
100
  warnings.push("Bundle permits both borrowing and swapping — review leverage exposure");
38
101
  }
39
102
  return {
40
- templateName: "SharedDefiBundlePermission",
103
+ templateName: "SharedDeFiBundlePermission",
41
104
  humanReadable: [
42
- `Maximum bundle value: $${params.maxBundleValueUsd.toLocaleString()} USD`,
43
- `Allowed protocols: ${params.allowedProtocols.join(", ")}`,
44
- `Allowed actions: ${params.allowedActions.join(", ")}`,
45
- `Allowed tokens: ${params.allowedTokens.join(", ")}`,
105
+ `Swap routers: ${params.swap.routers.join(", ") || "none"}; max/tx: ${params.swap.maxAmountPerTx.toString()}; slippage: ${params.swap.maxSlippageBps / 100}%`,
106
+ `Borrow protocols: ${params.borrow.protocols.join(", ") || "none"}; max/tx: ${params.borrow.maxAmountPerTx.toString()}; LTV: ${params.borrow.maxLtvBps / 100}%`,
107
+ `Transfer — recipients: ${params.transfer.recipients.join(", ") || "none"}; max/tx: ${params.transfer.maxAmountPerTx.toString()}`,
46
108
  ],
47
109
  warnings,
48
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"defiBundle.js","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAehE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC9C,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE;IAC9C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE;IAC5C,EAAE,IAAI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