@dev.sail.money/sailor 0.0.2-15 → 0.0.2-17

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 (39) hide show
  1. package/examples/permissions/BoundedSwap_UniswapV3_Base.sol +4 -3
  2. package/examples/permissions/BoundedSwap_UniswapV4_Unichain.sol +4 -0
  3. package/package.json +1 -1
  4. package/packages/cli/dist/index.cjs +401 -44
  5. package/packages/sdk/dist/intelligence.d.ts +1 -1
  6. package/packages/sdk/dist/intelligence.js +1 -1
  7. package/packages/sdk/dist/templates/ammLiquidity.d.ts +24 -11
  8. package/packages/sdk/dist/templates/ammLiquidity.d.ts.map +1 -1
  9. package/packages/sdk/dist/templates/ammLiquidity.js +39 -31
  10. package/packages/sdk/dist/templates/ammLiquidity.js.map +1 -1
  11. package/packages/sdk/dist/templates/approveAndCallBatch.d.ts +24 -10
  12. package/packages/sdk/dist/templates/approveAndCallBatch.d.ts.map +1 -1
  13. package/packages/sdk/dist/templates/approveAndCallBatch.js +36 -23
  14. package/packages/sdk/dist/templates/approveAndCallBatch.js.map +1 -1
  15. package/packages/sdk/dist/templates/boundedBorrow.d.ts +19 -9
  16. package/packages/sdk/dist/templates/boundedBorrow.d.ts.map +1 -1
  17. package/packages/sdk/dist/templates/boundedBorrow.js +28 -19
  18. package/packages/sdk/dist/templates/boundedBorrow.js.map +1 -1
  19. package/packages/sdk/dist/templates/boundedSwap.d.ts +19 -9
  20. package/packages/sdk/dist/templates/boundedSwap.d.ts.map +1 -1
  21. package/packages/sdk/dist/templates/boundedSwap.js +30 -20
  22. package/packages/sdk/dist/templates/boundedSwap.js.map +1 -1
  23. package/packages/sdk/dist/templates/defiBundle.d.ts +35 -9
  24. package/packages/sdk/dist/templates/defiBundle.d.ts.map +1 -1
  25. package/packages/sdk/dist/templates/defiBundle.js +84 -22
  26. package/packages/sdk/dist/templates/defiBundle.js.map +1 -1
  27. package/packages/sdk/dist/templates/pendle.d.ts +23 -8
  28. package/packages/sdk/dist/templates/pendle.d.ts.map +1 -1
  29. package/packages/sdk/dist/templates/pendle.js +34 -14
  30. package/packages/sdk/dist/templates/pendle.js.map +1 -1
  31. package/packages/sdk/dist/templates/transferTarget.d.ts +11 -3
  32. package/packages/sdk/dist/templates/transferTarget.d.ts.map +1 -1
  33. package/packages/sdk/dist/templates/transferTarget.js +14 -7
  34. package/packages/sdk/dist/templates/transferTarget.js.map +1 -1
  35. package/packages/sdk/package.json +1 -0
  36. package/templates/default/.github/workflows/agent-tick.yml +8 -7
  37. package/templates/default/AGENTS.md +12 -1
  38. package/templates/default/src/config.ts +1 -11
  39. package/templates/default/tsconfig.json +7 -1
@@ -5,7 +5,7 @@
5
5
  * Do not edit manually — run `pnpm build` to regenerate.
6
6
  *
7
7
  * Spec version : 1.2.0
8
- * Generated at : 2026-06-06T10:26:29.567Z
8
+ * Generated at : 2026-06-06T21:23:50.341Z
9
9
  */
10
10
  export declare const SAIL_INTELLIGENCE_BASE_URL = "https://api.sail.money";
11
11
  export declare const SAIL_INTELLIGENCE_DOCS_URL = "https://api.sail.money/docs";
@@ -5,7 +5,7 @@
5
5
  * Do not edit manually — run `pnpm build` to regenerate.
6
6
  *
7
7
  * Spec version : 1.2.0
8
- * Generated at : 2026-06-06T10:26:29.567Z
8
+ * Generated at : 2026-06-06T21:23:50.341Z
9
9
  */
10
10
  export const SAIL_INTELLIGENCE_BASE_URL = "https://api.sail.money";
11
11
  export const SAIL_INTELLIGENCE_DOCS_URL = "https://api.sail.money/docs";
@@ -1,16 +1,29 @@
1
1
  import type { Address, PermissionTemplate } from "../types.js";
2
- /** Params for SharedAmmLiquidityPermission. */
2
+ /**
3
+ * Params for SharedAMMLiquidityPermission.
4
+ *
5
+ * Matches the on-chain `_applyConfig` decode exactly:
6
+ * abi.decode(params, (address[], address[], uint128, bool, bool, bool, bool, bool))
7
+ * → allowedTargets, allowedTokens, maxAmountPerTokenPerTx,
8
+ * allowMint, allowIncrease, allowDecrease, allowCollect, allowBurn
9
+ */
3
10
  export type AmmLiquidityParams = {
4
- /** Maximum total liquidity value in USD-equivalent (18-decimal WAD). */
5
- maxLiquidityValueUsd: number;
6
- /** Pool addresses the agent may LP into. */
7
- allowedPools: Address[];
8
- /** Protocol identifiers allowed (e.g. ["uniswapV3", "curveV2", "balancer"]). */
9
- allowedProtocols: string[];
10
- /** Whether single-sided deposits are permitted. */
11
- allowSingleSided: boolean;
12
- /** Maximum price range width in basis points (Uni V3 only). */
13
- maxRangeBps?: number;
11
+ /** Position-manager / router addresses the agent may call (UniV3 NPM, Aerodrome, …). */
12
+ allowedTargets: Address[];
13
+ /** Token addresses the agent may provide as liquidity. */
14
+ allowedTokens: Address[];
15
+ /** Maximum amount of any single token per tx, in that token's base units (uint128). */
16
+ maxAmountPerTokenPerTx: bigint;
17
+ /** Allow mint / open-position (and Aerodrome add-liquidity). */
18
+ allowMint: boolean;
19
+ /** Allow increaseLiquidity. */
20
+ allowIncrease: boolean;
21
+ /** Allow decreaseLiquidity (and Aerodrome remove-liquidity). */
22
+ allowDecrease: boolean;
23
+ /** Allow collect (fee withdrawal). */
24
+ allowCollect: boolean;
25
+ /** Allow burn (close position NFT). */
26
+ allowBurn: boolean;
14
27
  };
15
28
  export declare const ammLiquidityTemplate: PermissionTemplate<AmmLiquidityParams>;
16
29
  //# sourceMappingURL=ammLiquidity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ammLiquidity.d.ts","sourceRoot":"","sources":["../../src/templates/ammLiquidity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,+CAA+C;AAC/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wEAAwE;IACxE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,gFAAgF;IAChF,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mDAAmD;IACnD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAUF,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,kBAAkB,CAuDvE,CAAC"}
1
+ {"version":3,"file":"ammLiquidity.d.ts","sourceRoot":"","sources":["../../src/templates/ammLiquidity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B,0DAA0D;IAC1D,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,uFAAuF;IACvF,sBAAsB,EAAE,MAAM,CAAC;IAC/B,gEAAgE;IAChE,SAAS,EAAE,OAAO,CAAC;IACnB,+BAA+B;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,aAAa,EAAE,OAAO,CAAC;IACvB,sCAAsC;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAaF,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,kBAAkB,CAyDvE,CAAC"}
@@ -1,56 +1,64 @@
1
1
  import { decodeAbiParameters, encodeAbiParameters } from "viem";
2
2
  const ABI = [
3
- { name: "maxLiquidityValueUsd", type: "uint256" },
4
- { name: "allowedPools", type: "address[]" },
5
- { name: "allowedProtocols", type: "string[]" },
6
- { name: "allowSingleSided", type: "bool" },
7
- { name: "maxRangeBps", type: "uint256" },
3
+ { name: "allowedTargets", type: "address[]" },
4
+ { name: "allowedTokens", type: "address[]" },
5
+ { name: "maxAmountPerTokenPerTx", type: "uint128" },
6
+ { name: "allowMint", type: "bool" },
7
+ { name: "allowIncrease", type: "bool" },
8
+ { name: "allowDecrease", type: "bool" },
9
+ { name: "allowCollect", type: "bool" },
10
+ { name: "allowBurn", type: "bool" },
8
11
  ];
9
12
  export const ammLiquidityTemplate = {
10
- name: "SharedAmmLiquidityPermission",
13
+ name: "SharedAMMLiquidityPermission",
11
14
  address: "0x0000000000000000000000000000000000000000",
12
15
  encoder: {
13
16
  encode(params) {
14
17
  return encodeAbiParameters(ABI, [
15
- BigInt(Math.round(params.maxLiquidityValueUsd)),
16
- params.allowedPools,
17
- params.allowedProtocols,
18
- params.allowSingleSided,
19
- BigInt(params.maxRangeBps ?? 0),
18
+ params.allowedTargets,
19
+ params.allowedTokens,
20
+ params.maxAmountPerTokenPerTx,
21
+ params.allowMint,
22
+ params.allowIncrease,
23
+ params.allowDecrease,
24
+ params.allowCollect,
25
+ params.allowBurn,
20
26
  ]);
21
27
  },
22
28
  decode(data) {
23
29
  const decoded = decodeAbiParameters(ABI, data);
24
- const maxRangeBps = Number(decoded[4]);
25
30
  return {
26
- maxLiquidityValueUsd: Number(decoded[0]),
27
- allowedPools: [...decoded[1]],
28
- allowedProtocols: [...decoded[2]],
29
- allowSingleSided: decoded[3],
30
- ...(maxRangeBps > 0 ? { maxRangeBps } : {}),
31
+ allowedTargets: [...decoded[0]],
32
+ allowedTokens: [...decoded[1]],
33
+ maxAmountPerTokenPerTx: decoded[2],
34
+ allowMint: decoded[3],
35
+ allowIncrease: decoded[4],
36
+ allowDecrease: decoded[5],
37
+ allowCollect: decoded[6],
38
+ allowBurn: decoded[7],
31
39
  };
32
40
  },
33
41
  },
34
42
  explainer: {
35
43
  explain(params) {
36
44
  const warnings = [];
37
- if (params.allowSingleSided) {
38
- warnings.push("Single-sided deposits permittedmay result in immediate impermanent loss");
45
+ if (params.allowedTargets.length === 0) {
46
+ warnings.push("No targets specifiedall liquidity operations will be blocked");
39
47
  }
40
- if (params.maxRangeBps !== undefined && params.maxRangeBps > 5000) {
41
- warnings.push(`Wide price range allowed: ±${params.maxRangeBps / 100}%`);
42
- }
43
- const rangeNote = params.maxRangeBps !== undefined
44
- ? `Maximum price range (Uni V3): ±${params.maxRangeBps / 100}%`
45
- : null;
48
+ const ops = [
49
+ params.allowMint && "mint",
50
+ params.allowIncrease && "increase",
51
+ params.allowDecrease && "decrease",
52
+ params.allowCollect && "collect",
53
+ params.allowBurn && "burn",
54
+ ].filter(Boolean);
46
55
  return {
47
- templateName: "SharedAmmLiquidityPermission",
56
+ templateName: "SharedAMMLiquidityPermission",
48
57
  humanReadable: [
49
- `Maximum liquidity value: $${params.maxLiquidityValueUsd.toLocaleString()} USD`,
50
- `Allowed protocols: ${params.allowedProtocols.join(", ")}`,
51
- `Allowed pools (${params.allowedPools.length}): ${params.allowedPools.join(", ")}`,
52
- `Single-sided deposits: ${params.allowSingleSided ? "allowed" : "not allowed"}`,
53
- ...(rangeNote ? [rangeNote] : []),
58
+ `Maximum amount per token per tx: ${params.maxAmountPerTokenPerTx.toString()} (base units)`,
59
+ `Allowed targets (${params.allowedTargets.length}): ${params.allowedTargets.join(", ")}`,
60
+ `Allowed tokens: ${params.allowedTokens.join(", ")}`,
61
+ `Enabled operations: ${ops.length ? ops.join(", ") : "none"}`,
54
62
  ],
55
63
  warnings,
56
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ammLiquidity.js","sourceRoot":"","sources":["../../src/templates/ammLiquidity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAiBhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,SAAS,EAAE;IACjD,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE;IAC3C,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE;IAC9C,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE;IAC1C,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;CAChC,CAAC;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,GAAa,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvC,QAAQ,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;YACnF,CAAC;YACD,MAAM,GAAG,GAAG;gBACV,MAAM,CAAC,SAAS,IAAI,MAAM;gBAC1B,MAAM,CAAC,aAAa,IAAI,UAAU;gBAClC,MAAM,CAAC,aAAa,IAAI,UAAU;gBAClC,MAAM,CAAC,YAAY,IAAI,SAAS;gBAChC,MAAM,CAAC,SAAS,IAAI,MAAM;aAC3B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClB,OAAO;gBACL,YAAY,EAAE,8BAA8B;gBAC5C,aAAa,EAAE;oBACb,oCAAoC,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,eAAe;oBAC3F,oBAAoB,MAAM,CAAC,cAAc,CAAC,MAAM,MAAM,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACxF,mBAAmB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACpD,uBAAuB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;iBAC9D;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -1,14 +1,28 @@
1
- import type { Address, PermissionTemplate } from "../types.js";
2
- /** Params for SharedApproveAndCallBatchPermission. */
1
+ import type { Address, Hex, PermissionTemplate } from "../types.js";
2
+ /**
3
+ * Params for SharedApproveAndCallBatchPermission.
4
+ *
5
+ * Matches the on-chain `_applyConfig` decode exactly:
6
+ * abi.decode(params, (Config))
7
+ * where Config is the tuple
8
+ * (address[] tokens, address[] spenders, address[] consumingTargets,
9
+ * bytes4[] consumingSelectors, uint256[] maxApprovalAmounts, bool requireAmountMatch)
10
+ *
11
+ * Note: the contract encodes a SINGLE struct, so the blob is one top-level tuple.
12
+ */
3
13
  export type ApproveAndCallBatchParams = {
4
- /** Spender addresses that may receive ERC-20 approvals. */
5
- allowedSpenders: Address[];
6
- /** Token addresses for which approvals may be granted. */
7
- allowedTokens: Address[];
8
- /** Maximum total approval value per batch in USD-equivalent (18-decimal WAD). */
9
- maxApprovalValueUsd: number;
10
- /** Whether infinite (max-uint) approvals are permitted. */
11
- allowInfiniteApprovals: boolean;
14
+ /** Allowlisted ERC-20 tokens that may be approved. Index-parallel with `maxApprovalAmounts`. */
15
+ tokens: Address[];
16
+ /** Allowlisted spenders that may receive the allowance. */
17
+ spenders: Address[];
18
+ /** Allowlisted consuming-call targets (often the same as spenders). */
19
+ consumingTargets: Address[];
20
+ /** Allowlisted selectors for the consuming call (4-byte hex, e.g. "0x095ea7b3"). */
21
+ consumingSelectors: Hex[];
22
+ /** Max approve amount per token, index-parallel with `tokens`. */
23
+ maxApprovalAmounts: bigint[];
24
+ /** When true, the consuming call's leading uint256 arg must equal the approved amount. */
25
+ requireAmountMatch: boolean;
12
26
  };
13
27
  export declare const approveAndCallBatchTemplate: PermissionTemplate<ApproveAndCallBatchParams>;
14
28
  //# sourceMappingURL=approveAndCallBatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"approveAndCallBatch.d.ts","sourceRoot":"","sources":["../../src/templates/approveAndCallBatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,sDAAsD;AACtD,MAAM,MAAM,yBAAyB,GAAG;IACtC,2DAA2D;IAC3D,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,0DAA0D;IAC1D,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,sBAAsB,EAAE,OAAO,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,2BAA2B,EAAE,kBAAkB,CAAC,yBAAyB,CAgDrF,CAAC"}
1
+ {"version":3,"file":"approveAndCallBatch.d.ts","sourceRoot":"","sources":["../../src/templates/approveAndCallBatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAsB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,gGAAgG;IAChG,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,2DAA2D;IAC3D,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,uEAAuE;IACvE,gBAAgB,EAAE,OAAO,EAAE,CAAC;IAC5B,oFAAoF;IACpF,kBAAkB,EAAE,GAAG,EAAE,CAAC;IAC1B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,0FAA0F;IAC1F,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAaF,eAAO,MAAM,2BAA2B,EAAE,kBAAkB,CAAC,yBAAyB,CA4DrF,CAAC"}
@@ -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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AAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC9D,4BAA4B,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC3F,yBAAyB,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;iBACpE;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 SharedBoundedBorrowPermission. */
2
+ /**
3
+ * 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,WA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C,iBAAiB,MAAM,CAAC,SAAS,GAAG,GAAG,kCAAkC,CAAC,CAAC;YAC3F,CAAC;YACD,IAAI,MAAM,CAAC,gBAAgB,KAAK,YAAY,IAAI,MAAM,CAAC,YAAY,KAAK,YAAY,EAAE,CAAC;gBACrF,QAAQ,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;YACrF,CAAC;YACD,OAAO;gBACL,YAAY,EAAE,+BAA+B;gBAC7C,aAAa,EAAE;oBACb,0BAA0B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,qBAAqB;oBAC/E,gBAAgB,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG;oBACzC,sBAAsB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,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
  };