@dev.sail.money/sailor 0.0.2-31 → 0.1.0-local

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 (153) hide show
  1. package/AGENTS.md +140 -140
  2. package/LICENSE +21 -21
  3. package/README.md +430 -430
  4. package/docs/PERMISSION_MODEL.md +93 -93
  5. package/examples/permissions/BoundedApproveAndCallBatch.sol +179 -179
  6. package/examples/permissions/BoundedBet_Limitless_Base.sol +97 -97
  7. package/examples/permissions/BoundedBorrow_AaveV3_Arbitrum.sol +94 -94
  8. package/examples/permissions/BoundedPerp_GMXv2_Arbitrum.sol +154 -154
  9. package/examples/permissions/BoundedStake_Venice_Base.sol +85 -85
  10. package/examples/permissions/BoundedSupply_AaveV3_Arbitrum.sol +82 -82
  11. package/examples/permissions/BoundedSwap_UniswapV3_Base.sol +116 -116
  12. package/examples/permissions/BoundedSwap_UniswapV4_Unichain.sol +150 -150
  13. package/examples/permissions/BoundedTransfer_ERC20_Ethereum.sol +73 -73
  14. package/examples/permissions/BoundedVault_ERC4626_Base.sol +97 -97
  15. package/examples/permissions/README.md +79 -79
  16. package/examples/permissions/SailCalldata.sol +118 -118
  17. package/examples/permissions/foundry.toml +10 -10
  18. package/examples/permissions/interfaces/IBatchPermission.sol +38 -38
  19. package/examples/permissions/interfaces/IPermission.sol +18 -18
  20. package/package.json +45 -45
  21. package/packages/cli/README.md +34 -34
  22. package/packages/cli/dist/index.cjs +705 -687
  23. package/packages/cli/dist/server.cjs +506 -495
  24. package/packages/sdk/README.md +65 -65
  25. package/packages/sdk/dist/intelligence.d.ts +1 -1
  26. package/packages/sdk/dist/intelligence.js +1 -1
  27. package/packages/sdk/package.json +80 -80
  28. package/packages/ui/dist/assets/{add-B0J2XPqD.js → add-BxpXfVWe.js} +1 -1
  29. package/packages/ui/dist/assets/{all-wallets-DAWTUGbI.js → all-wallets-BKTn_sWK.js} +1 -1
  30. package/packages/ui/dist/assets/{app-store-B-bz9zO1.js → app-store-CfuKbwxR.js} +1 -1
  31. package/packages/ui/dist/assets/{apple-CW_aatUl.js → apple-BKSBbNYg.js} +1 -1
  32. package/packages/ui/dist/assets/{arrow-bottom-D9xphoWP.js → arrow-bottom-D4bG6gZi.js} +1 -1
  33. package/packages/ui/dist/assets/{arrow-bottom-circle-D-N3HlXh.js → arrow-bottom-circle-BNTs1p0T.js} +1 -1
  34. package/packages/ui/dist/assets/{arrow-left-DofAd9ta.js → arrow-left-2uee3vYv.js} +1 -1
  35. package/packages/ui/dist/assets/{arrow-right-CLBZVLVF.js → arrow-right-BktjMV6h.js} +1 -1
  36. package/packages/ui/dist/assets/{arrow-top-B47Y4sI6.js → arrow-top-Izu28fX4.js} +1 -1
  37. package/packages/ui/dist/assets/{bank-CVHPZeNC.js → bank-USBaAyFM.js} +1 -1
  38. package/packages/ui/dist/assets/{basic-CijTV8XG.js → basic-C_9KjTEH.js} +1 -1
  39. package/packages/ui/dist/assets/{browser-D12J6hPl.js → browser-DAEMAKV7.js} +1 -1
  40. package/packages/ui/dist/assets/{card-suad8wBG.js → card-DT8yDkKN.js} +1 -1
  41. package/packages/ui/dist/assets/{ccip-Bev57e2Y.js → ccip-CkqfGSxX.js} +1 -1
  42. package/packages/ui/dist/assets/{checkmark-DSzbM9ge.js → checkmark-CsgdEXFj.js} +1 -1
  43. package/packages/ui/dist/assets/{checkmark-bold-Ctlpy8fR.js → checkmark-bold-D2gjOQo2.js} +1 -1
  44. package/packages/ui/dist/assets/{chevron-bottom-DD4PYpsh.js → chevron-bottom-tprFynYV.js} +1 -1
  45. package/packages/ui/dist/assets/{chevron-left-HJzgI5fr.js → chevron-left-D2Zj1gNB.js} +1 -1
  46. package/packages/ui/dist/assets/{chevron-right-BAJMtoWG.js → chevron-right-D1rRuAVe.js} +1 -1
  47. package/packages/ui/dist/assets/{chevron-top-CSTGBRNq.js → chevron-top-24dL1mbL.js} +1 -1
  48. package/packages/ui/dist/assets/{chrome-store-CSgmzP0o.js → chrome-store-Vy-5niYX.js} +1 -1
  49. package/packages/ui/dist/assets/{clock-BGKXrbjA.js → clock-qBjLnVdJ.js} +1 -1
  50. package/packages/ui/dist/assets/{close-B-9LI-cc.js → close-DARDwgcu.js} +1 -1
  51. package/packages/ui/dist/assets/{coinPlaceholder-C9zB6O8f.js → coinPlaceholder-BvpIbPlD.js} +1 -1
  52. package/packages/ui/dist/assets/{compass-DNbNVsgN.js → compass-BMTO0ayt.js} +1 -1
  53. package/packages/ui/dist/assets/{copy-r_J027hY.js → copy-PaXeRHza.js} +1 -1
  54. package/packages/ui/dist/assets/{core-CuWvvvu4.js → core-BFnStQd-.js} +3 -3
  55. package/packages/ui/dist/assets/cursor-BDvw-B17.js +3 -0
  56. package/packages/ui/dist/assets/{cursor-transparent-By6KxbOE.js → cursor-transparent-BEMdi-8q.js} +1 -1
  57. package/packages/ui/dist/assets/{desktop-DRMmsjrd.js → desktop-CfuLLThw.js} +1 -1
  58. package/packages/ui/dist/assets/{disconnect-C69Z8KUW.js → disconnect-DhwgJMiR.js} +1 -1
  59. package/packages/ui/dist/assets/{discord-p3AKvqDk.js → discord-po8qoN1s.js} +1 -1
  60. package/packages/ui/dist/assets/{etherscan-C2zTiWaN.js → etherscan-BEsz0_yx.js} +1 -1
  61. package/packages/ui/dist/assets/{events-DKTfpIHs.js → events-Bz33Unzu.js} +1 -1
  62. package/packages/ui/dist/assets/{exclamation-triangle-D4IJznwI.js → exclamation-triangle-7CjTAGOQ.js} +1 -1
  63. package/packages/ui/dist/assets/{extension-C0y2g1tg.js → extension-CmxjEWEt.js} +1 -1
  64. package/packages/ui/dist/assets/{external-link-fkbBBTcW.js → external-link-CmQ--bNS.js} +1 -1
  65. package/packages/ui/dist/assets/{facebook-nsIgKROR.js → facebook-CIBn9b65.js} +1 -1
  66. package/packages/ui/dist/assets/{fallback-DHv3hSPW.js → fallback-DATyrQlb.js} +1 -1
  67. package/packages/ui/dist/assets/{farcaster-CzBHn8fo.js → farcaster-OJ3Jasxg.js} +1 -1
  68. package/packages/ui/dist/assets/{filters-gW1TGI8D.js → filters-D4x09zeL.js} +1 -1
  69. package/packages/ui/dist/assets/{github-D9UuzE25.js → github-ZlIuMArp.js} +1 -1
  70. package/packages/ui/dist/assets/{google-DxUfChw6.js → google-Gwg85sfv.js} +1 -1
  71. package/packages/ui/dist/assets/{help-circle-2dNDsXrX.js → help-circle-D1uOWYcX.js} +1 -1
  72. package/packages/ui/dist/assets/{id-rNBDU8mz.js → id-C0-5UdYk.js} +1 -1
  73. package/packages/ui/dist/assets/{image-C9Peu4QW.js → image-D_DUsv8-.js} +1 -1
  74. package/packages/ui/dist/assets/{index-B1wosqUU.js → index-BCzex_R6.js} +1 -1
  75. package/packages/ui/dist/assets/index-BUhrHLpY.js +1775 -0
  76. package/packages/ui/dist/assets/index-Cq02kQmy.css +1 -0
  77. package/packages/ui/dist/assets/{index-B1aFIpJ0.js → index-CrYzBWfD.js} +1 -1
  78. package/packages/ui/dist/assets/{index-_F9WbMAT.js → index-DdbJhIdl.js} +3 -3
  79. package/packages/ui/dist/assets/{index-JwrWbcaz.js → index-DiojfeVM.js} +1 -1
  80. package/packages/ui/dist/assets/{index-4lrTXbkY.js → index-izd7vu_r.js} +1 -1
  81. package/packages/ui/dist/assets/{index.es-wlYgJouQ.js → index.es-DdkHhQAj.js} +4 -4
  82. package/packages/ui/dist/assets/{info-cGbqKpFv.js → info-CiRd_kEG.js} +1 -1
  83. package/packages/ui/dist/assets/{info-circle-B8Xfr9A0.js → info-circle-ypxjqarK.js} +1 -1
  84. package/packages/ui/dist/assets/{lightbulb-CM2m-PnZ.js → lightbulb-B-pxLxd8.js} +1 -1
  85. package/packages/ui/dist/assets/{mail-_qO7Zcxu.js → mail-BYmicuVZ.js} +1 -1
  86. package/packages/ui/dist/assets/{metamask-sdk-Dy961bnw.js → metamask-sdk-Ccl6DG7Q.js} +1 -1
  87. package/packages/ui/dist/assets/{mobile-C6TDJh2K.js → mobile-CtP5PqVT.js} +1 -1
  88. package/packages/ui/dist/assets/{more-3pPTR0Gx.js → more-6C2733we.js} +1 -1
  89. package/packages/ui/dist/assets/{network-placeholder-BtFT2yZA.js → network-placeholder-CdhxMzqd.js} +1 -1
  90. package/packages/ui/dist/assets/{nftPlaceholder-BfBZEH1N.js → nftPlaceholder-DVmTWEAY.js} +1 -1
  91. package/packages/ui/dist/assets/{off-Bg5cnmyC.js → off-DNYLughs.js} +1 -1
  92. package/packages/ui/dist/assets/{parseSignature-CSIsnC1G.js → parseSignature-Dq2B5Bu3.js} +1 -1
  93. package/packages/ui/dist/assets/{play-store-Dg32m5PL.js → play-store-D7Qut5ta.js} +1 -1
  94. package/packages/ui/dist/assets/{plus-Ce97GbOa.js → plus-kqMyjt3q.js} +1 -1
  95. package/packages/ui/dist/assets/{qr-code-D3KdZWUh.js → qr-code-DiUCWRbz.js} +1 -1
  96. package/packages/ui/dist/assets/{recycle-horizontal-DOKfyzVh.js → recycle-horizontal-Boe3XiS-.js} +1 -1
  97. package/packages/ui/dist/assets/{refresh-DSjW7q17.js → refresh-CrBgBQYO.js} +1 -1
  98. package/packages/ui/dist/assets/{reown-logo-B0n-8waR.js → reown-logo-CFZCCHSx.js} +1 -1
  99. package/packages/ui/dist/assets/{search-CL2iyGid.js → search-ChTDrghU.js} +1 -1
  100. package/packages/ui/dist/assets/{secp256k1-DdqDRGog.js → secp256k1-DAV5Q_FR.js} +1 -1
  101. package/packages/ui/dist/assets/{send-C_Rm4fzj.js → send-DLFbBFe1.js} +1 -1
  102. package/packages/ui/dist/assets/{swapHorizontal-0d_94RdY.js → swapHorizontal-BEs3emfG.js} +1 -1
  103. package/packages/ui/dist/assets/{swapHorizontalBold-BukSRa8V.js → swapHorizontalBold-CC-Hfa7W.js} +1 -1
  104. package/packages/ui/dist/assets/{swapHorizontalMedium-DvroDkEf.js → swapHorizontalMedium-BmR0H8DC.js} +1 -1
  105. package/packages/ui/dist/assets/{swapHorizontalRoundedBold-BAehcn9y.js → swapHorizontalRoundedBold-BdP5NGIH.js} +1 -1
  106. package/packages/ui/dist/assets/{swapVertical-kblIte_7.js → swapVertical-CPrGEJPY.js} +1 -1
  107. package/packages/ui/dist/assets/{telegram-DHLO89MI.js → telegram-CxNoZ80Q.js} +1 -1
  108. package/packages/ui/dist/assets/{three-dots-ctb5FHLw.js → three-dots-BRa6SBpL.js} +1 -1
  109. package/packages/ui/dist/assets/{twitch-CK_fCqNu.js → twitch-BC338bG5.js} +1 -1
  110. package/packages/ui/dist/assets/{twitterIcon-BCngN3WD.js → twitterIcon-BGZmt2i9.js} +1 -1
  111. package/packages/ui/dist/assets/{verify-Dy-B59vy.js → verify-CEstW0zw.js} +1 -1
  112. package/packages/ui/dist/assets/{verify-filled-DHDHx8Lk.js → verify-filled-OkZb0weU.js} +1 -1
  113. package/packages/ui/dist/assets/{w3m-modal-DRNXP3Ww.js → w3m-modal-pS09ECwE.js} +1 -1
  114. package/packages/ui/dist/assets/{wallet-DriPOF7d.js → wallet-BXVKCgC9.js} +1 -1
  115. package/packages/ui/dist/assets/{wallet-placeholder-B4ukOjpR.js → wallet-placeholder-C_kNhB1c.js} +1 -1
  116. package/packages/ui/dist/assets/{walletconnect-Cjl1Ki75.js → walletconnect-CRKIuUHH.js} +1 -1
  117. package/packages/ui/dist/assets/{warning-circle-C7eCTFhJ.js → warning-circle-DB2NnwlJ.js} +1 -1
  118. package/packages/ui/dist/assets/{x-B8jYZY9t.js → x-DT4RmwL5.js} +1 -1
  119. package/packages/ui/dist/index.html +14 -14
  120. package/scripts/check-docs.mjs +262 -262
  121. package/scripts/check-init.mjs +108 -108
  122. package/scripts/postinstall.js +81 -56
  123. package/templates/custom-mandate/.sail/contracts/interfaces/IPermission.sol +18 -18
  124. package/templates/custom-mandate/README.md +116 -116
  125. package/templates/custom-mandate/foundry.toml +8 -8
  126. package/templates/custom-mandate/mandates/BoundedCallPermission.sol +41 -41
  127. package/templates/custom-mandate/mandates/README.md +16 -16
  128. package/templates/custom-mandate/mandates/SailCalldata.sol +118 -118
  129. package/templates/default/.cursor/rules +25 -25
  130. package/templates/default/.env.example +20 -20
  131. package/templates/default/.github/workflows/agent-tick.yml +33 -33
  132. package/templates/default/.sail/README.md +13 -13
  133. package/templates/default/.sail/config.json +10 -10
  134. package/templates/default/AGENTS.md +171 -171
  135. package/templates/default/CLAUDE.md +2 -2
  136. package/templates/default/README.md +16 -16
  137. package/templates/default/_gitignore +13 -13
  138. package/templates/default/docs/PERMISSION_MODEL.md +93 -93
  139. package/templates/default/examples/dca/README.md +16 -16
  140. package/templates/default/examples/dca/agent.ts +174 -174
  141. package/templates/default/examples/dca/mandate.ts +45 -45
  142. package/templates/default/package.json +17 -17
  143. package/templates/default/src/agent.ts +37 -37
  144. package/templates/default/src/config.ts +24 -24
  145. package/templates/default/src/mandate.ts +22 -22
  146. package/templates/default/tsconfig.json +17 -17
  147. package/templates/default/ui/README.md +3 -3
  148. package/templates/lifi-permissions/LifiBoundedApprovePermissionCloneable.sol +84 -84
  149. package/templates/lifi-permissions/LifiDiamondSwapPermissionCloneable.sol +97 -97
  150. package/templates/lifi-permissions/README.md +53 -53
  151. package/packages/ui/dist/assets/cursor-0ZcCqvYy.js +0 -3
  152. package/packages/ui/dist/assets/index-BzT0MJhc.js +0 -1775
  153. package/packages/ui/dist/assets/index-n8bp1ZEc.css +0 -1
@@ -1,17 +1,17 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "target": "ES2022",
5
- "module": "NodeNext",
6
- "moduleResolution": "NodeNext",
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "resolveJsonModule": true,
10
- "noEmit": true,
11
- "baseUrl": ".",
12
- "paths": {
13
- "@sail.money/sailor/sdk": ["../../packages/sdk/src/index.ts"]
14
- }
15
- },
16
- "include": ["src"]
17
- }
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "ES2022",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "resolveJsonModule": true,
10
+ "noEmit": true,
11
+ "baseUrl": ".",
12
+ "paths": {
13
+ "@sail.money/sailor/sdk": ["../../packages/sdk/src/index.ts"]
14
+ }
15
+ },
16
+ "include": ["src"]
17
+ }
@@ -1,3 +1,3 @@
1
- # UI
2
-
3
- Vite + React UI lands in the next prompt.
1
+ # UI
2
+
3
+ Vite + React UI lands in the next prompt.
@@ -1,84 +1,84 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.26;
3
-
4
- import {IPermission, Context} from "../../.sail/contracts/interfaces/IPermission.sol";
5
- import {CloneInitializable} from "../../.sail/contracts/templates/base/CloneInitializable.sol";
6
-
7
- /// @title LifiBoundedApprovePermissionCloneable
8
- /// @notice EIP-1167 clone-template approval permission with PER-TOKEN caps. The
9
- /// logic contract is deployed once and registered in the SDK's
10
- /// standaloneTemplates; each account clones it via
11
- /// PermissionFactory.deployAndAttach and configures via initialize().
12
- ///
13
- /// The manager may ONLY approve the LiFi Diamond, and only on tokens that
14
- /// have a configured cap, up to that token's cap. Passes through any
15
- /// non-approve call (conjunctive model).
16
- ///
17
- /// Caps are PER TOKEN (not one global cap) because token value and decimals
18
- /// differ — e.g. 1 DAI = 1e18 base units vs 1 USDC = 1e6. A single cap can't
19
- /// bound both sensibly.
20
- contract LifiBoundedApprovePermissionCloneable is IPermission, CloneInitializable {
21
- bytes4 private constant APPROVE = 0x095ea7b3;
22
- address public constant LIFI_DIAMOND = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;
23
-
24
- // Per-token approve cap, in the token's base units. 0 = token not allowed.
25
- // A mapping occupies its own slot pointer and does not pack with the
26
- // CloneInitializable `_initialized` bool at slot 0.
27
- mapping(address token => uint256 cap) public maxApprovePerToken;
28
- address public permissionSigner;
29
-
30
- error NotPermissionSigner();
31
- error ZeroAddress();
32
- error LengthMismatch();
33
-
34
- modifier onlyPermissionSigner() {
35
- if (msg.sender != permissionSigner) revert NotPermissionSigner();
36
- _;
37
- }
38
-
39
- /// @dev Lock the logic contract; only clones (fresh storage) can be initialized.
40
- constructor() {
41
- _disableInitializers();
42
- }
43
-
44
- /// @notice One-time per-clone configuration.
45
- /// @param tokens Tokens the manager may approve to the LiFi Diamond.
46
- /// @param caps Per-token cap (token base units); index-aligned with `tokens`.
47
- /// @param _permissionSigner Owner wallet; sole authority for post-init updates.
48
- function initialize(
49
- address[] memory tokens,
50
- uint256[] memory caps,
51
- address _permissionSigner
52
- ) external initializer {
53
- if (_permissionSigner == address(0)) revert ZeroAddress();
54
- if (tokens.length != caps.length) revert LengthMismatch();
55
- permissionSigner = _permissionSigner;
56
- for (uint256 i; i < tokens.length; i++) {
57
- maxApprovePerToken[tokens[i]] = caps[i];
58
- }
59
- }
60
-
61
- /// @notice Set (cap > 0) or clear (cap == 0) a token's per-tx approve cap.
62
- function setTokenCap(address token, uint256 cap) external onlyPermissionSigner {
63
- maxApprovePerToken[token] = cap;
64
- }
65
-
66
- function evaluate(bytes calldata txData, Context calldata ctx) external view returns (bool) {
67
- // Pass through calls outside this permission's domain (conjunctive model).
68
- if (ctx.selector != APPROVE) return true;
69
- if (ctx.target == address(0)) return false; // token is ctx.target
70
- if (txData.length < 68) return false;
71
-
72
- (address spender, uint256 amount) = abi.decode(txData[4:], (address, uint256));
73
- if (spender != LIFI_DIAMOND) return false;
74
-
75
- uint256 cap = maxApprovePerToken[ctx.target];
76
- if (cap == 0) return false; // token not allowed
77
- if (amount > cap) return false; // over the per-token cap
78
- return true;
79
- }
80
-
81
- function discriminator() external pure returns (bytes32) {
82
- return keccak256("LifiBoundedApprovePermissionCloneable.v1");
83
- }
84
- }
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.26;
3
+
4
+ import {IPermission, Context} from "../../.sail/contracts/interfaces/IPermission.sol";
5
+ import {CloneInitializable} from "../../.sail/contracts/templates/base/CloneInitializable.sol";
6
+
7
+ /// @title LifiBoundedApprovePermissionCloneable
8
+ /// @notice EIP-1167 clone-template approval permission with PER-TOKEN caps. The
9
+ /// logic contract is deployed once and registered in the SDK's
10
+ /// standaloneTemplates; each account clones it via
11
+ /// PermissionFactory.deployAndAttach and configures via initialize().
12
+ ///
13
+ /// The manager may ONLY approve the LiFi Diamond, and only on tokens that
14
+ /// have a configured cap, up to that token's cap. Passes through any
15
+ /// non-approve call (conjunctive model).
16
+ ///
17
+ /// Caps are PER TOKEN (not one global cap) because token value and decimals
18
+ /// differ — e.g. 1 DAI = 1e18 base units vs 1 USDC = 1e6. A single cap can't
19
+ /// bound both sensibly.
20
+ contract LifiBoundedApprovePermissionCloneable is IPermission, CloneInitializable {
21
+ bytes4 private constant APPROVE = 0x095ea7b3;
22
+ address public constant LIFI_DIAMOND = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;
23
+
24
+ // Per-token approve cap, in the token's base units. 0 = token not allowed.
25
+ // A mapping occupies its own slot pointer and does not pack with the
26
+ // CloneInitializable `_initialized` bool at slot 0.
27
+ mapping(address token => uint256 cap) public maxApprovePerToken;
28
+ address public permissionSigner;
29
+
30
+ error NotPermissionSigner();
31
+ error ZeroAddress();
32
+ error LengthMismatch();
33
+
34
+ modifier onlyPermissionSigner() {
35
+ if (msg.sender != permissionSigner) revert NotPermissionSigner();
36
+ _;
37
+ }
38
+
39
+ /// @dev Lock the logic contract; only clones (fresh storage) can be initialized.
40
+ constructor() {
41
+ _disableInitializers();
42
+ }
43
+
44
+ /// @notice One-time per-clone configuration.
45
+ /// @param tokens Tokens the manager may approve to the LiFi Diamond.
46
+ /// @param caps Per-token cap (token base units); index-aligned with `tokens`.
47
+ /// @param _permissionSigner Owner wallet; sole authority for post-init updates.
48
+ function initialize(
49
+ address[] memory tokens,
50
+ uint256[] memory caps,
51
+ address _permissionSigner
52
+ ) external initializer {
53
+ if (_permissionSigner == address(0)) revert ZeroAddress();
54
+ if (tokens.length != caps.length) revert LengthMismatch();
55
+ permissionSigner = _permissionSigner;
56
+ for (uint256 i; i < tokens.length; i++) {
57
+ maxApprovePerToken[tokens[i]] = caps[i];
58
+ }
59
+ }
60
+
61
+ /// @notice Set (cap > 0) or clear (cap == 0) a token's per-tx approve cap.
62
+ function setTokenCap(address token, uint256 cap) external onlyPermissionSigner {
63
+ maxApprovePerToken[token] = cap;
64
+ }
65
+
66
+ function evaluate(bytes calldata txData, Context calldata ctx) external view returns (bool) {
67
+ // Pass through calls outside this permission's domain (conjunctive model).
68
+ if (ctx.selector != APPROVE) return true;
69
+ if (ctx.target == address(0)) return false; // token is ctx.target
70
+ if (txData.length < 68) return false;
71
+
72
+ (address spender, uint256 amount) = abi.decode(txData[4:], (address, uint256));
73
+ if (spender != LIFI_DIAMOND) return false;
74
+
75
+ uint256 cap = maxApprovePerToken[ctx.target];
76
+ if (cap == 0) return false; // token not allowed
77
+ if (amount > cap) return false; // over the per-token cap
78
+ return true;
79
+ }
80
+
81
+ function discriminator() external pure returns (bytes32) {
82
+ return keccak256("LifiBoundedApprovePermissionCloneable.v1");
83
+ }
84
+ }
@@ -1,97 +1,97 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.26;
3
-
4
- import {IPermission, Context} from "../../.sail/contracts/interfaces/IPermission.sol";
5
- import {CloneInitializable} from "../../.sail/contracts/templates/base/CloneInitializable.sol";
6
-
7
- /// @title LifiDiamondSwapPermissionCloneable
8
- /// @notice EIP-1167 clone-template version of LifiDiamondSwapPermission. The logic
9
- /// contract is deployed once and registered in the SDK's standaloneTemplates;
10
- /// each account gets its own clone via PermissionFactory.deployAndAttach,
11
- /// configured through initialize() (NOT the constructor).
12
- ///
13
- /// Restricts manager-initiated swaps to the official LiFi Diamond on Base:
14
- /// - target must be the LiFi Diamond,
15
- /// - selector must be allowlisted,
16
- /// - receiver embedded in the calldata must equal ctx.account (the SMA),
17
- /// - the minAmount field must not exceed the configured cap.
18
- /// Passes through any call whose target is not the diamond (conjunctive model).
19
- ///
20
- /// Calldata layout (validated against live Base quotes):
21
- /// selector(4) + word0(32) + word1(32) + word2(32) + receiver(32) + minAmount(32)
22
- /// → receiver at offset 100, minAmount at offset 132.
23
- contract LifiDiamondSwapPermissionCloneable is IPermission, CloneInitializable {
24
- // Official LiFi Diamond on Base Mainnet.
25
- address public constant LIFI_DIAMOND = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;
26
-
27
- // Storage starts after CloneInitializable's `_initialized` bool (slot 0). A
28
- // mapping occupies its own slot pointer and does not pack with the bool.
29
- mapping(bytes4 selector => bool) public isAllowedSelector;
30
- uint256 public maxMinAmountPerTx;
31
- address public permissionSigner;
32
-
33
- error NotPermissionSigner();
34
- error ZeroAddress();
35
-
36
- modifier onlyPermissionSigner() {
37
- if (msg.sender != permissionSigner) revert NotPermissionSigner();
38
- _;
39
- }
40
-
41
- /// @dev Lock the logic contract; only clones (fresh storage) can be initialized.
42
- constructor() {
43
- _disableInitializers();
44
- }
45
-
46
- /// @notice One-time per-clone configuration.
47
- /// @param allowedSelectors LiFi Diamond selectors to allowlist on init.
48
- /// @param _maxMinAmountPerTx Cap on the minAmount field (type(uint256).max = uncapped).
49
- /// @param _permissionSigner Owner wallet; sole authority for post-init updates.
50
- function initialize(
51
- bytes4[] memory allowedSelectors,
52
- uint256 _maxMinAmountPerTx,
53
- address _permissionSigner
54
- ) external initializer {
55
- if (_permissionSigner == address(0)) revert ZeroAddress();
56
- maxMinAmountPerTx = _maxMinAmountPerTx;
57
- permissionSigner = _permissionSigner;
58
- for (uint256 i; i < allowedSelectors.length; i++) {
59
- isAllowedSelector[allowedSelectors[i]] = true;
60
- }
61
- }
62
-
63
- function setMaxMinAmountPerTx(uint256 newMax) external onlyPermissionSigner {
64
- maxMinAmountPerTx = newMax;
65
- }
66
-
67
- /// @notice Add a LiFi selector. Only after verifying its calldata places
68
- /// `receiver` at offset 100 and `minAmount` at offset 132.
69
- function addSelector(bytes4 selector) external onlyPermissionSigner {
70
- isAllowedSelector[selector] = true;
71
- }
72
-
73
- function removeSelector(bytes4 selector) external onlyPermissionSigner {
74
- isAllowedSelector[selector] = false;
75
- }
76
-
77
- uint256 private constant RECEIVER_OFFSET = 100;
78
- uint256 private constant MIN_DATA_LEN = 164;
79
-
80
- function evaluate(bytes calldata txData, Context calldata ctx) external view returns (bool) {
81
- // Pass through calls outside this permission's domain (conjunctive model).
82
- if (ctx.target != LIFI_DIAMOND) return true;
83
- if (!isAllowedSelector[ctx.selector]) return false;
84
- if (txData.length < MIN_DATA_LEN) return false;
85
-
86
- address receiver = abi.decode(txData[RECEIVER_OFFSET:RECEIVER_OFFSET + 32], (address));
87
- uint256 minAmount = abi.decode(txData[RECEIVER_OFFSET + 32:RECEIVER_OFFSET + 64], (uint256));
88
-
89
- if (receiver != ctx.account) return false;
90
- if (minAmount > maxMinAmountPerTx) return false;
91
- return true;
92
- }
93
-
94
- function discriminator() external pure returns (bytes32) {
95
- return keccak256("LifiDiamondSwapPermissionCloneable.v1");
96
- }
97
- }
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.26;
3
+
4
+ import {IPermission, Context} from "../../.sail/contracts/interfaces/IPermission.sol";
5
+ import {CloneInitializable} from "../../.sail/contracts/templates/base/CloneInitializable.sol";
6
+
7
+ /// @title LifiDiamondSwapPermissionCloneable
8
+ /// @notice EIP-1167 clone-template version of LifiDiamondSwapPermission. The logic
9
+ /// contract is deployed once and registered in the SDK's standaloneTemplates;
10
+ /// each account gets its own clone via PermissionFactory.deployAndAttach,
11
+ /// configured through initialize() (NOT the constructor).
12
+ ///
13
+ /// Restricts manager-initiated swaps to the official LiFi Diamond on Base:
14
+ /// - target must be the LiFi Diamond,
15
+ /// - selector must be allowlisted,
16
+ /// - receiver embedded in the calldata must equal ctx.account (the SMA),
17
+ /// - the minAmount field must not exceed the configured cap.
18
+ /// Passes through any call whose target is not the diamond (conjunctive model).
19
+ ///
20
+ /// Calldata layout (validated against live Base quotes):
21
+ /// selector(4) + word0(32) + word1(32) + word2(32) + receiver(32) + minAmount(32)
22
+ /// → receiver at offset 100, minAmount at offset 132.
23
+ contract LifiDiamondSwapPermissionCloneable is IPermission, CloneInitializable {
24
+ // Official LiFi Diamond on Base Mainnet.
25
+ address public constant LIFI_DIAMOND = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;
26
+
27
+ // Storage starts after CloneInitializable's `_initialized` bool (slot 0). A
28
+ // mapping occupies its own slot pointer and does not pack with the bool.
29
+ mapping(bytes4 selector => bool) public isAllowedSelector;
30
+ uint256 public maxMinAmountPerTx;
31
+ address public permissionSigner;
32
+
33
+ error NotPermissionSigner();
34
+ error ZeroAddress();
35
+
36
+ modifier onlyPermissionSigner() {
37
+ if (msg.sender != permissionSigner) revert NotPermissionSigner();
38
+ _;
39
+ }
40
+
41
+ /// @dev Lock the logic contract; only clones (fresh storage) can be initialized.
42
+ constructor() {
43
+ _disableInitializers();
44
+ }
45
+
46
+ /// @notice One-time per-clone configuration.
47
+ /// @param allowedSelectors LiFi Diamond selectors to allowlist on init.
48
+ /// @param _maxMinAmountPerTx Cap on the minAmount field (type(uint256).max = uncapped).
49
+ /// @param _permissionSigner Owner wallet; sole authority for post-init updates.
50
+ function initialize(
51
+ bytes4[] memory allowedSelectors,
52
+ uint256 _maxMinAmountPerTx,
53
+ address _permissionSigner
54
+ ) external initializer {
55
+ if (_permissionSigner == address(0)) revert ZeroAddress();
56
+ maxMinAmountPerTx = _maxMinAmountPerTx;
57
+ permissionSigner = _permissionSigner;
58
+ for (uint256 i; i < allowedSelectors.length; i++) {
59
+ isAllowedSelector[allowedSelectors[i]] = true;
60
+ }
61
+ }
62
+
63
+ function setMaxMinAmountPerTx(uint256 newMax) external onlyPermissionSigner {
64
+ maxMinAmountPerTx = newMax;
65
+ }
66
+
67
+ /// @notice Add a LiFi selector. Only after verifying its calldata places
68
+ /// `receiver` at offset 100 and `minAmount` at offset 132.
69
+ function addSelector(bytes4 selector) external onlyPermissionSigner {
70
+ isAllowedSelector[selector] = true;
71
+ }
72
+
73
+ function removeSelector(bytes4 selector) external onlyPermissionSigner {
74
+ isAllowedSelector[selector] = false;
75
+ }
76
+
77
+ uint256 private constant RECEIVER_OFFSET = 100;
78
+ uint256 private constant MIN_DATA_LEN = 164;
79
+
80
+ function evaluate(bytes calldata txData, Context calldata ctx) external view returns (bool) {
81
+ // Pass through calls outside this permission's domain (conjunctive model).
82
+ if (ctx.target != LIFI_DIAMOND) return true;
83
+ if (!isAllowedSelector[ctx.selector]) return false;
84
+ if (txData.length < MIN_DATA_LEN) return false;
85
+
86
+ address receiver = abi.decode(txData[RECEIVER_OFFSET:RECEIVER_OFFSET + 32], (address));
87
+ uint256 minAmount = abi.decode(txData[RECEIVER_OFFSET + 32:RECEIVER_OFFSET + 64], (uint256));
88
+
89
+ if (receiver != ctx.account) return false;
90
+ if (minAmount > maxMinAmountPerTx) return false;
91
+ return true;
92
+ }
93
+
94
+ function discriminator() external pure returns (bytes32) {
95
+ return keccak256("LifiDiamondSwapPermissionCloneable.v1");
96
+ }
97
+ }
@@ -1,53 +1,53 @@
1
- # LiFi clone-permission templates
2
-
3
- Canonical source (for reference) of the EIP-1167 **clone** permission templates
4
- used for LiFi-based swaps/DCA. The logic contracts are deployed once per chain and
5
- registered in the SDK deployment registry
6
- (`packages/sdk/src/deployments.ts` → `standaloneTemplates` / `cloneTemplates`).
7
- Each account gets its own clone via `PermissionFactory.deployAndAttach`, configured
8
- through `initialize()` (never the constructor).
9
-
10
- These follow the `CloneInitializable` pattern: the constructor calls
11
- `_disableInitializers()` to permanently lock the logic contract, and a one-time
12
- `initialize()` (guarded by the `initializer` modifier) configures each clone.
13
-
14
- > The `import` paths reference `../../.sail/contracts/{interfaces,templates/base}`
15
- > from the Foundry project they were built in
16
- > (`tests/base-mainnet-agent-01/`). This folder is **reference source** — sailor has
17
- > no Foundry build. Build/deploy happens in that project via
18
- > `scripts/deploy-clone-templates.ts`.
19
-
20
- > **Note:** The kernels bundled in `@sail.money/sailor/sdk` (Base, Base Sepolia, Arbitrum, Unichain) now all run the **selective** dispatch model — verified on-chain against each kernel's `DISPATCH_TYPEHASH`. These templates were written for the older conjunctive model and include pass-through logic (`return true` for calls outside their domain) that is not required on selective kernels. Review before deploying against a selective kernel; the pass-through logic is harmless but unnecessary.
21
-
22
- ## Contracts
23
-
24
- ### LifiDiamondSwapPermissionCloneable → `boundedLiFi`
25
- Restricts manager swaps to the official LiFi Diamond:
26
- target == diamond, selector allowlisted, embedded receiver == `ctx.account`,
27
- `minAmount <= maxMinAmountPerTx`. Passes through any call whose target is not the
28
- diamond (conjunctive-kernel rule).
29
-
30
- `initialize(bytes4[] allowedSelectors, uint256 maxMinAmountPerTx, address permissionSigner)`
31
-
32
- ### LifiBoundedApprovePermissionCloneable → `boundedApprove`
33
- Approve only the LiFi Diamond, only on tokens with a configured cap, up to that
34
- cap. **Per-token caps** (`mapping(token => cap)`) because token value/decimals
35
- differ (1 DAI = 1e18 vs 1 USDC = 1e6). Passes through non-approve calls.
36
-
37
- `initialize(address[] tokens, uint256[] caps, address permissionSigner)`
38
-
39
- ## Deployed logic addresses
40
-
41
- | Template | Chain | Address |
42
- |---|---|---|
43
- | boundedLiFi | Base mainnet (8453) | `0xF1abcF774250fD1A8147B56DA07Bf9021064650A` |
44
- | boundedApprove | Base mainnet (8453) | `0x9c0b86daf9e75d759a5D165aD7366e52b3353fD8` |
45
-
46
- Both verified `initialized() == true` (logic locked) post-deploy.
47
-
48
- ## Conjunctive-kernel note
49
-
50
- Both Base kernels use the **conjunctive** dispatch model: every registered
51
- permission is evaluated and ALL must return true. So a permission MUST pass through
52
- calls outside its own domain (return `true`), or it bricks unrelated dispatches.
53
- Both templates above do this.
1
+ # LiFi clone-permission templates
2
+
3
+ Canonical source (for reference) of the EIP-1167 **clone** permission templates
4
+ used for LiFi-based swaps/DCA. The logic contracts are deployed once per chain and
5
+ registered in the SDK deployment registry
6
+ (`packages/sdk/src/deployments.ts` → `standaloneTemplates` / `cloneTemplates`).
7
+ Each account gets its own clone via `PermissionFactory.deployAndAttach`, configured
8
+ through `initialize()` (never the constructor).
9
+
10
+ These follow the `CloneInitializable` pattern: the constructor calls
11
+ `_disableInitializers()` to permanently lock the logic contract, and a one-time
12
+ `initialize()` (guarded by the `initializer` modifier) configures each clone.
13
+
14
+ > The `import` paths reference `../../.sail/contracts/{interfaces,templates/base}`
15
+ > from the Foundry project they were built in
16
+ > (`tests/base-mainnet-agent-01/`). This folder is **reference source** — sailor has
17
+ > no Foundry build. Build/deploy happens in that project via
18
+ > `scripts/deploy-clone-templates.ts`.
19
+
20
+ > **Note:** The kernels bundled in `@sail.money/sailor/sdk` (Base, Base Sepolia, Arbitrum, Unichain) now all run the **selective** dispatch model — verified on-chain against each kernel's `DISPATCH_TYPEHASH`. These templates were written for the older conjunctive model and include pass-through logic (`return true` for calls outside their domain) that is not required on selective kernels. Review before deploying against a selective kernel; the pass-through logic is harmless but unnecessary.
21
+
22
+ ## Contracts
23
+
24
+ ### LifiDiamondSwapPermissionCloneable → `boundedLiFi`
25
+ Restricts manager swaps to the official LiFi Diamond:
26
+ target == diamond, selector allowlisted, embedded receiver == `ctx.account`,
27
+ `minAmount <= maxMinAmountPerTx`. Passes through any call whose target is not the
28
+ diamond (conjunctive-kernel rule).
29
+
30
+ `initialize(bytes4[] allowedSelectors, uint256 maxMinAmountPerTx, address permissionSigner)`
31
+
32
+ ### LifiBoundedApprovePermissionCloneable → `boundedApprove`
33
+ Approve only the LiFi Diamond, only on tokens with a configured cap, up to that
34
+ cap. **Per-token caps** (`mapping(token => cap)`) because token value/decimals
35
+ differ (1 DAI = 1e18 vs 1 USDC = 1e6). Passes through non-approve calls.
36
+
37
+ `initialize(address[] tokens, uint256[] caps, address permissionSigner)`
38
+
39
+ ## Deployed logic addresses
40
+
41
+ | Template | Chain | Address |
42
+ |---|---|---|
43
+ | boundedLiFi | Base mainnet (8453) | `0xF1abcF774250fD1A8147B56DA07Bf9021064650A` |
44
+ | boundedApprove | Base mainnet (8453) | `0x9c0b86daf9e75d759a5D165aD7366e52b3353fD8` |
45
+
46
+ Both verified `initialized() == true` (logic locked) post-deploy.
47
+
48
+ ## Conjunctive-kernel note
49
+
50
+ Both Base kernels use the **conjunctive** dispatch model: every registered
51
+ permission is evaluated and ALL must return true. So a permission MUST pass through
52
+ calls outside its own domain (return `true`), or it bricks unrelated dispatches.
53
+ Both templates above do this.
@@ -1,3 +0,0 @@
1
- import{F as o}from"./core-CuWvvvu4.js";import"./index-BzT0MJhc.js";import"./events-DKTfpIHs.js";import"./index.es-wlYgJouQ.js";import"./fallback-DHv3hSPW.js";const l=o` <svg fill="none" viewBox="0 0 13 4">
2
- <path fill="currentColor" d="M.5 0h12L8.9 3.13a3.76 3.76 0 0 1-4.8 0L.5 0Z" />
3
- </svg>`;export{l as cursorSvg};