@pushchain/core 6.0.27-alpha.1 → 6.0.27-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGW.md +57 -4
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/lib/agentic/index.d.ts +1 -1
- package/src/lib/agentic/presets/aave-reserves.d.ts +4 -0
- package/src/lib/agentic/presets/aave-reserves.js +147 -0
- package/src/lib/agentic/presets/catalog.d.ts +23 -1
- package/src/lib/agentic/presets/catalog.js +61 -17
- package/src/lib/agentic/presets/index.js +93 -4
- package/src/lib/agentic/presets/operation-limits.d.ts +13 -0
- package/src/lib/agentic/presets/operation-limits.js +111 -0
- package/src/lib/agentic/presets/types.d.ts +39 -8
- package/src/lib/index.d.ts +1 -1
package/AGW.md
CHANGED
|
@@ -91,7 +91,7 @@ An equality pin fixes an argument; a maximum pin bounds it. For EVM signatures,
|
|
|
91
91
|
|
|
92
92
|
`PushChain.CONSTANTS.AGENTIC.WALLET` resolves to the AGW on Push, its CEA on an EVM destination, or its CEA/selected token ATA on Solana. Deployment addresses and encoding helpers are internal.
|
|
93
93
|
|
|
94
|
-
Omitted `maxValue`, `assets[].maxTotal`, and `maxGasPerCall` default to **zero
|
|
94
|
+
Omitted `maxValue`, `assets[].maxTotal`, and `maxGasPerCall` default to **zero**. Asset totals meter tokens sent from Push; they do not meter trading or lending using capital already in the destination CEA. Specify positive caps for sends that need value, tokens or destination gas. Native value is limited per call; there is no public native lifetime-total cap.
|
|
95
95
|
|
|
96
96
|
## EVM destinations
|
|
97
97
|
|
|
@@ -171,7 +171,7 @@ The wire encoder uses uint32 maximum for unlimited native calls and 255 for unsp
|
|
|
171
171
|
|
|
172
172
|
- DEXES: Uniswap V3 on Ethereum, Base and Arbitrum (mainnet and their Sepolia testnets); PancakeSwap V3 on BNB mainnet and BSC testnet.
|
|
173
173
|
- LENDING: Aave on Ethereum, Base, Arbitrum and BNB mainnets, plus Sepolia/Base Sepolia/Arbitrum Sepolia; Moonwell on Base mainnet/testnet and Venus on BNB mainnet/testnet.
|
|
174
|
-
- STAKING: EigenLayer deposits on Ethereum mainnet and Sepolia
|
|
174
|
+
- STAKING: EigenLayer deposits on Ethereum mainnet and Sepolia; Lido stake and wrap/unwrap on Ethereum mainnet. Withdrawal requests with dynamic amounts, claims with position-derived amounts and EigenLayer withdrawals are excluded from these bounded presets. A selected native asset supplies the Lido `submit` value cap; omitted caps remain zero.
|
|
175
175
|
- PREDICTION: no entries yet. Hide categories with empty `chains` lists.
|
|
176
176
|
|
|
177
177
|
```ts
|
|
@@ -195,11 +195,11 @@ function filledPreset(agent: Address, tokenIn: Address, tokenOut: Address) {
|
|
|
195
195
|
{ token: tokenOut, maxPerCall: BigInt(100), maxTotal: BigInt(1000) },
|
|
196
196
|
],
|
|
197
197
|
},
|
|
198
|
-
)
|
|
198
|
+
);
|
|
199
199
|
}
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
The example caps are illustrative raw units; choose caps for the actual token decimals and gas requirements. `get` groups calls into one rule per chain. With agent and expiry supplied,
|
|
202
|
+
The example caps are illustrative raw units; choose caps for the actual token decimals and gas requirements. `get` groups calls into one rule per chain. The result is `{ rules, readiness }`. With agent and expiry supplied, `rules` is typed as `Rule[]`; otherwise it is `PresetRuleTemplate[]`. This type distinction alone does not establish readiness. Assets must name their chain unless a single chain filter is supplied. Omitted asset caps and `maxGasPerCall` default to zero.
|
|
203
203
|
|
|
204
204
|
DEX discovery works without options, with an empty asset list, or with assets for only some chains. A chain with fewer than two tokens returns full-signature review calls with wallet-recipient pins and an explicit zero input-amount maximum. A single supplied token is also pinned as the input. These calls cannot spend swap input tokens, even if asset budgets are filled later. Call `get` again after selecting both tokens to replace the review calls with the complete token-pinned rules; merely assigning `rule.assets` is insufficient.
|
|
205
205
|
|
|
@@ -209,6 +209,59 @@ Reviewed EVM spenders generate approvals pinned to that spender and bounded by t
|
|
|
209
209
|
|
|
210
210
|
Templates describe permissions, not available liquidity or guaranteed execution. Verify destination token balances, supported reserves and source PRC20 routes before use: protocol testnet mock tokens may differ from MOVEABLE tokens. Presets do not sign, fetch app ABIs or modify wallets. Dynamic-path swaps, Solana protocol templates and unconfirmed deployments are excluded. Mainnet addresses were checked read-only; no mainnet transactions were executed. Other mainnet protocols in the proposal remain excluded until their deployment and permission constraints are verified. Local policy tests do not execute the destination protocols.
|
|
211
211
|
|
|
212
|
+
### Configure, inspect and regenerate
|
|
213
|
+
|
|
214
|
+
`readiness.ready` means the returned chains have locally complete inputs and at least one enabled asset operation. It does not check PRC20 availability, deployments, balances, live reserve flags or liquidity. `readiness.chains` gives per-chain `issues`, `disabledCalls`, `excludedCalls`, catalog `knownTokens` and `zeroBridgeLimits`. These are additive result fields; `rules` remains accepted by the existing create/update methods.
|
|
215
|
+
|
|
216
|
+
The UI should collect chain, agent, token selections, raw-unit limits, gas budget and expiry. Show zero-cap calls as disabled. Present excluded calls explicitly. There is no SDK-selected 0.1 PC gas budget or 30-day expiry. A zero bridge limit can be intentional when assets are already at the destination; it is reported separately from operation readiness.
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
async function createConfiguredDex(
|
|
220
|
+
client: PushChain, agent: Address, tokenIn: Address, tokenOut: Address,
|
|
221
|
+
) {
|
|
222
|
+
const configured = filledPreset(agent, tokenIn, tokenOut);
|
|
223
|
+
if (!configured.readiness.ready) {
|
|
224
|
+
// Render these issues in the configuration screen; do not present it as ready.
|
|
225
|
+
return { issues: configured.readiness.chains };
|
|
226
|
+
}
|
|
227
|
+
return client.agentic.create('My DEX agent', { rules: configured.rules });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async function replaceConfiguredDex(
|
|
231
|
+
client: PushChain, wallet: Address, rulesId: Hex,
|
|
232
|
+
agent: Address, tokenIn: Address, tokenOut: Address,
|
|
233
|
+
) {
|
|
234
|
+
// Re-run get after editing tokens or limits. Changing rule.assets alone
|
|
235
|
+
// does not regenerate allowedCalls, token pins or approvals.
|
|
236
|
+
const configured = filledPreset(agent, tokenIn, tokenOut);
|
|
237
|
+
if (!configured.readiness.ready) throw new Error('Complete the preset inputs');
|
|
238
|
+
return client.agentic.wallet(wallet).rules.update({
|
|
239
|
+
rules: [{ rulesId, rule: configured.rules[0] }],
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Save the preset category and editable inputs in the UI if subsequent edits should regenerate the preset. On-chain rules do not retain preset provenance or display metadata. A regenerated result is a replacement: do not append it to the old allowedCalls or keep the old token approvals. An update creates a new rulesId and resets counters, as documented above.
|
|
245
|
+
|
|
246
|
+
### Amount units and enforcement scope
|
|
247
|
+
|
|
248
|
+
| Preset operation | Generated restriction |
|
|
249
|
+
| --- | --- |
|
|
250
|
+
| DEX swap | Selected input/output token equality, wallet recipient, maximum input amount |
|
|
251
|
+
| Aave supply/withdraw/borrow/repay | Listed reserve token equality, wallet beneficiary, amount maximum |
|
|
252
|
+
| Moonwell/Venus mint/redeemUnderlying/borrow/repayBorrow | Maximum in the market's underlying-token units |
|
|
253
|
+
| EigenLayer deposit | Selected token equality and deposit amount maximum |
|
|
254
|
+
| Lido wrap/unwrap | stETH/wstETH input limits respectively; their units are not interchangeable |
|
|
255
|
+
| Lido submit | Native-value cap from the selected native asset's maxPerCall |
|
|
256
|
+
|
|
257
|
+
Aave reserve choices come from the reviewed official address book; fixed-token markets only enable for their actual underlying. Unknown assets do not receive an Aave approval or a positive Aave operation cap. A reserve listing is not a guarantee that its current supply cap, pause state or liquidity allows a transaction.
|
|
258
|
+
|
|
259
|
+
Market `redeem(uint256)` takes shares: it is excluded and `redeemUnderlying(uint256)` is provided instead. Lido's dynamic withdrawal arrays and position-based claims are also excluded because an underlying amount cap cannot safely be converted into those arguments by this pure helper. Custom rules remain possible through the normal rule API.
|
|
260
|
+
|
|
261
|
+
**A per-call limit applies to each allowed contract call, not the sum of several calls in one transaction. `maxTotal` is the cumulative Push-outbound amount, not lifetime turnover on the destination.** These statements also hold when a call's tokens are already in the CEA. Destination lifetime or batch-total accounting requires contract support. Bounded approvals do not supply such accounting.
|
|
262
|
+
|
|
263
|
+
The contract allows at most 32 pins across a universal rule. Expansion fails explicitly if the selected assets/apps exceed that ceiling; no restrictions are silently dropped. Two Aave reserves fit its four-operation template; three do not. Blank/incomplete inputs return zero-cap review calls, and regeneration replaces them with the selected token-specific calls.
|
|
264
|
+
|
|
212
265
|
## Validation
|
|
213
266
|
|
|
214
267
|
Run `node packages/core/scripts/check-agw-docs.js` to typecheck these examples. Unit tests use the normal core Jest configuration. `jest.agw-local.config.ts` uses pinned real AGW contracts and a stub gateway. Live E2Es are opt-in under `__e2e__/agw`; preflight verifies the deployment and funding limits. Local tests do not prove destination delivery, and historical live results do not count as validation of a changed public API.
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -2,4 +2,4 @@ export type { AgenticAddress, AgenticHex, AgenticDoor, AgenticNamespace, Agentic
|
|
|
2
2
|
export { AGENTIC_ERROR_CODE, AgenticError, AgenticRevertError } from './errors';
|
|
3
3
|
export type { AgenticErrorCode } from './errors';
|
|
4
4
|
export { AGENTIC } from './constants';
|
|
5
|
-
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, AgenticPresets, } from './presets/types';
|
|
5
|
+
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, PresetResult, PresetChainReadiness, PresetConfigurationIssue, PresetCallIssue, AgenticPresets, } from './presets/types';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Aave V3 reserve addresses from the official bgd-labs/aave-address-book
|
|
2
|
+
* snapshots reviewed October 15, 2026. Listings are not liquidity/availability guarantees. */
|
|
3
|
+
import type { Address } from 'viem';
|
|
4
|
+
export declare const AAVE_RESERVES: Readonly<Record<string, readonly Address[]>>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AAVE_RESERVES = void 0;
|
|
4
|
+
exports.AAVE_RESERVES = {
|
|
5
|
+
'eip155:1': [
|
|
6
|
+
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
7
|
+
'0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
8
|
+
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
9
|
+
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
10
|
+
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
11
|
+
'0x514910771AF9Ca656af840dff83E8264EcF986CA',
|
|
12
|
+
'0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9',
|
|
13
|
+
'0xBe9895146f7AF43049ca1c1AE358B0541Ea49704',
|
|
14
|
+
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
15
|
+
'0xae78736Cd615f374D3085123A210448E74Fc6393',
|
|
16
|
+
'0x5f98805A4E8be255a32880FDeC7F6728C6568bA0',
|
|
17
|
+
'0xD533a949740bb3306d119CC777fa900bA034cd52',
|
|
18
|
+
'0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2',
|
|
19
|
+
'0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F',
|
|
20
|
+
'0xba100000625a3754423978a60c9317c58a424e3D',
|
|
21
|
+
'0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
|
|
22
|
+
'0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32',
|
|
23
|
+
'0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72',
|
|
24
|
+
'0x111111111117dC0aa78b770fA6A738034120C302',
|
|
25
|
+
'0x853d955aCEf822Db058eb8505911ED77F175b99e',
|
|
26
|
+
'0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f',
|
|
27
|
+
'0xD33526068D116cE69F19A9ee46F0bd304F21A51f',
|
|
28
|
+
'0x83F20F44975D03b1b09e64809B757c47f942BEeA',
|
|
29
|
+
'0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6',
|
|
30
|
+
'0xdeFA4e8a7bcBA345F687a2f1456F5Edd9CE97202',
|
|
31
|
+
'0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0',
|
|
32
|
+
'0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
|
|
33
|
+
'0x6c3ea9036406852006290770BEdFcAbA0e23A0e8',
|
|
34
|
+
'0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
35
|
+
'0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38',
|
|
36
|
+
'0x4c9EDD5852cd905f086C759E8383e09bff1E68B3',
|
|
37
|
+
'0xA35b1B31Ce002FBF2058D22F30f95D405200A15b',
|
|
38
|
+
'0x9D39A5DE30e57443BfF2A8307A4256c8797A3497',
|
|
39
|
+
'0x18084fbA666a33d37592fA2633fD49a74DD93a88',
|
|
40
|
+
'0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
|
|
41
|
+
'0xdC035D45d973E3EC169d2276DDab16f1e407384F',
|
|
42
|
+
'0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7',
|
|
43
|
+
'0x8236a87084f8B84306f72007F36F2618A5634494',
|
|
44
|
+
'0x657e8C867D8B37dCC18fA4Caead9C45EB088C642',
|
|
45
|
+
'0x8292Bb45bf1Ee4d140127049757C2E0fF06317eD',
|
|
46
|
+
'0x50D2C7992b802Eef16c04FeADAB310f31866a545',
|
|
47
|
+
'0x3b3fB9C57858EF816833dC91565EFcd85D96f634',
|
|
48
|
+
'0xC139190F447e929f090Edeb554D95AbB8b18aC1C',
|
|
49
|
+
'0x917459337CaAC939D41d7493B3999f571D20D667',
|
|
50
|
+
'0x14Bdc3A3AE09f5518b923b69489CBcAfB238e617',
|
|
51
|
+
'0x90D2af7d622ca3141efA4d8f1F24d86E5974Cc8F',
|
|
52
|
+
'0xC96dE26018A54D51c097160568752c4E3BD6C364',
|
|
53
|
+
'0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
|
|
54
|
+
'0x9F56094C450763769BA0EA9Fe2876070c0fD5F77',
|
|
55
|
+
'0xBC6736d346a5eBC0dEbc997397912CD9b8FAe10a',
|
|
56
|
+
'0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8',
|
|
57
|
+
'0xbf5495Efe5DB9ce00f80364C8B423567e58d2110',
|
|
58
|
+
'0x68749665FF8D2d112Fa859AA293F07A622782F38',
|
|
59
|
+
'0xe6A934089BBEe34F832060CE98848359883749B3',
|
|
60
|
+
'0x62C6E813b9589C3631Ba0Cdb013acdB8544038B7',
|
|
61
|
+
'0x1F84a51296691320478c98b8d77f2Bbd17D34350',
|
|
62
|
+
'0xE8483517077afa11A9B07f849cee2552f040d7b2',
|
|
63
|
+
'0xacA92E438df0B2401fF60dA7E4337B687a2435DA',
|
|
64
|
+
'0x356B8d89c1e1239Cbbb9dE4815c39A1474d5BA7D',
|
|
65
|
+
'0xe343167631d89B6Ffc58B88d6b7fB0228795491D',
|
|
66
|
+
'0xAeBf0Bb9f57E89260d57f31AF34eB58657d96Ce0',
|
|
67
|
+
'0x3de0ff76E8b528C092d47b9DaC775931cef80F49',
|
|
68
|
+
'0x9Bf45ab47747F4B4dD09B3C2c73953484b4eB375',
|
|
69
|
+
'0xB0F70C0bD6FD87dbEb7C10dC692a2a6106817072',
|
|
70
|
+
'0x619D75E3b790eBC21c289f2805Bb7177A7D732E2',
|
|
71
|
+
'0x9db38D74a0D29380899aD354121DfB521aDb0548',
|
|
72
|
+
'0x59bC9FaE5D62B19d4f8d07D758047aCb9EE19d34',
|
|
73
|
+
],
|
|
74
|
+
'eip155:8453': [
|
|
75
|
+
'0x4200000000000000000000000000000000000006',
|
|
76
|
+
'0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22',
|
|
77
|
+
'0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
|
|
78
|
+
'0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452',
|
|
79
|
+
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
80
|
+
'0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A',
|
|
81
|
+
'0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
|
|
82
|
+
'0x2416092f143378750bb29b79eD961ab195CcEea5',
|
|
83
|
+
'0x6Bb7a212910682DCFdbd5BCBb3e28FB4E8da10Ee',
|
|
84
|
+
'0xEDfa23602D0EC14714057867A78d01e94176BEA0',
|
|
85
|
+
'0xecAc9C5F704e954931349Da37F60E39f515c11c1',
|
|
86
|
+
'0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
|
|
87
|
+
'0x63706e401c06ac8513145b7687A14804d17f814b',
|
|
88
|
+
'0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b',
|
|
89
|
+
'0x660975730059246A68521a3e2FBD4740173100f5',
|
|
90
|
+
],
|
|
91
|
+
'eip155:42161': [
|
|
92
|
+
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
|
|
93
|
+
'0xf97f4df75117a78c1A5a0DBb814Af92458539FB4',
|
|
94
|
+
'0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
|
|
95
|
+
'0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
|
|
96
|
+
'0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
97
|
+
'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
|
|
98
|
+
'0xba5DdD1f9d7F570dc94a51479a000E3BCE967196',
|
|
99
|
+
'0xD22a58f79e9481D1a88e00c343885A588b34b68B',
|
|
100
|
+
'0x5979D7b546E38E414F7E9822514be443A4800529',
|
|
101
|
+
'0x3F56e0c36d275367b8C502090EDF38289b3dEa0d',
|
|
102
|
+
'0xEC70Dcb4A1EFa46b8F2D97C310C9c4790ba5ffA8',
|
|
103
|
+
'0x93b346b6BC2548dA6A1E7d98E9a421B42541425b',
|
|
104
|
+
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
105
|
+
'0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F',
|
|
106
|
+
'0x912CE59144191C1204E64559FE8253a0e49E6548',
|
|
107
|
+
'0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe',
|
|
108
|
+
'0x7dfF72693f6A4149b17e7C6314655f6A9F7c8B33',
|
|
109
|
+
'0x2416092f143378750bb29b79eD961ab195CcEea5',
|
|
110
|
+
'0x4186BFC76E2E237523CBC30FD220FE055156b41F',
|
|
111
|
+
'0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40',
|
|
112
|
+
],
|
|
113
|
+
'eip155:56': [
|
|
114
|
+
'0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82',
|
|
115
|
+
'0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
116
|
+
'0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c',
|
|
117
|
+
'0x2170Ed0880ac9A755fd29B2688956BD959F933F8',
|
|
118
|
+
'0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
119
|
+
'0x55d398326f99059fF775485246999027B3197955',
|
|
120
|
+
'0xc5f0f7b66764F6ec8C8Dff7BA683102295E16409',
|
|
121
|
+
'0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C',
|
|
122
|
+
],
|
|
123
|
+
'eip155:11155111': [
|
|
124
|
+
'0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357',
|
|
125
|
+
'0xf8Fb3713D459D7C1018BD0A49D19b4C44290EBE5',
|
|
126
|
+
'0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8',
|
|
127
|
+
'0x29f2D40B0605204364af54EC677bD022dA425d03',
|
|
128
|
+
'0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c',
|
|
129
|
+
'0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0',
|
|
130
|
+
'0x88541670E55cC00bEEFD87eB59EDd1b7C511AC9a',
|
|
131
|
+
'0x6d906e526a4e2Ca02097BA9d0caA3c382F52278E',
|
|
132
|
+
'0xc4bF5CbDaBE595361438F8c6a187bDc330539c60',
|
|
133
|
+
],
|
|
134
|
+
'eip155:84532': [
|
|
135
|
+
'0xba50Cd2A20f6DA35D788639E581bca8d0B5d4D5f',
|
|
136
|
+
'0x0a215D8ba66387DCA84B284D18c3B4ec3de6E54a',
|
|
137
|
+
'0x54114591963CF60EF3aA63bEfD6eC263D98145a4',
|
|
138
|
+
'0x4200000000000000000000000000000000000006',
|
|
139
|
+
'0xD171b9694f7A2597Ed006D41f7509aaD4B485c4B',
|
|
140
|
+
'0x810D46F9a9027E28F9B01F75E2bdde839dA61115',
|
|
141
|
+
],
|
|
142
|
+
'eip155:421614': [
|
|
143
|
+
'0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
|
|
144
|
+
'0x1dF462e2712496373A347f8ad10802a5E95f053D',
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=aave-reserves.js.map
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { type Address } from 'viem';
|
|
2
2
|
import type { RuleCall, ForeignChainNamespace } from '../agentic.types';
|
|
3
3
|
import type { PresetCategory } from './types';
|
|
4
|
+
export type PresetBudget = {
|
|
5
|
+
kind: 'token-argument';
|
|
6
|
+
tokenArg: number;
|
|
7
|
+
amountArg: number;
|
|
8
|
+
tokens?: readonly Address[];
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'fixed-token';
|
|
11
|
+
token: Address;
|
|
12
|
+
amountArg: number;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'native-value';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'setup';
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'unsupported';
|
|
19
|
+
reason: 'SHARE_AMOUNT' | 'DYNAMIC_AMOUNT' | 'POSITION_AMOUNT';
|
|
20
|
+
alternative?: RuleCall['selector'];
|
|
21
|
+
};
|
|
22
|
+
export interface PresetCallDefinition extends RuleCall {
|
|
23
|
+
budget?: PresetBudget;
|
|
24
|
+
}
|
|
4
25
|
/** Internal catalog: reviewed addresses and explicit calls only; never fetched at runtime. */
|
|
5
26
|
export interface PresetChainDefinition {
|
|
6
27
|
chainNamespace: ForeignChainNamespace;
|
|
7
|
-
allowedCalls: readonly
|
|
28
|
+
allowedCalls: readonly PresetCallDefinition[];
|
|
8
29
|
/** Static single-hop routers; incomplete pairs return zero-input-cap review calls. */
|
|
9
30
|
swapRouters?: readonly {
|
|
10
31
|
address: Address;
|
|
@@ -15,6 +36,7 @@ export interface PresetChainDefinition {
|
|
|
15
36
|
spender: Address;
|
|
16
37
|
app: string;
|
|
17
38
|
token?: Address;
|
|
39
|
+
tokens?: readonly Address[];
|
|
18
40
|
}[];
|
|
19
41
|
maxGasPerCall?: bigint;
|
|
20
42
|
}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PRESET_CATALOG = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
|
+
const aave_reserves_1 = require("./aave-reserves");
|
|
5
6
|
/** Mainnet and testnet templates from the October 15 Notion export and protocol sources.
|
|
6
7
|
* Read-only deployment/code evidence and exclusions: plan/agw/research/preset-catalog-2026-10-15/.
|
|
7
8
|
* Mainnet entries are templates only; no mainnet deployment or execution guarantee.
|
|
8
9
|
*/
|
|
9
10
|
const address = (value) => (0, viem_1.getAddress)(value.toLowerCase());
|
|
10
11
|
const wallet = 'agentic:wallet';
|
|
11
|
-
const aave = (pool) => [
|
|
12
|
+
const aave = (pool, chain) => [
|
|
12
13
|
['supply(address,uint256,address,uint16)', 2, 'Supply'],
|
|
13
14
|
['withdraw(address,uint256,address)', 2, 'Withdraw'],
|
|
14
15
|
['borrow(address,uint256,uint256,uint16,address)', 4, 'Borrow'],
|
|
@@ -19,8 +20,14 @@ const aave = (pool) => [
|
|
|
19
20
|
pins: [{ arg: arg, expected: wallet }],
|
|
20
21
|
app: 'Aave V3',
|
|
21
22
|
label: label,
|
|
23
|
+
budget: {
|
|
24
|
+
kind: 'token-argument',
|
|
25
|
+
tokenArg: 0,
|
|
26
|
+
amountArg: 1,
|
|
27
|
+
tokens: aave_reserves_1.AAVE_RESERVES[chain],
|
|
28
|
+
},
|
|
22
29
|
}));
|
|
23
|
-
const market = (target, app) => [
|
|
30
|
+
const market = (target, app, token) => [
|
|
24
31
|
'mint(uint256)',
|
|
25
32
|
'redeem(uint256)',
|
|
26
33
|
'redeemUnderlying(uint256)',
|
|
@@ -31,6 +38,13 @@ const market = (target, app) => [
|
|
|
31
38
|
selector: selector,
|
|
32
39
|
app,
|
|
33
40
|
label: selector.split('(')[0],
|
|
41
|
+
budget: selector === 'redeem(uint256)'
|
|
42
|
+
? {
|
|
43
|
+
kind: 'unsupported',
|
|
44
|
+
reason: 'SHARE_AMOUNT',
|
|
45
|
+
alternative: 'redeemUnderlying(uint256)',
|
|
46
|
+
}
|
|
47
|
+
: { kind: 'fixed-token', token, amountArg: 0 },
|
|
34
48
|
}));
|
|
35
49
|
const sepoliaPool = address('0x6Ae43d3271ff6888e7Fc43Fd7321a503ff738951');
|
|
36
50
|
const basePool = address('0x8bAB6d1b75f19e9eD9fCe8b9BD338844fF79aE27');
|
|
@@ -76,7 +90,7 @@ const mainnetMarkets = (chain) => {
|
|
|
76
90
|
: '0xfD36E2c2a6789Db23113685031d7F16329158384';
|
|
77
91
|
return {
|
|
78
92
|
allowedCalls: [
|
|
79
|
-
...entries.flatMap(([target, app]) => market(address(target), app)),
|
|
93
|
+
...entries.flatMap(([target, app, token]) => market(address(target), app, address(token))),
|
|
80
94
|
...(entries.length
|
|
81
95
|
? [
|
|
82
96
|
{
|
|
@@ -84,6 +98,7 @@ const mainnetMarkets = (chain) => {
|
|
|
84
98
|
selector: 'enterMarkets(address[])',
|
|
85
99
|
app: chain === 'eip155:8453' ? 'Moonwell' : 'Venus',
|
|
86
100
|
label: 'Enter markets',
|
|
101
|
+
budget: { kind: 'setup' },
|
|
87
102
|
},
|
|
88
103
|
]
|
|
89
104
|
: []),
|
|
@@ -155,39 +170,60 @@ exports.PRESET_CATALOG = [
|
|
|
155
170
|
].map(([chainNamespace, pool]) => ({
|
|
156
171
|
chainNamespace,
|
|
157
172
|
allowedCalls: [
|
|
158
|
-
...aave(address(pool)),
|
|
173
|
+
...aave(address(pool), chainNamespace),
|
|
159
174
|
...mainnetMarkets(chainNamespace).allowedCalls,
|
|
160
175
|
],
|
|
161
176
|
approvals: [
|
|
162
|
-
{
|
|
177
|
+
{
|
|
178
|
+
spender: address(pool),
|
|
179
|
+
app: 'Aave V3',
|
|
180
|
+
tokens: aave_reserves_1.AAVE_RESERVES[chainNamespace],
|
|
181
|
+
},
|
|
163
182
|
...(mainnetMarkets(chainNamespace).approvals ?? []),
|
|
164
183
|
],
|
|
165
184
|
})),
|
|
166
185
|
{
|
|
167
186
|
chainNamespace: 'eip155:11155111',
|
|
168
|
-
allowedCalls: aave(sepoliaPool),
|
|
169
|
-
approvals: [
|
|
187
|
+
allowedCalls: aave(sepoliaPool, 'eip155:11155111'),
|
|
188
|
+
approvals: [
|
|
189
|
+
{
|
|
190
|
+
spender: sepoliaPool,
|
|
191
|
+
app: 'Aave V3',
|
|
192
|
+
tokens: aave_reserves_1.AAVE_RESERVES['eip155:11155111'],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
170
195
|
},
|
|
171
196
|
{
|
|
172
197
|
chainNamespace: 'eip155:421614',
|
|
173
|
-
allowedCalls: aave(arbitrumPool),
|
|
174
|
-
approvals: [
|
|
198
|
+
allowedCalls: aave(arbitrumPool, 'eip155:421614'),
|
|
199
|
+
approvals: [
|
|
200
|
+
{
|
|
201
|
+
spender: arbitrumPool,
|
|
202
|
+
app: 'Aave V3',
|
|
203
|
+
tokens: aave_reserves_1.AAVE_RESERVES['eip155:421614'],
|
|
204
|
+
},
|
|
205
|
+
],
|
|
175
206
|
},
|
|
176
207
|
{
|
|
177
208
|
chainNamespace: 'eip155:84532',
|
|
178
209
|
allowedCalls: [
|
|
179
|
-
...aave(basePool),
|
|
180
|
-
...market(moonUSDBC, 'Moonwell mUSDbC'),
|
|
181
|
-
...market(moonWETH, 'Moonwell mWETH'),
|
|
210
|
+
...aave(basePool, 'eip155:84532'),
|
|
211
|
+
...market(moonUSDBC, 'Moonwell mUSDbC', address('0x4616975f7E6045FD9737e95bC527e9e14c727BD2')),
|
|
212
|
+
...market(moonWETH, 'Moonwell mWETH', address('0x663A6F02d547dFd639BF689FED298712f2FB69Fb')),
|
|
182
213
|
{
|
|
183
214
|
target: address('0xC72ba45f2Ae134F21DAEb2b7B5fd5De0064Ee9bB'),
|
|
184
215
|
selector: 'enterMarkets(address[])',
|
|
185
216
|
app: 'Moonwell',
|
|
186
217
|
label: 'Enter markets',
|
|
218
|
+
budget: { kind: 'setup' },
|
|
187
219
|
},
|
|
188
220
|
],
|
|
189
221
|
approvals: [
|
|
190
|
-
{
|
|
222
|
+
{
|
|
223
|
+
spender: basePool,
|
|
224
|
+
app: 'Aave V3',
|
|
225
|
+
tokens: aave_reserves_1.AAVE_RESERVES['eip155:84532'],
|
|
226
|
+
},
|
|
191
227
|
{
|
|
192
228
|
spender: moonUSDBC,
|
|
193
229
|
app: 'Moonwell mUSDbC',
|
|
@@ -203,13 +239,14 @@ exports.PRESET_CATALOG = [
|
|
|
203
239
|
{
|
|
204
240
|
chainNamespace: 'eip155:97',
|
|
205
241
|
allowedCalls: [
|
|
206
|
-
...market(venusUSDT, 'Venus vUSDT'),
|
|
207
|
-
...market(venusUSDC, 'Venus vUSDC'),
|
|
242
|
+
...market(venusUSDT, 'Venus vUSDT', address('0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c')),
|
|
243
|
+
...market(venusUSDC, 'Venus vUSDC', address('0x16227D60f7a0e586C66B005219dfc887D13C9531')),
|
|
208
244
|
{
|
|
209
245
|
target: address('0x94d1820b2D1c7c7452A163983Dc888CEC546b77D'),
|
|
210
246
|
selector: 'enterMarkets(address[])',
|
|
211
247
|
app: 'Venus',
|
|
212
248
|
label: 'Enter markets',
|
|
249
|
+
budget: { kind: 'setup' },
|
|
213
250
|
},
|
|
214
251
|
],
|
|
215
252
|
approvals: [
|
|
@@ -239,19 +276,22 @@ exports.PRESET_CATALOG = [
|
|
|
239
276
|
selector: 'submit(address)',
|
|
240
277
|
maxValue: BigInt(0),
|
|
241
278
|
app: 'Lido',
|
|
242
|
-
label: 'Stake ETH
|
|
279
|
+
label: 'Stake ETH',
|
|
280
|
+
budget: { kind: 'native-value' },
|
|
243
281
|
},
|
|
244
282
|
{
|
|
245
283
|
target: wstETH,
|
|
246
284
|
selector: 'wrap(uint256)',
|
|
247
285
|
app: 'Lido wstETH',
|
|
248
286
|
label: 'Wrap stETH',
|
|
287
|
+
budget: { kind: 'fixed-token', token: stETH, amountArg: 0 },
|
|
249
288
|
},
|
|
250
289
|
{
|
|
251
290
|
target: wstETH,
|
|
252
291
|
selector: 'unwrap(uint256)',
|
|
253
292
|
app: 'Lido wstETH',
|
|
254
293
|
label: 'Unwrap wstETH',
|
|
294
|
+
budget: { kind: 'fixed-token', token: wstETH, amountArg: 0 },
|
|
255
295
|
},
|
|
256
296
|
{
|
|
257
297
|
target: lidoQueue,
|
|
@@ -259,29 +299,32 @@ exports.PRESET_CATALOG = [
|
|
|
259
299
|
pins: [{ arg: 1, expected: wallet }],
|
|
260
300
|
app: 'Lido withdrawal queue',
|
|
261
301
|
label: 'Request withdrawal',
|
|
302
|
+
budget: { kind: 'unsupported', reason: 'DYNAMIC_AMOUNT' },
|
|
262
303
|
},
|
|
263
304
|
{
|
|
264
305
|
target: lidoQueue,
|
|
265
306
|
selector: 'claimWithdrawals(uint256[],uint256[])',
|
|
266
307
|
app: 'Lido withdrawal queue',
|
|
267
308
|
label: 'Claim finalized withdrawals',
|
|
309
|
+
budget: { kind: 'unsupported', reason: 'POSITION_AMOUNT' },
|
|
268
310
|
},
|
|
269
311
|
{
|
|
270
312
|
target: lidoQueue,
|
|
271
313
|
selector: 'claimWithdrawal(uint256)',
|
|
272
314
|
app: 'Lido withdrawal queue',
|
|
273
315
|
label: 'Claim finalized withdrawal',
|
|
316
|
+
budget: { kind: 'unsupported', reason: 'POSITION_AMOUNT' },
|
|
274
317
|
},
|
|
275
318
|
{
|
|
276
319
|
target: address('0x858646372CC42E1A627fcE94aa7A7033e7CF075A'),
|
|
277
320
|
selector: 'depositIntoStrategy(address,address,uint256)',
|
|
278
321
|
app: 'EigenLayer',
|
|
279
322
|
label: 'Deposit into strategy (withdrawals not included)',
|
|
323
|
+
budget: { kind: 'token-argument', tokenArg: 1, amountArg: 2 },
|
|
280
324
|
},
|
|
281
325
|
],
|
|
282
326
|
approvals: [
|
|
283
327
|
{ spender: wstETH, token: stETH, app: 'Lido wstETH' },
|
|
284
|
-
{ spender: lidoQueue, token: stETH, app: 'Lido withdrawal queue' },
|
|
285
328
|
{
|
|
286
329
|
spender: address('0x858646372CC42E1A627fcE94aa7A7033e7CF075A'),
|
|
287
330
|
app: 'EigenLayer',
|
|
@@ -296,6 +339,7 @@ exports.PRESET_CATALOG = [
|
|
|
296
339
|
selector: 'depositIntoStrategy(address,address,uint256)',
|
|
297
340
|
app: 'EigenLayer',
|
|
298
341
|
label: 'Deposit into strategy (withdrawals not included)',
|
|
342
|
+
budget: { kind: 'token-argument', tokenArg: 1, amountArg: 2 },
|
|
299
343
|
},
|
|
300
344
|
],
|
|
301
345
|
approvals: [{ spender: eigen, app: 'EigenLayer' }],
|
|
@@ -6,6 +6,7 @@ const viem_1 = require("viem");
|
|
|
6
6
|
const errors_1 = require("../errors");
|
|
7
7
|
const selectors_1 = require("../codec/selectors");
|
|
8
8
|
const catalog_1 = require("./catalog");
|
|
9
|
+
const operation_limits_1 = require("./operation-limits");
|
|
9
10
|
const MAX_UINT256 = (BigInt(1) << BigInt(256)) - BigInt(1);
|
|
10
11
|
const invalid = (message) => new errors_1.AgenticError(errors_1.AGENTIC_ERROR_CODE.INVALID_RULE, message);
|
|
11
12
|
function cap(value, name) {
|
|
@@ -50,8 +51,23 @@ function buildPresetApi(catalog) {
|
|
|
50
51
|
...p,
|
|
51
52
|
chains: p.chains.map((c) => ({
|
|
52
53
|
...c,
|
|
53
|
-
allowedCalls: c.allowedCalls.map(
|
|
54
|
-
|
|
54
|
+
allowedCalls: c.allowedCalls.map((call) => ({
|
|
55
|
+
...copyCall(call),
|
|
56
|
+
...(call.budget
|
|
57
|
+
? {
|
|
58
|
+
budget: {
|
|
59
|
+
...call.budget,
|
|
60
|
+
...(call.budget.kind === 'token-argument' && call.budget.tokens
|
|
61
|
+
? { tokens: [...call.budget.tokens] }
|
|
62
|
+
: {}),
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
: {}),
|
|
66
|
+
})),
|
|
67
|
+
approvals: c.approvals?.map((a) => ({
|
|
68
|
+
...a,
|
|
69
|
+
...(a.tokens ? { tokens: [...a.tokens] } : {}),
|
|
70
|
+
})),
|
|
55
71
|
swapRouters: c.swapRouters?.map((r) => ({ ...r })),
|
|
56
72
|
})),
|
|
57
73
|
}));
|
|
@@ -125,8 +141,14 @@ function buildPresetApi(catalog) {
|
|
|
125
141
|
});
|
|
126
142
|
assets.set(chain, group);
|
|
127
143
|
}
|
|
144
|
+
const readiness = [];
|
|
128
145
|
const rules = chains.map((chain) => {
|
|
129
|
-
const
|
|
146
|
+
const selectedAssets = assets.get(chain.chainNamespace) ?? [];
|
|
147
|
+
const limits = (0, operation_limits_1.applyOperationLimits)(chain.allowedCalls.map((c) => ({
|
|
148
|
+
...copyCall(c),
|
|
149
|
+
...(c.budget ? { budget: c.budget } : {}),
|
|
150
|
+
})), selectedAssets);
|
|
151
|
+
const calls = limits.calls;
|
|
130
152
|
if (chain.swapRouters?.length) {
|
|
131
153
|
const tokens = assets.get(chain.chainNamespace) ?? [];
|
|
132
154
|
if (tokens.some((a) => tokenAddress(a.token) === viem_1.zeroAddress ||
|
|
@@ -185,6 +207,21 @@ function buildPresetApi(catalog) {
|
|
|
185
207
|
});
|
|
186
208
|
}
|
|
187
209
|
}
|
|
210
|
+
if (chain.swapRouters?.length) {
|
|
211
|
+
const swaps = calls.filter((c) => c.selector.startsWith('exact'));
|
|
212
|
+
for (const c of swaps) {
|
|
213
|
+
const positive = c.pins?.some((p) => 'max' in p && p.max !== undefined && p.max > BigInt(0));
|
|
214
|
+
if (positive)
|
|
215
|
+
limits.enabled = true;
|
|
216
|
+
else
|
|
217
|
+
limits.disabledCalls.push({
|
|
218
|
+
target: c.target,
|
|
219
|
+
selector: c.selector,
|
|
220
|
+
app: c.app,
|
|
221
|
+
reason: selectedAssets.length < 2 ? 'TOKEN_REQUIRED' : 'ZERO_CAP',
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
188
225
|
const approvals = new Set();
|
|
189
226
|
for (const asset of assets.get(chain.chainNamespace) ?? []) {
|
|
190
227
|
const token = tokenAddress(asset.token);
|
|
@@ -198,6 +235,9 @@ function buildPresetApi(catalog) {
|
|
|
198
235
|
if (approval.token &&
|
|
199
236
|
(0, viem_1.getAddress)(token) !== (0, viem_1.getAddress)(approval.token))
|
|
200
237
|
continue;
|
|
238
|
+
if (approval.tokens &&
|
|
239
|
+
!approval.tokens.some((t) => (0, viem_1.getAddress)(t) === (0, viem_1.getAddress)(token)))
|
|
240
|
+
continue;
|
|
201
241
|
const spender = (0, viem_1.getAddress)(approval.spender);
|
|
202
242
|
const target = (0, viem_1.getAddress)(token);
|
|
203
243
|
const approvalKey = `${target}:${spender}`;
|
|
@@ -236,6 +276,49 @@ function buildPresetApi(catalog) {
|
|
|
236
276
|
throw (0, errors_1.capabilityUnavailable)('presetCalls', 'an unpinned alternative would bypass restrictions for this target/function');
|
|
237
277
|
pairs.set(pair, !!call.pins?.length);
|
|
238
278
|
}
|
|
279
|
+
const issues = [];
|
|
280
|
+
if (!options.agent)
|
|
281
|
+
issues.push({
|
|
282
|
+
code: 'AGENT_REQUIRED',
|
|
283
|
+
message: 'Choose the agent Push address.',
|
|
284
|
+
});
|
|
285
|
+
if (!options.validUntil)
|
|
286
|
+
issues.push({
|
|
287
|
+
code: 'EXPIRY_REQUIRED',
|
|
288
|
+
message: 'Choose an expiry.',
|
|
289
|
+
});
|
|
290
|
+
if ((options.maxGasPerCall ?? chain.maxGasPerCall ?? BigInt(0)) ===
|
|
291
|
+
BigInt(0))
|
|
292
|
+
issues.push({
|
|
293
|
+
code: 'GAS_BUDGET_REQUIRED',
|
|
294
|
+
message: 'Set a positive PC gas budget per outbound.',
|
|
295
|
+
});
|
|
296
|
+
if (!selectedAssets.length)
|
|
297
|
+
issues.push({
|
|
298
|
+
code: 'ASSETS_REQUIRED',
|
|
299
|
+
message: 'Choose tokens and their limits, then regenerate this preset.',
|
|
300
|
+
});
|
|
301
|
+
if (chain.swapRouters?.length && selectedAssets.length < 2)
|
|
302
|
+
issues.push({
|
|
303
|
+
code: 'TOKEN_PAIR_REQUIRED',
|
|
304
|
+
message: 'Choose both swap tokens, then regenerate this preset.',
|
|
305
|
+
});
|
|
306
|
+
if (!limits.enabled)
|
|
307
|
+
issues.push({
|
|
308
|
+
code: 'NO_ENABLED_OPERATION',
|
|
309
|
+
message: 'No asset operation has a positive per-call limit.',
|
|
310
|
+
});
|
|
311
|
+
readiness.push({
|
|
312
|
+
chainNamespace: chain.chainNamespace,
|
|
313
|
+
ready: issues.length === 0,
|
|
314
|
+
issues,
|
|
315
|
+
disabledCalls: limits.disabledCalls,
|
|
316
|
+
excludedCalls: limits.excludedCalls,
|
|
317
|
+
knownTokens: limits.knownTokens,
|
|
318
|
+
zeroBridgeLimits: selectedAssets
|
|
319
|
+
.filter((a) => a.maxPerCall === BigInt(0) || a.maxTotal === BigInt(0))
|
|
320
|
+
.map(operation_limits_1.assetAddress),
|
|
321
|
+
});
|
|
239
322
|
return {
|
|
240
323
|
chainNamespace: chain.chainNamespace,
|
|
241
324
|
allowedCalls: calls,
|
|
@@ -255,7 +338,13 @@ function buildPresetApi(catalog) {
|
|
|
255
338
|
: {}),
|
|
256
339
|
};
|
|
257
340
|
});
|
|
258
|
-
return {
|
|
341
|
+
return {
|
|
342
|
+
rules,
|
|
343
|
+
readiness: {
|
|
344
|
+
ready: readiness.length > 0 && readiness.every((c) => c.ready),
|
|
345
|
+
chains: readiness,
|
|
346
|
+
},
|
|
347
|
+
};
|
|
259
348
|
},
|
|
260
349
|
};
|
|
261
350
|
// The overload narrows templates only when both required fields were supplied and validated.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuleAsset, RuleCall } from '../agentic.types';
|
|
2
|
+
import type { PresetCallDefinition } from './catalog';
|
|
3
|
+
import type { PresetCallIssue } from './types';
|
|
4
|
+
export declare const assetAddress: (asset: RuleAsset) => string;
|
|
5
|
+
export declare const nativeAsset: (asset: RuleAsset) => boolean;
|
|
6
|
+
/** Compile reviewed protocol argument positions. No exchange-rate or share guesses. */
|
|
7
|
+
export declare function applyOperationLimits(definitions: readonly PresetCallDefinition[], assets: RuleAsset[]): {
|
|
8
|
+
calls: RuleCall[];
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
disabledCalls: PresetCallIssue[];
|
|
11
|
+
excludedCalls: PresetCallIssue[];
|
|
12
|
+
knownTokens: string[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nativeAsset = exports.assetAddress = void 0;
|
|
4
|
+
exports.applyOperationLimits = applyOperationLimits;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const assetAddress = (asset) => typeof asset.token === 'string' ? asset.token : asset.token.address;
|
|
7
|
+
exports.assetAddress = assetAddress;
|
|
8
|
+
const nativeAsset = (asset) => (0, exports.assetAddress)(asset) === viem_1.zeroAddress ||
|
|
9
|
+
(typeof asset.token !== 'string' && asset.token.mechanism === 'native');
|
|
10
|
+
exports.nativeAsset = nativeAsset;
|
|
11
|
+
/** Compile reviewed protocol argument positions. No exchange-rate or share guesses. */
|
|
12
|
+
function applyOperationLimits(definitions, assets) {
|
|
13
|
+
const matches = (definition) => {
|
|
14
|
+
const b = definition.budget;
|
|
15
|
+
if (!b)
|
|
16
|
+
return [];
|
|
17
|
+
if (b.kind === 'native-value')
|
|
18
|
+
return assets.filter(exports.nativeAsset);
|
|
19
|
+
if (b.kind === 'fixed-token')
|
|
20
|
+
return assets.filter((a) => !(0, exports.nativeAsset)(a) && (0, viem_1.getAddress)((0, exports.assetAddress)(a)) === (0, viem_1.getAddress)(b.token));
|
|
21
|
+
if (b.kind === 'token-argument')
|
|
22
|
+
return assets.filter((a) => !(0, exports.nativeAsset)(a) &&
|
|
23
|
+
(!b.tokens ||
|
|
24
|
+
b.tokens.some((t) => (0, viem_1.getAddress)(t) === (0, viem_1.getAddress)((0, exports.assetAddress)(a)))));
|
|
25
|
+
return [];
|
|
26
|
+
};
|
|
27
|
+
const previewAll = !definitions.some((d) => matches(d).length > 0);
|
|
28
|
+
const calls = [];
|
|
29
|
+
const disabledCalls = [], excludedCalls = [];
|
|
30
|
+
const knownTokens = new Set();
|
|
31
|
+
let enabled = false;
|
|
32
|
+
for (const definition of definitions) {
|
|
33
|
+
const { budget, ...call } = definition;
|
|
34
|
+
if (!budget || budget.kind === 'setup') {
|
|
35
|
+
calls.push(call);
|
|
36
|
+
if (!budget)
|
|
37
|
+
enabled = true; // Non-budgeted internal fixture entries only.
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const info = {
|
|
41
|
+
target: call.target,
|
|
42
|
+
selector: call.selector,
|
|
43
|
+
...(call.app ? { app: call.app } : {}),
|
|
44
|
+
};
|
|
45
|
+
if (budget.kind === 'unsupported') {
|
|
46
|
+
excludedCalls.push({
|
|
47
|
+
...info,
|
|
48
|
+
reason: budget.reason,
|
|
49
|
+
...(budget.alternative ? { alternative: budget.alternative } : {}),
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (budget.kind === 'fixed-token')
|
|
54
|
+
knownTokens.add((0, viem_1.getAddress)(budget.token));
|
|
55
|
+
if (budget.kind === 'native-value')
|
|
56
|
+
knownTokens.add(viem_1.zeroAddress);
|
|
57
|
+
if (budget.kind === 'token-argument')
|
|
58
|
+
budget.tokens?.forEach((t) => knownTokens.add((0, viem_1.getAddress)(t)));
|
|
59
|
+
const selected = matches(definition);
|
|
60
|
+
if (!selected.length && !previewAll) {
|
|
61
|
+
excludedCalls.push({
|
|
62
|
+
...info,
|
|
63
|
+
reason: 'UNSELECTED_TOKEN',
|
|
64
|
+
...(budget.kind === 'fixed-token'
|
|
65
|
+
? { token: (0, viem_1.getAddress)(budget.token) }
|
|
66
|
+
: {}),
|
|
67
|
+
});
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const asset of selected.length ? selected : [undefined]) {
|
|
71
|
+
const maximum = asset?.maxPerCall ?? BigInt(0);
|
|
72
|
+
const pins = [...(call.pins ?? [])];
|
|
73
|
+
if (budget.kind === 'token-argument' && asset)
|
|
74
|
+
pins.push({
|
|
75
|
+
arg: budget.tokenArg,
|
|
76
|
+
expected: (0, viem_1.getAddress)((0, exports.assetAddress)(asset)),
|
|
77
|
+
});
|
|
78
|
+
if (budget.kind !== 'native-value')
|
|
79
|
+
pins.push({ arg: budget.amountArg, max: maximum });
|
|
80
|
+
calls.push({
|
|
81
|
+
...call,
|
|
82
|
+
...(pins.length ? { pins } : {}),
|
|
83
|
+
...(budget.kind === 'native-value' ? { maxValue: maximum } : {}),
|
|
84
|
+
});
|
|
85
|
+
if (maximum > BigInt(0))
|
|
86
|
+
enabled = true;
|
|
87
|
+
else
|
|
88
|
+
disabledCalls.push({
|
|
89
|
+
...info,
|
|
90
|
+
reason: asset
|
|
91
|
+
? 'ZERO_CAP'
|
|
92
|
+
: assets.length
|
|
93
|
+
? 'UNSELECTED_TOKEN'
|
|
94
|
+
: 'TOKEN_REQUIRED',
|
|
95
|
+
...(asset
|
|
96
|
+
? { token: (0, exports.assetAddress)(asset) }
|
|
97
|
+
: budget.kind === 'fixed-token'
|
|
98
|
+
? { token: (0, viem_1.getAddress)(budget.token) }
|
|
99
|
+
: {}),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
calls,
|
|
105
|
+
enabled,
|
|
106
|
+
disabledCalls,
|
|
107
|
+
excludedCalls,
|
|
108
|
+
knownTokens: [...knownTokens],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=operation-limits.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from 'viem';
|
|
2
|
-
import type { Rule, RuleAsset, ForeignChainNamespace } from '../agentic.types';
|
|
2
|
+
import type { Rule, RuleAsset, RuleCall, ForeignChainNamespace } from '../agentic.types';
|
|
3
3
|
export type PresetCategory = 'DEXES' | 'LENDING' | 'STAKING' | 'PREDICTION';
|
|
4
4
|
export interface Preset {
|
|
5
5
|
type: 'CATEGORY';
|
|
@@ -15,8 +15,10 @@ export type PresetRuleTemplate = Omit<Rule, 'agent' | 'validUntil'> & {
|
|
|
15
15
|
export interface PresetAsset {
|
|
16
16
|
chainNamespace?: ForeignChainNamespace;
|
|
17
17
|
token: RuleAsset['token'];
|
|
18
|
-
/**
|
|
18
|
+
/** Per allowed operation and per Push outbound, in raw token units. Omitted = 0.
|
|
19
|
+
* Does not aggregate multiple destination calls in one transaction. */
|
|
19
20
|
maxPerCall?: bigint;
|
|
21
|
+
/** Cumulative Push-outbound amount only; not lifetime activity on destination-held assets. Omitted = 0. */
|
|
20
22
|
maxTotal?: bigint;
|
|
21
23
|
}
|
|
22
24
|
export interface PresetOptions {
|
|
@@ -33,16 +35,45 @@ export interface ReadyPresetOptions extends PresetOptions {
|
|
|
33
35
|
agent: Address;
|
|
34
36
|
validUntil: number;
|
|
35
37
|
}
|
|
38
|
+
/** Offline configuration only: does not check deployment, reserves, balances or liquidity. */
|
|
39
|
+
export interface PresetConfigurationIssue {
|
|
40
|
+
code: 'AGENT_REQUIRED' | 'EXPIRY_REQUIRED' | 'GAS_BUDGET_REQUIRED' | 'ASSETS_REQUIRED' | 'TOKEN_PAIR_REQUIRED' | 'NO_ENABLED_OPERATION';
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PresetCallIssue {
|
|
44
|
+
target: string;
|
|
45
|
+
selector: RuleCall['selector'];
|
|
46
|
+
app?: string;
|
|
47
|
+
reason: 'TOKEN_REQUIRED' | 'ZERO_CAP' | 'UNSELECTED_TOKEN' | 'SHARE_AMOUNT' | 'DYNAMIC_AMOUNT' | 'POSITION_AMOUNT';
|
|
48
|
+
token?: string;
|
|
49
|
+
alternative?: RuleCall['selector'];
|
|
50
|
+
}
|
|
51
|
+
export interface PresetChainReadiness {
|
|
52
|
+
chainNamespace: ForeignChainNamespace;
|
|
53
|
+
ready: boolean;
|
|
54
|
+
issues: PresetConfigurationIssue[];
|
|
55
|
+
/** Calls present in the rule but disabled by a zero amount/value maximum. */
|
|
56
|
+
disabledCalls: PresetCallIssue[];
|
|
57
|
+
/** Calls deliberately omitted, including operations with incompatible amount units. */
|
|
58
|
+
excludedCalls: PresetCallIssue[];
|
|
59
|
+
/** Known fixed-token/reserve addresses in this catalog, not selected defaults. */
|
|
60
|
+
knownTokens: string[];
|
|
61
|
+
/** Selected tokens with a zero Push-outbound budget; destination-held assets are separate. */
|
|
62
|
+
zeroBridgeLimits: string[];
|
|
63
|
+
}
|
|
64
|
+
export interface PresetResult<T extends PresetRuleTemplate = PresetRuleTemplate> {
|
|
65
|
+
rules: T[];
|
|
66
|
+
readiness: {
|
|
67
|
+
ready: boolean;
|
|
68
|
+
chains: PresetChainReadiness[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
36
71
|
export interface AgenticPresets {
|
|
37
72
|
list(options?: {
|
|
38
73
|
type?: 'CATEGORY';
|
|
39
74
|
}): {
|
|
40
75
|
presets: Preset[];
|
|
41
76
|
};
|
|
42
|
-
get(preset: PresetCategory, options: ReadyPresetOptions):
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
get(preset: PresetCategory, options?: PresetOptions): {
|
|
46
|
-
rules: PresetRuleTemplate[];
|
|
47
|
-
};
|
|
77
|
+
get(preset: PresetCategory, options: ReadyPresetOptions): PresetResult<Rule>;
|
|
78
|
+
get(preset: PresetCategory, options?: PresetOptions): PresetResult;
|
|
48
79
|
}
|
package/src/lib/index.d.ts
CHANGED
|
@@ -26,4 +26,4 @@ export type { PushChainInitializeOptions } from './push-chain/push-chain';
|
|
|
26
26
|
export { AGENTIC_ERROR_CODE, AgenticError, AgenticRevertError, } from './agentic';
|
|
27
27
|
export type { AgenticAddress, AgenticDoor, AgenticErrorCode, AgenticHex, AgenticNamespace, AgenticProgressHook, AgenticTxMetadata, AgenticWallet, AllowedCall, AssetCap, Checkpoint, CheckpointKind, CreateOptions, CreateResult, ForeignChainNamespace, DecodedSolanaRule, Rule, RuleInput, Pin, Spent, WalletMarker, ArgumentPath, RulesRecord, Selector, WalletInfo, WalletSummary, } from './agentic';
|
|
28
28
|
export { PushChain };
|
|
29
|
-
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, AgenticPresets, } from './agentic';
|
|
29
|
+
export type { Preset, PresetCategory, PresetAsset, PresetOptions, ReadyPresetOptions, PresetRuleTemplate, PresetResult, PresetChainReadiness, PresetConfigurationIssue, PresetCallIssue, AgenticPresets, } from './agentic';
|