@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundedSwap.js","sourceRoot":"","sources":["../../src/templates/boundedSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"boundedSwap.js","sourceRoot":"","sources":["../../src/templates/boundedSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA2BhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE;IACvC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;IACxC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;CACnC,CAAC;AAEX,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAA0C;IACxE,IAAI,EAAE,6BAA6B;IACnC,OAAO,EAAE,4CAA4C;I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AAE,6BAA6B;gBAC3C,aAAa,EAAE;oBACb,2BAA2B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,2BAA2B;oBACtF,qBAAqB,MAAM,CAAC,cAAc,GAAG,GAAG,GAAG;oBACnD,oBAAoB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC/C,yBAAyB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACrD,0BAA0B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACvD,MAAM,CAAC,WAAW,KAAK,YAAY;wBACjC,CAAC,CAAC,oBAAoB;wBACtB,CAAC,CAAC,iBAAiB,MAAM,CAAC,WAAW,aAAa,MAAM,CAAC,cAAc,IAAI;iBAC9E;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import type { Address, PermissionTemplate } from "../types.js";
|
|
2
|
-
/**
|
|
2
|
+
/** Swap sub-domain config — mirrors the contract's `SwapConfig` struct. */
|
|
3
|
+
export type DefiBundleSwapConfig = {
|
|
4
|
+
routers: Address[];
|
|
5
|
+
tokensIn: Address[];
|
|
6
|
+
tokensOut: Address[];
|
|
7
|
+
maxAmountPerTx: bigint;
|
|
8
|
+
maxSlippageBps: number;
|
|
9
|
+
priceOracle: Address;
|
|
10
|
+
maxPriceAgeSec: number;
|
|
11
|
+
};
|
|
12
|
+
/** Borrow sub-domain config — mirrors the contract's `BorrowConfig` struct. */
|
|
13
|
+
export type DefiBundleBorrowConfig = {
|
|
14
|
+
protocols: Address[];
|
|
15
|
+
assets: Address[];
|
|
16
|
+
maxAmountPerTx: bigint;
|
|
17
|
+
maxLtvBps: number;
|
|
18
|
+
collateralOracle: Address;
|
|
19
|
+
borrowOracle: Address;
|
|
20
|
+
maxPriceAgeSec: number;
|
|
21
|
+
};
|
|
22
|
+
/** Transfer sub-domain config — mirrors the contract's `TransferConfig` struct. */
|
|
23
|
+
export type DefiBundleTransferConfig = {
|
|
24
|
+
recipients: Address[];
|
|
25
|
+
tokens: Address[];
|
|
26
|
+
maxAmountPerTx: bigint;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Params for SharedDeFiBundlePermission.
|
|
30
|
+
*
|
|
31
|
+
* Matches the on-chain `_applyConfig` decode exactly:
|
|
32
|
+
* abi.decode(params, (SwapConfig, BorrowConfig, TransferConfig))
|
|
33
|
+
*/
|
|
3
34
|
export type DefiBundleParams = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
allowedProtocols: string[];
|
|
8
|
-
/** Allowed action types within the bundle (e.g. ["swap", "deposit", "borrow"]). */
|
|
9
|
-
allowedActions: string[];
|
|
10
|
-
/** Allowed token addresses that the bundle may interact with. */
|
|
11
|
-
allowedTokens: Address[];
|
|
35
|
+
swap: DefiBundleSwapConfig;
|
|
36
|
+
borrow: DefiBundleBorrowConfig;
|
|
37
|
+
transfer: DefiBundleTransferConfig;
|
|
12
38
|
};
|
|
13
39
|
export declare const defiBundleTemplate: PermissionTemplate<DefiBundleParams>;
|
|
14
40
|
//# sourceMappingURL=defiBundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defiBundle.d.ts","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,
|
|
1
|
+
{"version":3,"file":"defiBundle.d.ts","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAkCF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,gBAAgB,CAqFnE,CAAC"}
|
|
@@ -1,48 +1,110 @@
|
|
|
1
1
|
import { decodeAbiParameters, encodeAbiParameters } from "viem";
|
|
2
|
+
const SWAP_COMPONENTS = [
|
|
3
|
+
{ name: "routers", type: "address[]" },
|
|
4
|
+
{ name: "tokensIn", type: "address[]" },
|
|
5
|
+
{ name: "tokensOut", type: "address[]" },
|
|
6
|
+
{ name: "maxAmountPerTx", type: "uint256" },
|
|
7
|
+
{ name: "maxSlippageBps", type: "uint256" },
|
|
8
|
+
{ name: "priceOracle", type: "address" },
|
|
9
|
+
{ name: "maxPriceAgeSec", type: "uint256" },
|
|
10
|
+
];
|
|
11
|
+
const BORROW_COMPONENTS = [
|
|
12
|
+
{ name: "protocols", type: "address[]" },
|
|
13
|
+
{ name: "assets", type: "address[]" },
|
|
14
|
+
{ name: "maxAmountPerTx", type: "uint256" },
|
|
15
|
+
{ name: "maxLtvBps", type: "uint256" },
|
|
16
|
+
{ name: "collateralOracle", type: "address" },
|
|
17
|
+
{ name: "borrowOracle", type: "address" },
|
|
18
|
+
{ name: "maxPriceAgeSec", type: "uint256" },
|
|
19
|
+
];
|
|
20
|
+
const TRANSFER_COMPONENTS = [
|
|
21
|
+
{ name: "recipients", type: "address[]" },
|
|
22
|
+
{ name: "tokens", type: "address[]" },
|
|
23
|
+
{ name: "maxAmountPerTx", type: "uint256" },
|
|
24
|
+
];
|
|
2
25
|
const ABI = [
|
|
3
|
-
{ name: "
|
|
4
|
-
{ name: "
|
|
5
|
-
{ name: "
|
|
6
|
-
{ name: "allowedTokens", type: "address[]" },
|
|
26
|
+
{ name: "swap", type: "tuple", components: SWAP_COMPONENTS },
|
|
27
|
+
{ name: "borrow", type: "tuple", components: BORROW_COMPONENTS },
|
|
28
|
+
{ name: "transfer", type: "tuple", components: TRANSFER_COMPONENTS },
|
|
7
29
|
];
|
|
8
30
|
export const defiBundleTemplate = {
|
|
9
|
-
name: "
|
|
31
|
+
name: "SharedDeFiBundlePermission",
|
|
10
32
|
address: "0x0000000000000000000000000000000000000000",
|
|
11
33
|
encoder: {
|
|
12
34
|
encode(params) {
|
|
13
35
|
return encodeAbiParameters(ABI, [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
{
|
|
37
|
+
routers: params.swap.routers,
|
|
38
|
+
tokensIn: params.swap.tokensIn,
|
|
39
|
+
tokensOut: params.swap.tokensOut,
|
|
40
|
+
maxAmountPerTx: params.swap.maxAmountPerTx,
|
|
41
|
+
maxSlippageBps: BigInt(params.swap.maxSlippageBps),
|
|
42
|
+
priceOracle: params.swap.priceOracle,
|
|
43
|
+
maxPriceAgeSec: BigInt(params.swap.maxPriceAgeSec),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
protocols: params.borrow.protocols,
|
|
47
|
+
assets: params.borrow.assets,
|
|
48
|
+
maxAmountPerTx: params.borrow.maxAmountPerTx,
|
|
49
|
+
maxLtvBps: BigInt(params.borrow.maxLtvBps),
|
|
50
|
+
collateralOracle: params.borrow.collateralOracle,
|
|
51
|
+
borrowOracle: params.borrow.borrowOracle,
|
|
52
|
+
maxPriceAgeSec: BigInt(params.borrow.maxPriceAgeSec),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
recipients: params.transfer.recipients,
|
|
56
|
+
tokens: params.transfer.tokens,
|
|
57
|
+
maxAmountPerTx: params.transfer.maxAmountPerTx,
|
|
58
|
+
},
|
|
18
59
|
]);
|
|
19
60
|
},
|
|
20
61
|
decode(data) {
|
|
21
|
-
const
|
|
62
|
+
const [swap, borrow, transfer] = decodeAbiParameters(ABI, data);
|
|
22
63
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
64
|
+
swap: {
|
|
65
|
+
routers: [...swap.routers],
|
|
66
|
+
tokensIn: [...swap.tokensIn],
|
|
67
|
+
tokensOut: [...swap.tokensOut],
|
|
68
|
+
maxAmountPerTx: swap.maxAmountPerTx,
|
|
69
|
+
maxSlippageBps: Number(swap.maxSlippageBps),
|
|
70
|
+
priceOracle: swap.priceOracle,
|
|
71
|
+
maxPriceAgeSec: Number(swap.maxPriceAgeSec),
|
|
72
|
+
},
|
|
73
|
+
borrow: {
|
|
74
|
+
protocols: [...borrow.protocols],
|
|
75
|
+
assets: [...borrow.assets],
|
|
76
|
+
maxAmountPerTx: borrow.maxAmountPerTx,
|
|
77
|
+
maxLtvBps: Number(borrow.maxLtvBps),
|
|
78
|
+
collateralOracle: borrow.collateralOracle,
|
|
79
|
+
borrowOracle: borrow.borrowOracle,
|
|
80
|
+
maxPriceAgeSec: Number(borrow.maxPriceAgeSec),
|
|
81
|
+
},
|
|
82
|
+
transfer: {
|
|
83
|
+
recipients: [...transfer.recipients],
|
|
84
|
+
tokens: [...transfer.tokens],
|
|
85
|
+
maxAmountPerTx: transfer.maxAmountPerTx,
|
|
86
|
+
},
|
|
27
87
|
};
|
|
28
88
|
},
|
|
29
89
|
},
|
|
30
90
|
explainer: {
|
|
31
91
|
explain(params) {
|
|
32
92
|
const warnings = [];
|
|
33
|
-
if (params.
|
|
34
|
-
warnings.push(`
|
|
93
|
+
if (params.swap.maxSlippageBps > 100) {
|
|
94
|
+
warnings.push(`High swap slippage tolerance: ${params.swap.maxSlippageBps / 100}%`);
|
|
95
|
+
}
|
|
96
|
+
if (params.borrow.maxLtvBps > 8000) {
|
|
97
|
+
warnings.push(`High borrow LTV cap: ${params.borrow.maxLtvBps / 100}%`);
|
|
35
98
|
}
|
|
36
|
-
if (params.
|
|
99
|
+
if (params.borrow.protocols.length > 0 && params.swap.routers.length > 0) {
|
|
37
100
|
warnings.push("Bundle permits both borrowing and swapping — review leverage exposure");
|
|
38
101
|
}
|
|
39
102
|
return {
|
|
40
|
-
templateName: "
|
|
103
|
+
templateName: "SharedDeFiBundlePermission",
|
|
41
104
|
humanReadable: [
|
|
42
|
-
`
|
|
43
|
-
`
|
|
44
|
-
`
|
|
45
|
-
`Allowed tokens: ${params.allowedTokens.join(", ")}`,
|
|
105
|
+
`Swap — routers: ${params.swap.routers.join(", ") || "none"}; max/tx: ${params.swap.maxAmountPerTx.toString()}; slippage: ${params.swap.maxSlippageBps / 100}%`,
|
|
106
|
+
`Borrow — protocols: ${params.borrow.protocols.join(", ") || "none"}; max/tx: ${params.borrow.maxAmountPerTx.toString()}; LTV: ${params.borrow.maxLtvBps / 100}%`,
|
|
107
|
+
`Transfer — recipients: ${params.transfer.recipients.join(", ") || "none"}; max/tx: ${params.transfer.maxAmountPerTx.toString()}`,
|
|
46
108
|
],
|
|
47
109
|
warnings,
|
|
48
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defiBundle.js","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"defiBundle.js","sourceRoot":"","sources":["../../src/templates/defiBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA4ChE,MAAM,eAAe,GAAG;IACtB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE;IACvC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;IACxC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;CACnC,CAAC;AAEX,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;IACxC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE;IACrC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE;IAC7C,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE;IACzC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;CACnC,CAAC;AAEX,MAAM,mB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,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,aAAa,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG;oBACjK,0BAA0B,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,aAAa,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE;iBAClI;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import type { Address, PermissionTemplate } from "../types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Params for SharedPendlePermission.
|
|
4
|
+
*
|
|
5
|
+
* Matches the on-chain `_applyConfig` decode exactly:
|
|
6
|
+
* abi.decode(params, (address, address[], uint128, bool, bool, bool, bool, bool))
|
|
7
|
+
* → pendleRouter, allowedMarkets, maxAmountPerTx,
|
|
8
|
+
* allowLiquidityOps, allowPtSwaps, allowYtSwaps, allowMintRedeem, allowClaimYield
|
|
9
|
+
*/
|
|
3
10
|
export type PendleParams = {
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
/** Pendle market addresses the agent may interact with. */
|
|
11
|
+
/** Pendle Router V4 address the agent may call. Must be non-zero. */
|
|
12
|
+
pendleRouter: Address;
|
|
13
|
+
/** Pendle market (and YT, for mint/redeem) addresses the agent may interact with. */
|
|
7
14
|
allowedMarkets: Address[];
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
15
|
+
/** Maximum amount of a single tx, in base units (uint128). */
|
|
16
|
+
maxAmountPerTx: bigint;
|
|
17
|
+
/** Allow add/remove liquidity operations. */
|
|
18
|
+
allowLiquidityOps: boolean;
|
|
19
|
+
/** Allow PT swaps. */
|
|
20
|
+
allowPtSwaps: boolean;
|
|
21
|
+
/** Allow YT swaps. */
|
|
22
|
+
allowYtSwaps: boolean;
|
|
23
|
+
/** Allow mint / redeem of PY. */
|
|
24
|
+
allowMintRedeem: boolean;
|
|
25
|
+
/** Allow claiming yield (redeemDueInterestAndRewards). */
|
|
26
|
+
allowClaimYield: boolean;
|
|
12
27
|
};
|
|
13
28
|
export declare const pendleTemplate: PermissionTemplate<PendleParams>;
|
|
14
29
|
//# sourceMappingURL=pendle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pendle.d.ts","sourceRoot":"","sources":["../../src/templates/pendle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF
|
|
1
|
+
{"version":3,"file":"pendle.d.ts","sourceRoot":"","sources":["../../src/templates/pendle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,qEAAqE;IACrE,YAAY,EAAE,OAAO,CAAC;IACtB,qFAAqF;IACrF,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sBAAsB;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iCAAiC;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAeF,eAAO,MAAM,cAAc,EAAE,kBAAkB,CAAC,YAAY,CA4D3D,CAAC"}
|
|
@@ -1,47 +1,67 @@
|
|
|
1
1
|
import { decodeAbiParameters, encodeAbiParameters } from "viem";
|
|
2
2
|
const ABI = [
|
|
3
|
-
{ name: "
|
|
3
|
+
{ name: "pendleRouter", type: "address" },
|
|
4
4
|
{ name: "allowedMarkets", type: "address[]" },
|
|
5
|
-
{ name: "
|
|
6
|
-
{ name: "
|
|
5
|
+
{ name: "maxAmountPerTx", type: "uint128" },
|
|
6
|
+
{ name: "allowLiquidityOps", type: "bool" },
|
|
7
|
+
{ name: "allowPtSwaps", type: "bool" },
|
|
8
|
+
{ name: "allowYtSwaps", type: "bool" },
|
|
9
|
+
{ name: "allowMintRedeem", type: "bool" },
|
|
10
|
+
{ name: "allowClaimYield", type: "bool" },
|
|
7
11
|
];
|
|
12
|
+
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
8
13
|
export const pendleTemplate = {
|
|
9
14
|
name: "SharedPendlePermission",
|
|
10
15
|
address: "0x0000000000000000000000000000000000000000",
|
|
11
16
|
encoder: {
|
|
12
17
|
encode(params) {
|
|
13
18
|
return encodeAbiParameters(ABI, [
|
|
14
|
-
|
|
19
|
+
params.pendleRouter,
|
|
15
20
|
params.allowedMarkets,
|
|
16
|
-
params.
|
|
17
|
-
|
|
21
|
+
params.maxAmountPerTx,
|
|
22
|
+
params.allowLiquidityOps,
|
|
23
|
+
params.allowPtSwaps,
|
|
24
|
+
params.allowYtSwaps,
|
|
25
|
+
params.allowMintRedeem,
|
|
26
|
+
params.allowClaimYield,
|
|
18
27
|
]);
|
|
19
28
|
},
|
|
20
29
|
decode(data) {
|
|
21
30
|
const decoded = decodeAbiParameters(ABI, data);
|
|
22
31
|
return {
|
|
23
|
-
|
|
32
|
+
pendleRouter: decoded[0],
|
|
24
33
|
allowedMarkets: [...decoded[1]],
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
maxAmountPerTx: decoded[2],
|
|
35
|
+
allowLiquidityOps: decoded[3],
|
|
36
|
+
allowPtSwaps: decoded[4],
|
|
37
|
+
allowYtSwaps: decoded[5],
|
|
38
|
+
allowMintRedeem: decoded[6],
|
|
39
|
+
allowClaimYield: decoded[7],
|
|
27
40
|
};
|
|
28
41
|
},
|
|
29
42
|
},
|
|
30
43
|
explainer: {
|
|
31
44
|
explain(params) {
|
|
32
45
|
const warnings = [];
|
|
33
|
-
if (params.
|
|
34
|
-
warnings.push("
|
|
46
|
+
if (params.pendleRouter === ZERO_ADDRESS) {
|
|
47
|
+
warnings.push("Pendle router is zero — configuration will revert on-chain");
|
|
35
48
|
}
|
|
36
49
|
if (params.allowedMarkets.length === 0) {
|
|
37
50
|
warnings.push("No markets specified — all Pendle market interactions will be blocked");
|
|
38
51
|
}
|
|
52
|
+
const ops = [
|
|
53
|
+
params.allowLiquidityOps && "liquidity",
|
|
54
|
+
params.allowPtSwaps && "PT swaps",
|
|
55
|
+
params.allowYtSwaps && "YT swaps",
|
|
56
|
+
params.allowMintRedeem && "mint/redeem",
|
|
57
|
+
params.allowClaimYield && "claim yield",
|
|
58
|
+
].filter(Boolean);
|
|
39
59
|
return {
|
|
40
60
|
templateName: "SharedPendlePermission",
|
|
41
61
|
humanReadable: [
|
|
42
|
-
`
|
|
43
|
-
`
|
|
44
|
-
`
|
|
62
|
+
`Pendle router: ${params.pendleRouter}`,
|
|
63
|
+
`Maximum amount per tx: ${params.maxAmountPerTx.toString()} (base units)`,
|
|
64
|
+
`Enabled operations: ${ops.length ? ops.join(", ") : "none"}`,
|
|
45
65
|
`Allowed markets (${params.allowedMarkets.length}): ${params.allowedMarkets.join(", ")}`,
|
|
46
66
|
],
|
|
47
67
|
warnings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pendle.js","sourceRoot":"","sources":["../../src/templates/pendle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"pendle.js","sourceRoot":"","sources":["../../src/templates/pendle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA8BhE,MAAM,GAAG,GAAG;IACV,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;CACF,CAAC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { Address, PermissionTemplate } from "../types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Params for SharedTransferTargetPermission.
|
|
4
|
+
*
|
|
5
|
+
* Matches the on-chain `_applyConfig` decode exactly:
|
|
6
|
+
* abi.decode(params, (address[], address[], uint256))
|
|
7
|
+
* → recipients, tokens, maxAmountPerTx
|
|
8
|
+
*/
|
|
3
9
|
export type TransferTargetParams = {
|
|
4
|
-
/** Addresses that ERC-20 transfer() calls are allowed to send funds to. */
|
|
10
|
+
/** Addresses that ERC-20 transfer()/transferFrom() calls are allowed to send funds to. */
|
|
5
11
|
allowedRecipients: Address[];
|
|
6
|
-
/** Token addresses for which
|
|
12
|
+
/** Token addresses for which transfers are gated. The token is the call target. */
|
|
7
13
|
allowedTokens: Address[];
|
|
14
|
+
/** Maximum amount per transfer, in the token's base units. */
|
|
15
|
+
maxAmountPerTx: bigint;
|
|
8
16
|
};
|
|
9
17
|
export declare const transferTargetTemplate: PermissionTemplate<TransferTargetParams>;
|
|
10
18
|
//# sourceMappingURL=transferTarget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferTarget.d.ts","sourceRoot":"","sources":["../../src/templates/transferTarget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF
|
|
1
|
+
{"version":3,"file":"transferTarget.d.ts","sourceRoot":"","sources":["../../src/templates/transferTarget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,0FAA0F;IAC1F,iBAAiB,EAAE,OAAO,EAAE,CAAC;IAC7B,mFAAmF;IACnF,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAQF,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,oBAAoB,CA2C3E,CAAC"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { decodeAbiParameters, encodeAbiParameters } from "viem";
|
|
2
2
|
const ABI = [
|
|
3
|
-
{ name: "
|
|
4
|
-
{ name: "
|
|
3
|
+
{ name: "recipients", type: "address[]" },
|
|
4
|
+
{ name: "tokens", type: "address[]" },
|
|
5
|
+
{ name: "maxAmountPerTx", type: "uint256" },
|
|
5
6
|
];
|
|
6
7
|
export const transferTargetTemplate = {
|
|
7
8
|
name: "SharedTransferTargetPermission",
|
|
8
9
|
address: "0x0000000000000000000000000000000000000000",
|
|
9
10
|
encoder: {
|
|
10
11
|
encode(params) {
|
|
11
|
-
return encodeAbiParameters(ABI, [
|
|
12
|
+
return encodeAbiParameters(ABI, [
|
|
13
|
+
params.allowedRecipients,
|
|
14
|
+
params.allowedTokens,
|
|
15
|
+
params.maxAmountPerTx,
|
|
16
|
+
]);
|
|
12
17
|
},
|
|
13
18
|
decode(data) {
|
|
14
19
|
const decoded = decodeAbiParameters(ABI, data);
|
|
15
20
|
return {
|
|
16
21
|
allowedRecipients: [...decoded[0]],
|
|
17
22
|
allowedTokens: [...decoded[1]],
|
|
23
|
+
maxAmountPerTx: decoded[2],
|
|
18
24
|
};
|
|
19
25
|
},
|
|
20
26
|
},
|
|
@@ -24,14 +30,15 @@ export const transferTargetTemplate = {
|
|
|
24
30
|
if (params.allowedRecipients.length === 0) {
|
|
25
31
|
warnings.push("No recipients specified — all transfers will be blocked");
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
if (params.allowedTokens.length === 0) {
|
|
34
|
+
warnings.push("No tokens specified — all transfers will be blocked");
|
|
35
|
+
}
|
|
30
36
|
return {
|
|
31
37
|
templateName: "SharedTransferTargetPermission",
|
|
32
38
|
humanReadable: [
|
|
33
39
|
`ERC-20 transfers restricted to ${params.allowedRecipients.length} approved recipient(s)`,
|
|
34
|
-
`
|
|
40
|
+
`Gated tokens: ${params.allowedTokens.join(", ")}`,
|
|
41
|
+
`Maximum amount per transfer: ${params.maxAmountPerTx.toString()} (base units)`,
|
|
35
42
|
`Approved recipients: ${params.allowedRecipients.join(", ")}`,
|
|
36
43
|
],
|
|
37
44
|
warnings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferTarget.js","sourceRoot":"","sources":["../../src/templates/transferTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transferTarget.js","sourceRoot":"","sources":["../../src/templates/transferTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAmBhE,MAAM,GAAG,GAAG;IACV,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE;IACzC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE;IACrC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;CACnC,CAAC;AAEX,MAAM,CAAC,MAAM,sBAAsB,GAA6C;IAC9E,IAAI,EAAE,gCAAgC;IACtC,OAAO,EAAE,4CAA4C;IAErD,OAAO,EAAE;QACP,MAAM,CAAC,MAA4B;YACjC,OAAO,mBAAmB,CAAC,GAAG,EAAE;gBAC9B,MAAM,CAAC,iBAAiB;gBACxB,MAAM,CAAC,aAAa;gBACpB,MAAM,CAAC,cAAc;aACtB,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,IAAS;YACd,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAO;gBACL,iBAAiB,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAClC,aAAa,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC9B,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;aAC3B,CAAC;QACJ,CAAC;KACF;IAED,SAAS,EAAE;QACT,OAAO,CAAC,MAA4B;YAClC,MAAM,QAAQ,GAAa,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1C,QAAQ,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;YAC3E,CAAC;YACD,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtC,QAAQ,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;YACvE,CAAC;YACD,OAAO;gBACL,YAAY,EAAE,gCAAgC;gBAC9C,aAAa,EAAE;oBACb,kCAAkC,MAAM,CAAC,iBAAiB,CAAC,MAAM,wBAAwB;oBACzF,iBAAiB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAClD,gCAAgC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe;oBAC/E,wBAAwB,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;iBAC9D;gBACD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"prebuild": "node scripts/generate-intelligence.mjs",
|
|
40
40
|
"build": "tsc -p tsconfig.json",
|
|
41
41
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
+
"test": "tsx --test src/**/*.test.ts",
|
|
42
43
|
"generate:intelligence": "node scripts/generate-intelligence.mjs"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
@@ -12,21 +12,22 @@ jobs:
|
|
|
12
12
|
steps:
|
|
13
13
|
- uses: actions/checkout@v4
|
|
14
14
|
|
|
15
|
-
- uses: pnpm/action-setup@v4
|
|
16
|
-
with:
|
|
17
|
-
version: 9
|
|
18
|
-
|
|
19
15
|
- uses: actions/setup-node@v4
|
|
20
16
|
with:
|
|
21
17
|
node-version: 20
|
|
22
|
-
cache: "
|
|
18
|
+
cache: "npm"
|
|
23
19
|
|
|
24
20
|
- name: Install dependencies
|
|
25
|
-
run:
|
|
21
|
+
run: npm ci
|
|
22
|
+
|
|
23
|
+
- name: Copy keystore to expected path
|
|
24
|
+
run: |
|
|
25
|
+
mkdir -p .sail/keys
|
|
26
|
+
cp ci-keystore.json .sail/keys/manager.json
|
|
26
27
|
|
|
27
28
|
- name: Run agent tick
|
|
28
29
|
env:
|
|
29
30
|
RPC_URL: ${{ secrets.RPC_URL }}
|
|
30
|
-
|
|
31
|
+
SAIL_PASSPHRASE: ${{ secrets.SAIL_PASSPHRASE }}
|
|
31
32
|
CHAIN_ID: ${{ vars.CHAIN_ID || '8453' }}
|
|
32
33
|
run: npx sailor run --once
|
|
@@ -68,7 +68,18 @@ sailor run # local, continuous
|
|
|
68
68
|
sailor run --once # single tick — confirm it works before automating
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
For GitHub Actions:
|
|
71
|
+
For GitHub Actions:
|
|
72
|
+
|
|
73
|
+
1. Run `sailor keys export-ci` — copies your encrypted agent wallet to `ci-keystore.json` in the project root and adds it to `.gitignore` as an allowed file. The keystore is geth v3 encrypted; the raw private key is never exposed.
|
|
74
|
+
2. Commit and push `ci-keystore.json`:
|
|
75
|
+
```bash
|
|
76
|
+
git add ci-keystore.json && git commit -m "chore: add CI keystore" && git push
|
|
77
|
+
```
|
|
78
|
+
3. Add two secrets in GitHub (Settings → Secrets → Actions):
|
|
79
|
+
- `SAIL_PASSPHRASE` — the passphrase that encrypts your agent wallet
|
|
80
|
+
- `RPC_URL` — your RPC endpoint
|
|
81
|
+
|
|
82
|
+
The scaffolded workflow at `.github/workflows/agent-tick.yml` picks up `ci-keystore.json`, unlocks it with `SAIL_PASSPHRASE`, and runs on the configured schedule. No private key ever appears in the workflow or in secrets.
|
|
72
83
|
|
|
73
84
|
## Stage 5 — Extend
|
|
74
85
|
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { SailorClient } from "@sail/sdk";
|
|
2
|
-
|
|
3
1
|
/** Reads RPC_URL and CHAIN_ID from environment (set via .sail/.env.local or GitHub Secrets). */
|
|
4
2
|
export function getEnvConfig(): { rpcUrl: string; chainId: number } {
|
|
5
3
|
const rpcUrl = process.env["RPC_URL"];
|
|
6
4
|
if (!rpcUrl) {
|
|
7
5
|
throw new Error(
|
|
8
6
|
"RPC_URL is not set.\n" +
|
|
9
|
-
"
|
|
10
|
-
"add RPC_URL to .sail/.env.local manually.",
|
|
7
|
+
"Add RPC_URL to .sail/.env.local or set it as an environment variable.",
|
|
11
8
|
);
|
|
12
9
|
}
|
|
13
10
|
|
|
@@ -25,10 +22,3 @@ export function getEnvConfig(): { rpcUrl: string; chainId: number } {
|
|
|
25
22
|
|
|
26
23
|
return { rpcUrl, chainId };
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
/** Builds a SailorClient from environment config. */
|
|
30
|
-
export function createClient(): SailorClient {
|
|
31
|
-
const { rpcUrl, chainId } = getEnvConfig();
|
|
32
|
-
// SailorClient constructor is not implemented yet — this is illustrative.
|
|
33
|
-
return new SailorClient({ rpcUrl, chainId });
|
|
34
|
-
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
2
|
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
4
10
|
"rootDir": "src",
|
|
5
11
|
"noEmit": true
|
|
6
12
|
},
|