@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.
- package/examples/permissions/BoundedSwap_UniswapV3_Base.sol +4 -3
- package/examples/permissions/BoundedSwap_UniswapV4_Unichain.sol +4 -0
- package/package.json +1 -1
- package/packages/cli/dist/index.cjs +401 -44
- package/packages/sdk/dist/intelligence.d.ts +1 -1
- package/packages/sdk/dist/intelligence.js +1 -1
- package/packages/sdk/dist/templates/ammLiquidity.d.ts +24 -11
- package/packages/sdk/dist/templates/ammLiquidity.d.ts.map +1 -1
- package/packages/sdk/dist/templates/ammLiquidity.js +39 -31
- package/packages/sdk/dist/templates/ammLiquidity.js.map +1 -1
- package/packages/sdk/dist/templates/approveAndCallBatch.d.ts +24 -10
- package/packages/sdk/dist/templates/approveAndCallBatch.d.ts.map +1 -1
- package/packages/sdk/dist/templates/approveAndCallBatch.js +36 -23
- package/packages/sdk/dist/templates/approveAndCallBatch.js.map +1 -1
- package/packages/sdk/dist/templates/boundedBorrow.d.ts +19 -9
- package/packages/sdk/dist/templates/boundedBorrow.d.ts.map +1 -1
- package/packages/sdk/dist/templates/boundedBorrow.js +28 -19
- package/packages/sdk/dist/templates/boundedBorrow.js.map +1 -1
- package/packages/sdk/dist/templates/boundedSwap.d.ts +19 -9
- package/packages/sdk/dist/templates/boundedSwap.d.ts.map +1 -1
- package/packages/sdk/dist/templates/boundedSwap.js +30 -20
- package/packages/sdk/dist/templates/boundedSwap.js.map +1 -1
- package/packages/sdk/dist/templates/defiBundle.d.ts +35 -9
- package/packages/sdk/dist/templates/defiBundle.d.ts.map +1 -1
- package/packages/sdk/dist/templates/defiBundle.js +84 -22
- package/packages/sdk/dist/templates/defiBundle.js.map +1 -1
- package/packages/sdk/dist/templates/pendle.d.ts +23 -8
- package/packages/sdk/dist/templates/pendle.d.ts.map +1 -1
- package/packages/sdk/dist/templates/pendle.js +34 -14
- package/packages/sdk/dist/templates/pendle.js.map +1 -1
- package/packages/sdk/dist/templates/transferTarget.d.ts +11 -3
- package/packages/sdk/dist/templates/transferTarget.d.ts.map +1 -1
- package/packages/sdk/dist/templates/transferTarget.js +14 -7
- package/packages/sdk/dist/templates/transferTarget.js.map +1 -1
- package/packages/sdk/package.json +1 -0
- package/templates/default/.github/workflows/agent-tick.yml +8 -7
- package/templates/default/AGENTS.md +12 -1
- package/templates/default/src/config.ts +1 -11
- 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-
|
|
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-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
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
|
|
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: "
|
|
4
|
-
{ name: "
|
|
5
|
-
{ name: "
|
|
6
|
-
{ name: "
|
|
7
|
-
{ name: "
|
|
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: "
|
|
13
|
+
name: "SharedAMMLiquidityPermission",
|
|
11
14
|
address: "0x0000000000000000000000000000000000000000",
|
|
12
15
|
encoder: {
|
|
13
16
|
encode(params) {
|
|
14
17
|
return encodeAbiParameters(ABI, [
|
|
15
|
-
|
|
16
|
-
params.
|
|
17
|
-
params.
|
|
18
|
-
params.
|
|
19
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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.
|
|
38
|
-
warnings.push("
|
|
45
|
+
if (params.allowedTargets.length === 0) {
|
|
46
|
+
warnings.push("No targets specified — all liquidity operations will be blocked");
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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: "
|
|
56
|
+
templateName: "SharedAMMLiquidityPermission",
|
|
48
57
|
humanReadable: [
|
|
49
|
-
`Maximum
|
|
50
|
-
`Allowed
|
|
51
|
-
`Allowed
|
|
52
|
-
`
|
|
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;
|
|
1
|
+
{"version":3,"file":"ammLiquidity.js","sourceRoot":"","sources":["../../src/templates/ammLiquidity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA8BhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,EAAE;IAC7C,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IAC5C,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,SAAS,EAAE;IACnD,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE;IACnC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;IACvC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;IACvC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE;IACtC,EAAE,IAAI,EAAE,WAAW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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
|
-
/**
|
|
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
|
-
/**
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
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,
|
|
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
|
|
3
|
-
{ name: "
|
|
4
|
-
{ name: "
|
|
5
|
-
{ name: "
|
|
6
|
-
{ name: "
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
28
|
+
const [config] = decodeAbiParameters(ABI, data);
|
|
22
29
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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.
|
|
34
|
-
warnings.push("
|
|
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.
|
|
37
|
-
warnings.push("
|
|
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
|
-
`
|
|
43
|
-
`
|
|
44
|
-
`
|
|
45
|
-
`
|
|
46
|
-
`
|
|
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;
|
|
1
|
+
{"version":3,"file":"approveAndCallBatch.js","sourceRoot":"","sources":["../../src/templates/approveAndCallBatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA6BhE,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE;IACrC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE;IACvC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE;IAC/C,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,UAAU,EAAE;IAChD,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,WAAW,EAAE;IACjD,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE;CACpC,CAAC;AAEX,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAU,CAAC;AAExF,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;oBACE,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,gBAAgB,EA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qCAAqC;gBACnD,aAAa,EAAE;oBACb,sBAAsB,MAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC1E,sBAAsB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAClD,sBAAsB,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC1D,wBAAwB,MAAM,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
|
-
/**
|
|
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
|
-
/**
|
|
5
|
-
|
|
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
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
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
|
|
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: "
|
|
3
|
+
{ name: "protocols", type: "address[]" },
|
|
4
|
+
{ name: "assets", type: "address[]" },
|
|
5
|
+
{ name: "maxAmountPerTx", type: "uint256" },
|
|
4
6
|
{ name: "maxLtvBps", type: "uint256" },
|
|
5
|
-
{ name: "
|
|
6
|
-
{ name: "
|
|
7
|
-
{ name: "
|
|
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
|
-
|
|
18
|
+
params.protocols,
|
|
19
|
+
params.assets,
|
|
20
|
+
params.maxAmountPerTx,
|
|
16
21
|
BigInt(params.maxLtvBps),
|
|
17
|
-
params.
|
|
18
|
-
params.
|
|
19
|
-
params.
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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.
|
|
40
|
-
warnings.push(
|
|
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
|
|
52
|
+
`Maximum borrow per tx: ${params.maxAmountPerTx.toString()} (asset base units)`,
|
|
46
53
|
`Maximum LTV: ${params.maxLtvBps / 100}%`,
|
|
47
|
-
`Allowed
|
|
48
|
-
`Allowed
|
|
49
|
-
`
|
|
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;
|
|
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ACF;CACF,CAAC"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { Address, PermissionTemplate } from "../types.js";
|
|
2
|
-
/**
|
|
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
|
-
/**
|
|
5
|
-
|
|
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
|
-
|
|
13
|
+
tokensIn: Address[];
|
|
10
14
|
/** Token addresses allowed as swap output. */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
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
|
|
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: "
|
|
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: "
|
|
6
|
-
{ name: "
|
|
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
|
-
|
|
18
|
+
params.routers,
|
|
19
|
+
params.tokensIn,
|
|
20
|
+
params.tokensOut,
|
|
21
|
+
params.maxAmountPerTx,
|
|
16
22
|
BigInt(params.maxSlippageBps),
|
|
17
|
-
params.
|
|
18
|
-
params.
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
52
|
+
`Maximum input per swap: ${params.maxAmountPerTx.toString()} (input-token base units)`,
|
|
46
53
|
`Maximum slippage: ${params.maxSlippageBps / 100}%`,
|
|
47
|
-
`Allowed
|
|
48
|
-
`Allowed
|
|
49
|
-
`Allowed
|
|
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
|
};
|