@panoptic-eng/sdk 1.0.63 → 1.0.64
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/README.md +1 -1
- package/dist/cow/index.d.ts +1 -1
- package/dist/cow/index.d.ts.map +1 -1
- package/dist/cow/index.js +1 -1
- package/dist/cow/index.js.map +1 -1
- package/dist/{cow-BsSaoahK.js → cow-BIzmQHon.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{irm-BDlcUNgJ.js → irm-BGog_tSR.js} +3 -3
- package/dist/panoptic/v2/index.d.ts +135 -135
- package/dist/panoptic/v2/index.js +50 -50
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/panoptic/v2/react-public.d.ts +142 -142
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/panoptic/v2/react-public.js +53 -53
- package/dist/panoptic/v2/react-public.js.map +1 -1
- package/dist/{rates-BwZnK0tG.js → rates-O6Sn-xqL.js} +3 -3
- package/dist/{router-Dejb6MWu.js → router-BuAvFpbu.js} +3 -3
- package/dist/{router-pm9PDlyH.js → router-DHn0rNd7.js} +2 -2
- package/dist/uniswap/index.d.ts +1 -1
- package/dist/uniswap/index.js +1 -1
- package/dist/uniswap/index.js.map +1 -1
- package/dist/{v2-ccGPXWvq.js → v2-D2Bg1SeN.js} +15 -15
- package/dist/{writes--fM_8ggw.js → writes-jz-N6C_4.js} +37 -37
- package/dist/zodiac/index.d.ts +3 -3
- package/dist/zodiac/index.d.ts.map +1 -1
- package/dist/zodiac/index.js +3 -3
- package/dist/zodiac/index.js.map +1 -1
- package/package.json +1 -1
package/dist/zodiac/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["params: {\n publicClient: ScopeStepsPublicClient\n walletClient: ScopeStepsWalletClient\n rolesModifier: `0x${string}`\n steps: ScopeStep[]\n log?: (line: string) => void\n /**\n * EIP-1559 fee overrides applied to every tx. Pass a NON-ZERO\n * `maxPriorityFeePerGas` — some RPC estimators return a zero tip, which leaves\n * txs un-prioritised and slow to include.\n */\n fees?: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n /** Receipt-wait timeout (ms). */\n timeoutMs?: number\n}","v: string","addr: `0x${string}`","adapter: `0x${string}`","extra: Hex","cap: bigint","name: string","adapter: `0x${string}`","extra: Hex","params: {\n roleName: string\n roleKey: Hex\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}`\n extra?: Hex\n}","params: {\n member: `0x${string}`\n pool: `0x${string}`\n roleKey?: Hex\n}","params: LiquidatorConditionsParams","parent: number","paramType: ConditionFlat['paramType']","conditions: ConditionFlat[]","params: LiquidatorConditionsParams & { roleKey: Hex; member: Address }","fieldOffset: bigint","bits: bigint","tokenId: bigint","v: bigint","shiftBytes: number","safe: `0x${string}`","safe: `0x${string}`","params: {\n member: `0x${string}`\n pool: `0x${string}`\n safe: `0x${string}`\n roleKey?: Hex\n}","params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed RollerCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}","safe: `0x${string}`","poolId: bigint","adapter: `0x${string}`","poolIdPin: bigint","params: {\n roleKey: Hex\n safe: `0x${string}`\n sfpm: `0x${string}`\n /** CollateralTracker for token0. */\n collateralTracker0: `0x${string}`\n /** CollateralTracker for token1. */\n collateralTracker1: `0x${string}`\n /** Deployed SfpmSwapCondition (stateless, canonical per chain). */\n adapter: `0x${string}`\n /** The registered `uint64` SFPM poolId of the allowed swap pool. */\n poolIdPin: bigint\n /** Safe MultiSendCallOnly address (the batch entrypoint). */\n multiSendCallOnly: `0x${string}`\n /** Canonical MultiSend unwrapper adapter for this chain. */\n multiSendUnwrapper: `0x${string}`\n /**\n * Which collateral asset is native ETH (its CT `deposit` is payable and needs\n * value; the batch wraps/unwraps around the swap). `'none'` for two-ERC20 pools.\n */\n nativeCollateral?: 'token0' | 'token1' | 'none'\n /** WETH9 address — required when `nativeCollateral` is not `'none'`. */\n weth9?: `0x${string}`\n}","side: 'token0' | 'token1'","ct: `0x${string}`","label: string","roleKey","steps: ScopeStep[]","params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed SizeAdjusterCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}"],"sources":["../../src/zodiac/rolesAbi.ts","../../src/zodiac/applySteps.ts","../../src/zodiac/conditions.ts","../../src/zodiac/constants.ts","../../src/zodiac/roles/dispatchCustomRole.ts","../../src/zodiac/roles/deleverager.ts","../../src/zodiac/roles/liquidator.ts","../../src/zodiac/tokenIdMask.ts","../../src/zodiac/roles/loanHedger.ts","../../src/zodiac/roles/maintenance.ts","../../src/zodiac/roles/roller.ts","../../src/zodiac/roles/sfpmSwap.ts","../../src/zodiac/roles/sizeAdjuster.ts"],"sourcesContent":["/** Minimal Zodiac Roles v2 modifier ABI used by the scoping/apply flows. */\nexport const rolesV2Abi = [\n {\n type: 'function',\n name: 'assignRoles',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'module', type: 'address' },\n { name: 'roleKeys', type: 'bytes32[]' },\n { name: 'memberOf', type: 'bool[]' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'scopeTarget',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'scopeFunction',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n {\n name: 'conditions',\n type: 'tuple[]',\n components: [\n { name: 'parent', type: 'uint8' },\n { name: 'paramType', type: 'uint8' },\n { name: 'operator', type: 'uint8' },\n { name: 'compValue', type: 'bytes' },\n ],\n },\n { name: 'options', type: 'uint8' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'allowFunction',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n { name: 'options', type: 'uint8' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'setTransactionUnwrapper',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n { name: 'adapter', type: 'address' },\n ],\n outputs: [],\n },\n] as const\n","import type { ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport { rolesV2Abi } from './rolesAbi'\n\ntype ScopeFunctionName = ContractFunctionName<typeof rolesV2Abi, 'nonpayable'>\n\n/** One idempotent Roles-modifier configuration call, paired with its ABI arguments. */\nexport type ScopeStep = {\n [Name in ScopeFunctionName]: {\n name: string\n functionName: Name\n args: ContractFunctionArgs<typeof rolesV2Abi, 'nonpayable', Name>\n }\n}[ScopeFunctionName]\n\n/**\n * Minimal structural client shapes (instead of viem's `PublicClient` /\n * `WalletClient`) so any viem 2.x instance is accepted — pnpm peer-keying can\n * produce multiple viem type-instances across a workspace, and the deeply\n * generic client types are not assignable across instances (TS2719).\n */\nexport interface ScopeStepsPublicClient {\n waitForTransactionReceipt(args: {\n hash: `0x${string}`\n timeout?: number\n }): Promise<{ status: string }>\n}\n\nexport interface ScopeStepsWalletClient {\n writeContract(args: {\n address: `0x${string}`\n abi: typeof rolesV2Abi\n functionName: ScopeStep['functionName']\n args: never\n maxFeePerGas?: bigint\n maxPriorityFeePerGas?: bigint\n }): Promise<`0x${string}`>\n}\n\n/**\n * Apply scope steps to a Roles v2 modifier sequentially, aborting on the\n * first revert so a partially-applied role is never silently left behind.\n * The wallet must be the modifier's owner.\n */\nexport async function applyScopeSteps(params: {\n publicClient: ScopeStepsPublicClient\n walletClient: ScopeStepsWalletClient\n rolesModifier: `0x${string}`\n steps: ScopeStep[]\n log?: (line: string) => void\n /**\n * EIP-1559 fee overrides applied to every tx. Pass a NON-ZERO\n * `maxPriorityFeePerGas` — some RPC estimators return a zero tip, which leaves\n * txs un-prioritised and slow to include.\n */\n fees?: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n /** Receipt-wait timeout (ms). */\n timeoutMs?: number\n}): Promise<void> {\n // eslint-disable-next-line no-console\n const { publicClient, walletClient, rolesModifier, steps, log = console.log } = params\n for (const step of steps) {\n log(`→ ${step.name}`)\n const hash = await walletClient.writeContract({\n address: rolesModifier,\n abi: rolesV2Abi,\n functionName: step.functionName,\n args: step.args as never,\n ...(params.fees ?? {}),\n })\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n ...(params.timeoutMs ? { timeout: params.timeoutMs } : {}),\n })\n log(` ${receipt.status} ${hash}`)\n if (receipt.status !== 'success') {\n throw new Error(`step \"${step.name}\" reverted (tx ${hash}); aborting before later steps`)\n }\n }\n}\n","import type { Hex } from 'viem'\n\n/** Roles v2 flat condition node (BFS-ordered tree). */\nexport interface ConditionFlat {\n parent: number\n paramType: number\n operator: number\n compValue: Hex\n}\n\n/** True for a 0x-prefixed, 20-byte (40 hex char) address. */\nfunction isHexAddress(v: string): boolean {\n return /^0x[0-9a-fA-F]{40}$/.test(v)\n}\n\n/** 32-byte left-padded address as an EqualTo Static compValue. */\nexport function addressEqualCompValue(addr: `0x${string}`): Hex {\n if (!isHexAddress(addr)) {\n throw new Error(`addressEqualCompValue: expected a 20-byte hex address, got \"${addr}\"`)\n }\n return `0x${addr.slice(2).toLowerCase().padStart(64, '0')}` as Hex\n}\n\n/**\n * Operator.Custom compValue: adapter address in the leading 20 bytes, the\n * trailing 12 bytes are passed to the adapter verbatim as `extra`.\n */\nexport function customCompValue(adapter: `0x${string}`, extra: Hex = '0x'): Hex {\n if (!isHexAddress(adapter)) {\n throw new Error(`customCompValue: adapter must be a 20-byte hex address, got \"${adapter}\"`)\n }\n if (!/^0x([0-9a-fA-F]{2})*$/.test(extra)) {\n throw new Error(`customCompValue: extra must be 0x-prefixed, even-length hex, got \"${extra}\"`)\n }\n if (extra.length - 2 > 24) throw new Error('customCompValue: extra must be at most 12 bytes')\n const extraHex = extra.slice(2).padEnd(24, '0')\n return `0x${adapter.slice(2).toLowerCase()}${extraHex}` as Hex\n}\n\n/**\n * Encode a uint96 mint-size cap as the `bytes12 extra` of a pair-condition\n * compValue (0n = uncapped). The adapters read it as `uint96(extra)`, i.e.\n * big-endian right-aligned in the 12 bytes.\n */\nexport function sizeCapExtra(cap: bigint): Hex {\n if (cap < 0n || cap >= 1n << 96n) throw new Error('size cap must fit in uint96')\n return `0x${cap.toString(16).padStart(24, '0')}` as Hex\n}\n","/**\n * Zodiac Roles Modifier v2 enum ordinals.\n *\n * Verified against gnosisguild/zodiac-modifier-roles `contracts/Types.sol`\n * (commit c343958ab7317b31d8c4aec790606d950ea21eed) and the deployed v2.1\n * mastercopy 0x9646fDAD06d3e24444381f44362a3B0eB343D337. Keep in sync with the\n * modifier version the Safe actually runs.\n */\n\nexport const ParameterType = {\n None: 0,\n Static: 1,\n Dynamic: 2,\n Tuple: 3,\n Array: 4,\n Calldata: 5,\n AbiEncoded: 6,\n} as const\n\nexport const Operator = {\n Pass: 0,\n And: 1,\n Or: 2,\n Nor: 3,\n Matches: 5,\n ArraySome: 6,\n ArrayEvery: 7,\n ArraySubset: 8,\n EqualToAvatar: 15,\n EqualTo: 16,\n GreaterThan: 17,\n LessThan: 18,\n SignedIntGreaterThan: 19,\n SignedIntLessThan: 20,\n Bitmask: 21,\n Custom: 22,\n WithinAllowance: 28,\n EtherWithinAllowance: 29,\n CallWithinAllowance: 30,\n} as const\n\n/**\n * Canonical adapter addresses — deterministic CREATE2 (factory\n * 0x4e59b44847b379578588920cA78FbF26c0B4956C, salt\n * keccak256(\"panoptic.zodiac-modules.v1\")), so they depend only on the\n * bytecode: same on every chain, deployer-independent, verifiable with\n * `cast code` against a local `forge build`. The adapters are stateless and\n * immutable (no owner/storage/upgradability). Recompute via\n * `forge script scripts/DeployAdapters.s.sol` after any source change.\n */\nexport const CANONICAL_ADAPTERS = {\n RollerCondition: '0x7b2402F7Ff7fFe0970D383dE1C6AF8892B87523a',\n SizeAdjusterCondition: '0x72494B2A0C5a69Dd0154386c2F4Af0b38a24C400',\n SfpmSwapCondition: '0x9321DdE7242dFcFac61D1b2d357e88FC4302eAF7',\n} as const\n\nexport const ExecutionOptions = {\n None: 0,\n Send: 1,\n DelegateCall: 2,\n Both: 3,\n} as const\n","import { type Hex, keccak256, toBytes, toFunctionSelector } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\n\n/** PanopticPool.dispatch — TokenId is a uint256 value type. */\nexport const DISPATCH_SELECTOR = toFunctionSelector(\n 'dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)',\n)\n\n/** Deterministic per-role keys; override via env/config if a Safe needs several instances. */\nexport function roleKey(name: string): Hex {\n return keccak256(toBytes(`panoptic.role.${name}.v1`))\n}\n\n/**\n * ConditionFlat tree for a dispatch-scoped role whose whole authorization\n * logic lives in an on-chain `ICustomCondition` adapter (Operator.Custom).\n *\n * The Custom node is attached to arg0 (`positionIdList`): Roles hands the\n * adapter the FULL calldata regardless of attachment point, and the adapter\n * decodes `positionIdList`/`positionSizes` itself. The remaining nodes are the\n * structural template `Integrity.sol` requires (Calldata and Array nodes must\n * describe their children; see buildLoanOnlyDispatchConditions for the shape).\n */\nexport function buildDispatchCustomConditions(\n adapter: `0x${string}`,\n extra: Hex = '0x',\n): ConditionFlat[] {\n const compValue = customCompValue(adapter, extra)\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — carries the Custom adapter check\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Custom, compValue },\n // 2: arg1 finalPositionIdList\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7-9: array element types\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-13: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/** assignRoles → scopeTarget → scopeFunction steps for an adapter-gated dispatch role. */\nexport function buildDispatchCustomRoleSteps(params: {\n roleName: string\n roleKey: Hex\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}`\n extra?: Hex\n}): ScopeStep[] {\n const { roleName, member, pool, adapter, extra } = params\n return [\n {\n name: `assignRoles(${roleName} member)`,\n functionName: 'assignRoles',\n args: [member, [params.roleKey], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [params.roleKey, pool] },\n {\n name: `scopeFunction(dispatch, ${roleName} custom adapter)`,\n functionName: 'scopeFunction',\n args: [\n params.roleKey,\n pool,\n DISPATCH_SELECTOR,\n buildDispatchCustomConditions(adapter, extra),\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport type { ConditionFlat } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { DISPATCH_SELECTOR, roleKey } from './dispatchCustomRole'\n\n/**\n * Deleverager role: burn the Safe's existing positions only — never mint.\n *\n * Enforced with plain static conditions, no adapter and no state oracle:\n * every `positionSizes` entry must be 0. A size-0 entry either burns a held\n * position or reverts the whole dispatch — a size-0 mint is impossible\n * (option legs trip `ChunkHasZeroLiquidity` in the SFPM; pure-loan tokenIds\n * die in the end-of-dispatch solvency pass / positions-hash validation).\n *\n * Trade-off vs an oracle-based check: the key cannot settle premium (settle\n * requires `sizes[i] == storedSize`, unknowable pre-execution). Strictly a\n * risk-reduction key: safe for a watchdog keeper or dead-man's-switch.\n */\nexport const DELEVERAGER_ROLE_KEY = roleKey('deleverager')\n\nconst ZERO_WORD = `0x${'0'.repeat(64)}` as Hex\n\nexport function buildDeleveragerDispatchConditions(): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — unconstrained (any held tokenId may be burnt)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 2: arg1 finalPositionIdList\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes — EVERY entry must be 0 (burn-or-revert)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.ArrayEvery, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7-9: array element types\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 3,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: ZERO_WORD,\n },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-13: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\nexport function buildDeleveragerRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n roleKey?: Hex\n}): ScopeStep[] {\n const key = params.roleKey ?? DELEVERAGER_ROLE_KEY\n return [\n {\n name: 'assignRoles(deleverager member)',\n functionName: 'assignRoles',\n args: [params.member, [key], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [key, params.pool] },\n {\n name: 'scopeFunction(dispatch, burn-only: all sizes == 0)',\n functionName: 'scopeFunction',\n args: [\n key,\n params.pool,\n DISPATCH_SELECTOR,\n buildDeleveragerDispatchConditions(),\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","import { type Address, type Hex, toFunctionSelector, zeroAddress } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\n\n/**\n * Liquidator role: scopes ONLY `PanopticLiquidator.liquidate(LiquidateParams)`\n * on the helper. `initializePool`, `execute`, `multicall`, `sweep`, and\n * `quoteLiquidation` are never scoped.\n *\n * Split of enforcement (must match the LiquidatorCondition contract and the\n * hand-encoded tree in zodiac-modules/test/LiquidatorRolesFork.t.sol, which is\n * the golden spec for this builder):\n * - THIS TREE pins the static fields: pool ∈ allowlist, account ∉ {safe,\n * helper}, swap targets ∈ {router, 0}, premia flags = 0, and — via\n * ExecutionOptions.None — zero outer msg.value (attached value is excluded\n * from the helper's minDelta floors, so it must never flow through the\n * role; native shortfalls are funded via nativeFundingAmount instead).\n * - THE ADAPTER (Custom node on positionIdListTo; Roles hands it full\n * calldata) enforces the cross-field invariants: flash/swap tokens ∈ pool\n * underlyings, swap groups zeroed together or exact nonzero amounts,\n * nativeFundingAmount only on native pools, floors ≥ 0 with one positive.\n */\nexport const LIQUIDATE_SELECTOR = toFunctionSelector(\n 'liquidate((address,address,uint256[],uint256,address,uint256,uint256,address,bytes,address,uint256,address,bytes,address,uint256,int256,int256))',\n)\n\nexport interface LiquidatorConditionsParams {\n /** Deployed LiquidatorCondition adapter. */\n adapter: Address\n /** The Safe (avatar) — excluded as a liquidation target. */\n safe: Address\n /** The PanopticLiquidator helper — also excluded as a target. */\n helper: Address\n /** Pinned swap router (Uniswap Universal Router). */\n router: Address\n /** PanopticPool allowlist (at least one). */\n pools: readonly Address[]\n /** Trailing 12 bytes of the Custom compValue (unused by the adapter). */\n extra?: Hex\n}\n\n/** BFS ConditionFlat tree over liquidate's single LiquidateParams tuple. */\nexport function buildLiquidatorConditions(params: LiquidatorConditionsParams): ConditionFlat[] {\n const { adapter, safe, helper, router, pools, extra = '0x' } = params\n if (pools.length === 0) throw new Error('liquidator role needs at least one pool')\n\n const pass = (parent: number, paramType: ConditionFlat['paramType']): ConditionFlat => ({\n parent,\n paramType,\n operator: Operator.Pass,\n compValue: '0x',\n })\n\n const conditions: ConditionFlat[] = [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: the LiquidateParams tuple\n { parent: 0, paramType: ParameterType.Tuple, operator: Operator.Matches, compValue: '0x' },\n // 2: pool — Or(EqualTo(pool_i)) allowlist\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n // 3: account — Nor(EqualTo(safe), EqualTo(helper))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Nor, compValue: '0x' },\n // 4: positionIdListTo — carries the Custom adapter (full-calldata hook)\n {\n parent: 1,\n paramType: ParameterType.Array,\n operator: Operator.Custom,\n compValue: customCompValue(adapter, extra),\n },\n // 5: usePremiaAsCollateral — pinned to zero\n {\n parent: 1,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: '0x0000000000000000000000000000000000000000000000000000000000000000',\n },\n pass(1, ParameterType.Static), // 6: flashToken\n pass(1, ParameterType.Static), // 7: flashAmount\n pass(1, ParameterType.Static), // 8: nativeFundingAmount\n // 9: preSwapTarget — Or(EqualTo(router), EqualTo(0))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n pass(1, ParameterType.Dynamic), // 10: preSwapCallData\n pass(1, ParameterType.Static), // 11: preSwapTokenIn\n pass(1, ParameterType.Static), // 12: preSwapAmountIn\n // 13: swapTarget — Or(EqualTo(router), EqualTo(0))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n pass(1, ParameterType.Dynamic), // 14: swapCallData\n pass(1, ParameterType.Static), // 15: swapTokenIn\n pass(1, ParameterType.Static), // 16: swapAmountIn\n pass(1, ParameterType.Static), // 17: minDelta0\n pass(1, ParameterType.Static), // 18: minDelta1\n ]\n\n // Children (parents nondecreasing): pool allowlist under 2.\n for (const pool of pools) {\n conditions.push({\n parent: 2,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(pool),\n })\n }\n // account exclusions under 3.\n for (const excluded of [safe, helper]) {\n conditions.push({\n parent: 3,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(excluded),\n })\n }\n // positionIdListTo element template under 4.\n conditions.push(pass(4, ParameterType.Static))\n // swap target pins under 9 and 13.\n for (const parent of [9, 13]) {\n conditions.push({\n parent,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(router),\n })\n conditions.push({\n parent,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(zeroAddress),\n })\n }\n\n return conditions\n}\n\n/** assignRoles → scopeTarget → scopeFunction for the liquidator role. */\nexport function buildLiquidatorRoleSteps(\n params: LiquidatorConditionsParams & { roleKey: Hex; member: Address },\n): ScopeStep[] {\n return [\n {\n name: 'assignRoles(liquidator member)',\n functionName: 'assignRoles',\n args: [params.member, [params.roleKey], [true]],\n },\n {\n name: 'scopeTarget(helper)',\n functionName: 'scopeTarget',\n args: [params.roleKey, params.helper],\n },\n {\n name: 'scopeFunction(liquidate, liquidator conditions)',\n functionName: 'scopeFunction',\n args: [\n params.roleKey,\n params.helper,\n LIQUIDATE_SELECTOR,\n buildLiquidatorConditions(params),\n // No Send: zero outer msg.value is load-bearing (see module docblock).\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","/**\n * Bit-field masks over the Panoptic v2 tokenId layout, mirroring\n * `contracts/lib/TokenIdMasks.sol` (kept in lockstep by golden unit tests).\n *\n * Layout (packages/panoptic-v2-core/contracts/types/TokenId.sol):\n * - bits [0, 64) poolId\n * - each leg is 48 bits, starting at 64 + legIndex*48, packing\n * asset(+0,1b) | optionRatio(+1,7b) | isLong(+8) | tokenType(+9)\n * | riskPartner(+10,2b) | strike(+12,24b) | width(+36,12b)\n */\n\nconst POOL_ID_SIZE = 64n\nconst LEG_SIZE = 48n\nconst MAX_LEGS = 4n\n\n/** Mask with 1-bits over a `bits`-wide field at `fieldOffset` in every leg. */\nexport function legFieldMask(fieldOffset: bigint, bits: bigint): bigint {\n const field = (1n << bits) - 1n\n let mask = 0n\n for (let leg = 0n; leg < MAX_LEGS; leg++) {\n mask |= field << (POOL_ID_SIZE + leg * LEG_SIZE + fieldOffset)\n }\n return mask\n}\n\n/** Mask with 1-bits over every leg's 12-bit width field. */\nexport function loanWidthFieldsMask(): bigint {\n return legFieldMask(36n, 12n)\n}\n\n/** Mask with 1-bits over every leg's 24-bit strike field. */\nexport function strikeFieldsMask(): bigint {\n return legFieldMask(12n, 24n)\n}\n\n/** Mask with 1-bits over every leg's 7-bit optionRatio field. */\nexport function optionRatioFieldsMask(): bigint {\n return legFieldMask(1n, 7n)\n}\n\n/** True iff every leg of the tokenId has width == 0 (a pure loan/credit). */\nexport function isPureLoanTokenId(tokenId: bigint): boolean {\n return (tokenId & loanWidthFieldsMask()) === 0n\n}\n\n/** The 32-byte mask + expected value for a Zodiac Roles v2 Bitmask condition. */\nexport function loanBitmaskCondition(): { mask: `0x${string}`; expected: `0x${string}` } {\n const mask = loanWidthFieldsMask()\n const toBytes32 = (v: bigint) => `0x${v.toString(16).padStart(64, '0')}` as `0x${string}`\n return { mask: toBytes32(mask), expected: toBytes32(0n) }\n}\n","import type { Hex } from 'viem'\n\nimport { type ConditionFlat, addressEqualCompValue } from '../conditions'\nimport { Operator, ParameterType } from '../constants'\nimport { loanBitmaskCondition } from '../tokenIdMask'\n\n/**\n * Loan-only hedger role scope (migrated from apps/hedger-bot scripts/lib).\n *\n * ⚠️ VALIDATE ON A FORK BEFORE MAINNET. The ConditionFlat encoding below is\n * security-critical. Dry-run `scopeFunction` on an anvil/Tenderly fork and\n * assert that the role CAN mint/burn a pure width=0 loan via dispatch and\n * CANNOT dispatch a tokenId with any width>0 leg.\n *\n * The scope constrains PanopticPool.dispatch(positionIdList, finalPositionIdList,\n * positionSizes, tickAndSpreadLimits, usePremiaAsCollateral, builderCode) so that\n * EVERY element of `positionIdList` (arg 0 — the tokenIds actually minted/burned)\n * is a pure loan: `tokenId & widthFieldsMask == 0`. All other args pass freely;\n * `finalPositionIdList` is intentionally NOT constrained (it legitimately contains\n * the user's option positions that remain open).\n */\n\n/**\n * Bitmask compValue layout (Roles v2 `PermissionChecker._bitmask`): a 32-byte\n * word packing `uint16 shift | bytes15 mask | bytes15 expected`, where `shift`\n * is a BYTE offset from the start (left / most-significant end) of the value\n * and the 15-byte mask is applied LEFT-aligned to `bytes32(value[shift:])`.\n *\n * The four 12-bit width fields span tokenId bits 100–255 (leg 3's width sits in\n * the top two bytes), which is wider than one 15-byte window. So the loan\n * constraint is expressed as TWO windows AND-ed together:\n * - shift 0: tokenId bytes 0..14 (bits 136–255) — covers legs 1, 2, 3\n * - shift 17: tokenId bytes 17..31 (bits 0–119) — covers leg 0\n * Bytes 15–16 (bits 120–135) contain no width bits.\n */\nexport const LOAN_BITMASK_WINDOW_SHIFTS = [0, 17] as const\n\nexport function loanBitmaskCompValueAt(shiftBytes: number): Hex {\n const { mask } = loanBitmaskCondition()\n const maskBytes = mask.slice(2) // 64 hex chars, byte 0 first\n const window = maskBytes.slice(shiftBytes * 2, shiftBytes * 2 + 30).padEnd(30, '0')\n const shift = shiftBytes.toString(16).padStart(4, '0')\n return `0x${shift}${window}${'0'.repeat(30)}` as Hex // expected = all zeros\n}\n\n/**\n * Build the ConditionFlat[] tree scoping dispatch to loan-only positionIdList.\n *\n * Roles v2 `Integrity.sol` requirements honored here:\n * - BFS order: parent indices must be non-decreasing (NotBFS).\n * - Every Array-typed node needs >=1 child describing the element type\n * (UnsuitableChildCount); ArrayEvery needs exactly 1.\n * - And nodes use ParameterType.None and an empty compValue.\n */\nexport function buildLoanOnlyDispatchConditions(): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — every element must satisfy subtree [7]\n { parent: 0, paramType: ParameterType.Array, operator: Operator.ArrayEvery, compValue: '0x' },\n // 2: arg1 finalPositionIdList — unconstrained (holds user option positions)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7: positionIdList element (uint256 tokenId) — both width windows must be zero\n { parent: 1, paramType: ParameterType.None, operator: Operator.And, compValue: '0x' },\n // 8: finalPositionIdList element\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 9: positionSizes element\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-12: the two AND-ed bitmask windows over the tokenId\n {\n parent: 7,\n paramType: ParameterType.Static,\n operator: Operator.Bitmask,\n compValue: loanBitmaskCompValueAt(LOAN_BITMASK_WINDOW_SHIFTS[0]),\n },\n {\n parent: 7,\n paramType: ParameterType.Static,\n operator: Operator.Bitmask,\n compValue: loanBitmaskCompValueAt(LOAN_BITMASK_WINDOW_SHIFTS[1]),\n },\n // 13-15: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n// ---------------------------------------------------------------------------\n// Cross-pool scope: MultiSend unwrap + per-inner-call scopes.\n//\n// The bot batches [CT.withdraw, router.execute, CT.deposit] via Safe MultiSend,\n// routed through Roles with a MultiSend unwrapper registered so each inner call\n// is re-checked against these scopes. Selectors below are the inner targets.\n// ---------------------------------------------------------------------------\n\n/** ERC4626 CollateralTracker withdraw(uint256 assets, address receiver, address owner). */\nexport const WITHDRAW_SELECTOR = '0xb460af94' as const\n/** ERC4626 CollateralTracker deposit(uint256 assets, address receiver). */\nexport const DEPOSIT_SELECTOR = '0x6e553f65' as const\n/** Uniswap UniversalRouter execute(bytes,bytes[],uint256). */\nexport const EXECUTE_SELECTOR = '0x3593564c' as const\n\n/**\n * Scope CT.withdraw so tokens can only be pulled to the Safe: receiver == owner\n * == Safe. Without this, a compromised bot key could withdraw the Safe's\n * collateral to an arbitrary address — this is the critical cross-pool scope.\n */\nexport function buildWithdrawConditions(safe: `0x${string}`): ConditionFlat[] {\n const safeEq = addressEqualCompValue(safe)\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' }, // assets\n { parent: 0, paramType: ParameterType.Static, operator: Operator.EqualTo, compValue: safeEq }, // receiver\n { parent: 0, paramType: ParameterType.Static, operator: Operator.EqualTo, compValue: safeEq }, // owner\n ]\n}\n\n/** Scope CT.deposit so the shares are credited to the Safe: receiver == Safe. */\nexport function buildDepositConditions(safe: `0x${string}`): ConditionFlat[] {\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' }, // assets\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(safe),\n }, // receiver\n ]\n}\n","import { type Hex, toFunctionSelector } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { roleKey } from './dispatchCustomRole'\n\n/**\n * Maintenance role: full `dispatchFrom` access — settle premium on, force-\n * exercise, and liquidate third-party accounts using the Safe's capital.\n * No adapter needed; the pool itself hash-validates the position lists.\n *\n * The only pin is `account != Safe` (Nor(EqualTo(safe))) so the maintenance\n * key can never force-exercise or liquidate the Safe's own book.\n * `positionIdListFrom` (the caller's solvency list) is intentionally\n * unconstrained — the Safe may legitimately hold option positions.\n *\n * dispatchFrom is payable ⇒ ExecutionOptions.Send.\n */\nexport const MAINTENANCE_ROLE_KEY = roleKey('maintenance')\n\n/** LeftRightUnsigned is a uint256 value type. */\nexport const DISPATCH_FROM_SELECTOR = toFunctionSelector(\n 'dispatchFrom(uint256[],address,uint256[],uint256[],uint256)',\n)\n\nexport function buildDispatchFromConditions(safe: `0x${string}`): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdListFrom (caller solvency list)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 2: arg1 account — anything but the Safe itself\n { parent: 0, paramType: ParameterType.None, operator: Operator.Nor, compValue: '0x' },\n // 3: arg2 positionIdListTo\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 positionIdListToFinal\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral (LeftRightUnsigned)\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg0 element\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7: Nor child — account == Safe (negated by the parent)\n {\n parent: 2,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(safe),\n },\n // 8: arg2 element\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 9: arg3 element\n { parent: 4, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\nexport function buildMaintenanceRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n safe: `0x${string}`\n roleKey?: Hex\n}): ScopeStep[] {\n const key = params.roleKey ?? MAINTENANCE_ROLE_KEY\n return [\n {\n name: 'assignRoles(maintenance member)',\n functionName: 'assignRoles',\n args: [params.member, [key], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [key, params.pool] },\n {\n name: 'scopeFunction(dispatchFrom, account != safe, Send)',\n functionName: 'scopeFunction',\n args: [\n key,\n params.pool,\n DISPATCH_FROM_SELECTOR,\n buildDispatchFromConditions(params.safe),\n ExecutionOptions.Send,\n ],\n },\n ]\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { sizeCapExtra } from '../conditions'\nimport { buildDispatchCustomRoleSteps, roleKey } from './dispatchCustomRole'\n\n/**\n * Roller role: close one position and reopen it identical-except-strike (roll\n * out-of-range positions back into range). Enforced on-chain by the stateless\n * `RollerCondition` adapter (strike-mask equality + one-burn-one-mint shape).\n *\n * The reopened size is bounded by `sizeCap` (0n = uncapped, leaving only\n * dispatch's solvency check as the ceiling) — there is no pre-state oracle,\n * so \"same size as before\" cannot be enforced.\n */\nexport const ROLLER_ROLE_KEY = roleKey('roller')\n\nexport function buildRollerRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed RollerCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}): ScopeStep[] {\n return buildDispatchCustomRoleSteps({\n roleName: 'roller',\n roleKey: params.roleKey ?? ROLLER_ROLE_KEY,\n member: params.member,\n pool: params.pool,\n adapter: params.adapter,\n extra: sizeCapExtra(params.sizeCap ?? 0n),\n })\n}\n","import { type Hex, toFunctionSelector, zeroHash } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { buildDepositConditions, DEPOSIT_SELECTOR } from './loanHedger'\n\n/** SFPM `multicall(bytes[])`. */\nexport const MULTICALL_SELECTOR = toFunctionSelector('multicall(bytes[])')\n/** Safe `MultiSend.multiSend(bytes)` — the batch entrypoint the Roles unwrapper is registered for. */\nexport const MULTISEND_SELECTOR = toFunctionSelector('multiSend(bytes)')\n/** WETH9 `deposit()` (wrap native ETH → WETH; payable). */\nexport const WETH_DEPOSIT_SELECTOR = toFunctionSelector('deposit()')\n/** WETH9 `withdraw(uint256)` (unwrap WETH → native ETH). */\nexport const WETH_WITHDRAW_SELECTOR = toFunctionSelector('withdraw(uint256)')\n/** Panoptic CT solvency-aware withdrawal used while the Safe has open positions. */\nexport const WITHDRAW_WITH_POSITIONS_SELECTOR = toFunctionSelector(\n 'withdraw(uint256,address,address,uint256[],bool)',\n)\n\n/**\n * Scope the solvency-aware CT withdrawal to the Safe and to the conservative\n * `usePremiaAsCollateral=false` mode. The position list remains dynamic because\n * it must exactly match the Safe's live Panoptic portfolio.\n */\nexport function buildWithdrawWithPositionsConditions(safe: `0x${string}`): ConditionFlat[] {\n const safeEq = addressEqualCompValue(safe)\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: safeEq,\n },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: safeEq,\n },\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: zeroHash,\n },\n { parent: 4, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/**\n * Encode a `uint64` SFPM poolId as the `bytes12 extra` of the SfpmSwapCondition\n * compValue. The adapter reads it as `uint64(uint96(extra))`, i.e. big-endian\n * right-aligned in the 12 bytes (same convention as `sizeCapExtra`).\n */\nexport function sfpmPoolIdPinExtra(poolId: bigint): Hex {\n if (poolId <= 0n || poolId >= 1n << 64n) {\n throw new Error(`sfpmPoolIdPinExtra: poolId must be a nonzero uint64, got ${poolId}`)\n }\n return `0x${poolId.toString(16).padStart(24, '0')}` as Hex\n}\n\n/**\n * ConditionFlat tree scoping `SFPM.multicall(bytes[])` to the SfpmSwapCondition\n * adapter. The whole check lives in the adapter (Operator.Custom on arg0); the\n * other nodes are the structural template Integrity.sol requires — a Calldata\n * root and the `bytes[]` array with its element type.\n */\nexport function buildSfpmSwapConditions(\n adapter: `0x${string}`,\n poolIdPin: bigint,\n): ConditionFlat[] {\n const compValue = customCompValue(adapter, sfpmPoolIdPinExtra(poolIdPin))\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 bytes[] — carries the Custom adapter check\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Custom, compValue },\n // 2: array element type (bytes → Dynamic)\n { parent: 1, paramType: ParameterType.Dynamic, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/**\n * Steps that extend an existing bot role with the off-venue SFPM swap surface.\n *\n * The bot batches `[CT(tokenIn).withdraw(with position list),\n * SFPM.multicall(mint+burn), CT(tokenOut).deposit]`\n * via Safe MultiSend, routed through Roles with a MultiSend unwrapper registered\n * so each inner call is re-checked against the scopes below.\n *\n * Reuses the existing bot `roleKey` (no `assignRoles`) — `execTransactionWithRole`\n * authorizes one role per tx and the batch mixes CT + SFPM calls, so all inner\n * calls must live under one key. The loan-only dispatch scope on that role is\n * orthogonal and unchanged.\n *\n * `setTransactionUnwrapper` is **modifier-global**, not per-role: registering it\n * affects every role on the modifier.\n */\nexport function buildSfpmSwapVenueSteps(params: {\n roleKey: Hex\n safe: `0x${string}`\n sfpm: `0x${string}`\n /** CollateralTracker for token0. */\n collateralTracker0: `0x${string}`\n /** CollateralTracker for token1. */\n collateralTracker1: `0x${string}`\n /** Deployed SfpmSwapCondition (stateless, canonical per chain). */\n adapter: `0x${string}`\n /** The registered `uint64` SFPM poolId of the allowed swap pool. */\n poolIdPin: bigint\n /** Safe MultiSendCallOnly address (the batch entrypoint). */\n multiSendCallOnly: `0x${string}`\n /** Canonical MultiSend unwrapper adapter for this chain. */\n multiSendUnwrapper: `0x${string}`\n /**\n * Which collateral asset is native ETH (its CT `deposit` is payable and needs\n * value; the batch wraps/unwraps around the swap). `'none'` for two-ERC20 pools.\n */\n nativeCollateral?: 'token0' | 'token1' | 'none'\n /** WETH9 address — required when `nativeCollateral` is not `'none'`. */\n weth9?: `0x${string}`\n}): ScopeStep[] {\n const {\n roleKey,\n safe,\n sfpm,\n collateralTracker0,\n collateralTracker1,\n adapter,\n poolIdPin,\n multiSendCallOnly,\n multiSendUnwrapper,\n } = params\n const nativeCollateral = params.nativeCollateral ?? 'none'\n\n // The native-ETH CT's deposit is payable (deposit by sending value), so it\n // needs ExecutionOptions.Send; ERC20 CT deposits take no value.\n const depositOptions = (side: 'token0' | 'token1') =>\n nativeCollateral === side ? ExecutionOptions.Send : ExecutionOptions.None\n\n const scopeCollateralTracker = (\n ct: `0x${string}`,\n side: 'token0' | 'token1',\n label: string,\n ): ScopeStep[] => [\n { name: `scopeTarget(${label})`, functionName: 'scopeTarget', args: [roleKey, ct] },\n {\n name: `scopeFunction(${label}.withdraw(with positions) → Safe)`,\n functionName: 'scopeFunction',\n args: [\n roleKey,\n ct,\n WITHDRAW_WITH_POSITIONS_SELECTOR,\n buildWithdrawWithPositionsConditions(safe),\n ExecutionOptions.None,\n ],\n },\n {\n name: `scopeFunction(${label}.deposit → Safe)`,\n functionName: 'scopeFunction',\n args: [roleKey, ct, DEPOSIT_SELECTOR, buildDepositConditions(safe), depositOptions(side)],\n },\n ]\n\n const steps: ScopeStep[] = [\n {\n name: 'setTransactionUnwrapper(MultiSend)',\n functionName: 'setTransactionUnwrapper',\n args: [multiSendCallOnly, MULTISEND_SELECTOR, multiSendUnwrapper],\n },\n { name: 'scopeTarget(SFPM)', functionName: 'scopeTarget', args: [roleKey, sfpm] },\n {\n name: 'scopeFunction(SFPM.multicall, SfpmSwapCondition)',\n functionName: 'scopeFunction',\n args: [\n roleKey,\n sfpm,\n MULTICALL_SELECTOR,\n buildSfpmSwapConditions(adapter, poolIdPin),\n ExecutionOptions.None,\n ],\n },\n ...scopeCollateralTracker(collateralTracker0, 'token0', 'CT0'),\n ...scopeCollateralTracker(collateralTracker1, 'token1', 'CT1'),\n ]\n\n // Bridge native ETH ↔ WETH around the v3 swap when a collateral asset is native.\n if (nativeCollateral !== 'none') {\n if (params.weth9 === undefined) {\n throw new Error('buildSfpmSwapVenueSteps: weth9 is required when nativeCollateral is set')\n }\n steps.push(\n { name: 'scopeTarget(WETH9)', functionName: 'scopeTarget', args: [roleKey, params.weth9] },\n {\n name: 'allowFunction(WETH9.deposit, Send)',\n functionName: 'allowFunction',\n args: [roleKey, params.weth9, WETH_DEPOSIT_SELECTOR, ExecutionOptions.Send],\n },\n {\n name: 'allowFunction(WETH9.withdraw)',\n functionName: 'allowFunction',\n args: [roleKey, params.weth9, WETH_WITHDRAW_SELECTOR, ExecutionOptions.None],\n },\n )\n }\n\n return steps\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { sizeCapExtra } from '../conditions'\nimport { buildDispatchCustomRoleSteps, roleKey } from './dispatchCustomRole'\n\n/**\n * Size-adjuster role: replace one position with an identical-except-optionRatio\n * one — reduce a short whose long side was purchased, or grow a long as more\n * options are sold. Enforced on-chain by the stateless `SizeAdjusterCondition`\n * adapter (ratio-mask equality + one-burn-one-mint shape).\n *\n * Without a pre-state oracle the relative notional cap is not enforceable;\n * set `sizeCap` (uint96, 0n = uncapped) to bound the mint size absolutely.\n */\nexport const SIZE_ADJUSTER_ROLE_KEY = roleKey('size-adjuster')\n\nexport function buildSizeAdjusterRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed SizeAdjusterCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}): ScopeStep[] {\n return buildDispatchCustomRoleSteps({\n roleName: 'size-adjuster',\n roleKey: params.roleKey ?? SIZE_ADJUSTER_ROLE_KEY,\n member: params.member,\n pool: params.pool,\n adapter: params.adapter,\n extra: sizeCapExtra(params.sizeCap ?? 0n),\n })\n}\n"],"mappings":";;;;AACA,MAAa,aAAa;CACxB;EACE,MAAM;EACN,MAAM;EACN,iBAAiB;EACjB,QAAQ;GACN;IAAE,MAA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index.js","names":["params: {\n publicClient: ScopeStepsPublicClient\n walletClient: ScopeStepsWalletClient\n rolesModifier: `0x${string}`\n steps: ScopeStep[]\n log?: (line: string) => void\n /**\n * EIP-1559 fee overrides applied to every tx. Pass a NON-ZERO\n * `maxPriorityFeePerGas` — some RPC estimators return a zero tip, which leaves\n * txs un-prioritised and slow to include.\n */\n fees?: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n /** Receipt-wait timeout (ms). */\n timeoutMs?: number\n}","v: string","addr: `0x${string}`","adapter: `0x${string}`","extra: Hex","cap: bigint","name: string","adapter: `0x${string}`","extra: Hex","params: {\n roleName: string\n roleKey: Hex\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}`\n extra?: Hex\n}","params: {\n member: `0x${string}`\n pool: `0x${string}`\n roleKey?: Hex\n}","params: LiquidatorConditionsParams","parent: number","paramType: ConditionFlat['paramType']","conditions: ConditionFlat[]","params: LiquidatorConditionsParams & { roleKey: Hex; member: Address }","fieldOffset: bigint","bits: bigint","tokenId: bigint","v: bigint","shiftBytes: number","safe: `0x${string}`","safe: `0x${string}`","params: {\n member: `0x${string}`\n pool: `0x${string}`\n safe: `0x${string}`\n roleKey?: Hex\n}","params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed RollerCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}","safe: `0x${string}`","poolId: bigint","adapter: `0x${string}`","poolIdPin: bigint","params: {\n roleKey: Hex\n safe: `0x${string}`\n sfpm: `0x${string}`\n /** CollateralTracker for token0. */\n collateralTracker0: `0x${string}`\n /** CollateralTracker for token1. */\n collateralTracker1: `0x${string}`\n /** Deployed SfpmSwapCondition (stateless, canonical per chain). */\n adapter: `0x${string}`\n /** The registered `uint64` SFPM poolId of the allowed swap pool. */\n poolIdPin: bigint\n /** Safe MultiSendCallOnly address (the batch entrypoint). */\n multiSendCallOnly: `0x${string}`\n /** Canonical MultiSend unwrapper adapter for this chain. */\n multiSendUnwrapper: `0x${string}`\n /**\n * Which collateral asset is native ETH (its CT `deposit` is payable and needs\n * value; the batch wraps/unwraps around the swap). `'none'` for two-ERC20 pools.\n */\n nativeCollateral?: 'token0' | 'token1' | 'none'\n /** WETH9 address — required when `nativeCollateral` is not `'none'`. */\n weth9?: `0x${string}`\n}","side: 'token0' | 'token1'","ct: `0x${string}`","label: string","roleKey","steps: ScopeStep[]","params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed SizeAdjusterCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}"],"sources":["../../src/zodiac/rolesAbi.ts","../../src/zodiac/applySteps.ts","../../src/zodiac/conditions.ts","../../src/zodiac/constants.ts","../../src/zodiac/roles/dispatchCustomRole.ts","../../src/zodiac/roles/deleverager.ts","../../src/zodiac/roles/liquidator.ts","../../src/zodiac/tokenIdMask.ts","../../src/zodiac/roles/loanHedger.ts","../../src/zodiac/roles/maintenance.ts","../../src/zodiac/roles/roller.ts","../../src/zodiac/roles/sfpmSwap.ts","../../src/zodiac/roles/sizeAdjuster.ts"],"sourcesContent":["/** Minimal Zodiac Roles v2 modifier ABI used by the scoping/apply flows. */\nexport const rolesV2Abi = [\n {\n type: 'function',\n name: 'assignRoles',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'module', type: 'address' },\n { name: 'roleKeys', type: 'bytes32[]' },\n { name: 'memberOf', type: 'bool[]' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'scopeTarget',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'scopeFunction',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n {\n name: 'conditions',\n type: 'tuple[]',\n components: [\n { name: 'parent', type: 'uint8' },\n { name: 'paramType', type: 'uint8' },\n { name: 'operator', type: 'uint8' },\n { name: 'compValue', type: 'bytes' },\n ],\n },\n { name: 'options', type: 'uint8' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'allowFunction',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'roleKey', type: 'bytes32' },\n { name: 'targetAddress', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n { name: 'options', type: 'uint8' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'setTransactionUnwrapper',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'selector', type: 'bytes4' },\n { name: 'adapter', type: 'address' },\n ],\n outputs: [],\n },\n] as const\n","import type { ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport { rolesV2Abi } from './rolesAbi'\n\ntype ScopeFunctionName = ContractFunctionName<typeof rolesV2Abi, 'nonpayable'>\n\n/** One idempotent Roles-modifier configuration call, paired with its ABI arguments. */\nexport type ScopeStep = {\n [Name in ScopeFunctionName]: {\n name: string\n functionName: Name\n args: ContractFunctionArgs<typeof rolesV2Abi, 'nonpayable', Name>\n }\n}[ScopeFunctionName]\n\n/**\n * Minimal structural client shapes (instead of viem's `PublicClient` /\n * `WalletClient`) so any viem 2.x instance is accepted — pnpm peer-keying can\n * produce multiple viem type-instances across a workspace, and the deeply\n * generic client types are not assignable across instances (TS2719).\n */\nexport interface ScopeStepsPublicClient {\n waitForTransactionReceipt(args: {\n hash: `0x${string}`\n timeout?: number\n }): Promise<{ status: string }>\n}\n\nexport interface ScopeStepsWalletClient {\n writeContract(args: {\n address: `0x${string}`\n abi: typeof rolesV2Abi\n functionName: ScopeStep['functionName']\n args: never\n maxFeePerGas?: bigint\n maxPriorityFeePerGas?: bigint\n }): Promise<`0x${string}`>\n}\n\n/**\n * Apply scope steps to a Roles v2 modifier sequentially, aborting on the\n * first revert so a partially-applied role is never silently left behind.\n * The wallet must be the modifier's owner.\n */\nexport async function applyScopeSteps(params: {\n publicClient: ScopeStepsPublicClient\n walletClient: ScopeStepsWalletClient\n rolesModifier: `0x${string}`\n steps: ScopeStep[]\n log?: (line: string) => void\n /**\n * EIP-1559 fee overrides applied to every tx. Pass a NON-ZERO\n * `maxPriorityFeePerGas` — some RPC estimators return a zero tip, which leaves\n * txs un-prioritised and slow to include.\n */\n fees?: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n /** Receipt-wait timeout (ms). */\n timeoutMs?: number\n}): Promise<void> {\n // eslint-disable-next-line no-console\n const { publicClient, walletClient, rolesModifier, steps, log = console.log } = params\n for (const step of steps) {\n log(`→ ${step.name}`)\n const hash = await walletClient.writeContract({\n address: rolesModifier,\n abi: rolesV2Abi,\n functionName: step.functionName,\n args: step.args as never,\n ...(params.fees ?? {}),\n })\n const receipt = await publicClient.waitForTransactionReceipt({\n hash,\n ...(params.timeoutMs ? { timeout: params.timeoutMs } : {}),\n })\n log(` ${receipt.status} ${hash}`)\n if (receipt.status !== 'success') {\n throw new Error(`step \"${step.name}\" reverted (tx ${hash}); aborting before later steps`)\n }\n }\n}\n","import type { Hex } from 'viem'\n\n/** Roles v2 flat condition node (BFS-ordered tree). */\nexport interface ConditionFlat {\n parent: number\n paramType: number\n operator: number\n compValue: Hex\n}\n\n/** True for a 0x-prefixed, 20-byte (40 hex char) address. */\nfunction isHexAddress(v: string): boolean {\n return /^0x[0-9a-fA-F]{40}$/.test(v)\n}\n\n/** 32-byte left-padded address as an EqualTo Static compValue. */\nexport function addressEqualCompValue(addr: `0x${string}`): Hex {\n if (!isHexAddress(addr)) {\n throw new Error(`addressEqualCompValue: expected a 20-byte hex address, got \"${addr}\"`)\n }\n return `0x${addr.slice(2).toLowerCase().padStart(64, '0')}` as Hex\n}\n\n/**\n * Operator.Custom compValue: adapter address in the leading 20 bytes, the\n * trailing 12 bytes are passed to the adapter verbatim as `extra`.\n */\nexport function customCompValue(adapter: `0x${string}`, extra: Hex = '0x'): Hex {\n if (!isHexAddress(adapter)) {\n throw new Error(`customCompValue: adapter must be a 20-byte hex address, got \"${adapter}\"`)\n }\n if (!/^0x([0-9a-fA-F]{2})*$/.test(extra)) {\n throw new Error(`customCompValue: extra must be 0x-prefixed, even-length hex, got \"${extra}\"`)\n }\n if (extra.length - 2 > 24) throw new Error('customCompValue: extra must be at most 12 bytes')\n const extraHex = extra.slice(2).padEnd(24, '0')\n return `0x${adapter.slice(2).toLowerCase()}${extraHex}` as Hex\n}\n\n/**\n * Encode a uint96 mint-size cap as the `bytes12 extra` of a pair-condition\n * compValue (0n = uncapped). The adapters read it as `uint96(extra)`, i.e.\n * big-endian right-aligned in the 12 bytes.\n */\nexport function sizeCapExtra(cap: bigint): Hex {\n if (cap < 0n || cap >= 1n << 96n) throw new Error('size cap must fit in uint96')\n return `0x${cap.toString(16).padStart(24, '0')}` as Hex\n}\n","/**\n * Zodiac Roles Modifier v2 enum ordinals.\n *\n * Verified against gnosisguild/zodiac-modifier-roles `contracts/Types.sol`\n * (commit c343958ab7317b31d8c4aec790606d950ea21eed) and the deployed v2.1\n * mastercopy 0x9646fDAD06d3e24444381f44362a3B0eB343D337. Keep in sync with the\n * modifier version the Safe actually runs.\n */\n\nexport const ParameterType = {\n None: 0,\n Static: 1,\n Dynamic: 2,\n Tuple: 3,\n Array: 4,\n Calldata: 5,\n AbiEncoded: 6,\n} as const\n\nexport const Operator = {\n Pass: 0,\n And: 1,\n Or: 2,\n Nor: 3,\n Matches: 5,\n ArraySome: 6,\n ArrayEvery: 7,\n ArraySubset: 8,\n EqualToAvatar: 15,\n EqualTo: 16,\n GreaterThan: 17,\n LessThan: 18,\n SignedIntGreaterThan: 19,\n SignedIntLessThan: 20,\n Bitmask: 21,\n Custom: 22,\n WithinAllowance: 28,\n EtherWithinAllowance: 29,\n CallWithinAllowance: 30,\n} as const\n\n/**\n * Canonical adapter addresses — deterministic CREATE2 (factory\n * 0x4e59b44847b379578588920cA78FbF26c0B4956C, salt\n * keccak256(\"panoptic.zodiac-modules.v1\")), so they depend only on the\n * bytecode: same on every chain, deployer-independent, verifiable with\n * `cast code` against a local `forge build`. The adapters are stateless and\n * immutable (no owner/storage/upgradability). Recompute via\n * `forge script scripts/DeployAdapters.s.sol` after any source change.\n */\nexport const CANONICAL_ADAPTERS = {\n RollerCondition: '0x7b2402F7Ff7fFe0970D383dE1C6AF8892B87523a',\n SizeAdjusterCondition: '0x72494B2A0C5a69Dd0154386c2F4Af0b38a24C400',\n SfpmSwapCondition: '0x9321DdE7242dFcFac61D1b2d357e88FC4302eAF7',\n} as const\n\nexport const ExecutionOptions = {\n None: 0,\n Send: 1,\n DelegateCall: 2,\n Both: 3,\n} as const\n","import { type Hex, keccak256, toBytes, toFunctionSelector } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\n\n/** PanopticPool.dispatch — TokenId is a uint256 value type. */\nexport const DISPATCH_SELECTOR = toFunctionSelector(\n 'dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)',\n)\n\n/** Deterministic per-role keys; override via env/config if a Safe needs several instances. */\nexport function roleKey(name: string): Hex {\n return keccak256(toBytes(`panoptic.role.${name}.v1`))\n}\n\n/**\n * ConditionFlat tree for a dispatch-scoped role whose whole authorization\n * logic lives in an on-chain `ICustomCondition` adapter (Operator.Custom).\n *\n * The Custom node is attached to arg0 (`positionIdList`): Roles hands the\n * adapter the FULL calldata regardless of attachment point, and the adapter\n * decodes `positionIdList`/`positionSizes` itself. The remaining nodes are the\n * structural template `Integrity.sol` requires (Calldata and Array nodes must\n * describe their children; see buildLoanOnlyDispatchConditions for the shape).\n */\nexport function buildDispatchCustomConditions(\n adapter: `0x${string}`,\n extra: Hex = '0x',\n): ConditionFlat[] {\n const compValue = customCompValue(adapter, extra)\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — carries the Custom adapter check\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Custom, compValue },\n // 2: arg1 finalPositionIdList\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7-9: array element types\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-13: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/** assignRoles → scopeTarget → scopeFunction steps for an adapter-gated dispatch role. */\nexport function buildDispatchCustomRoleSteps(params: {\n roleName: string\n roleKey: Hex\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}`\n extra?: Hex\n}): ScopeStep[] {\n const { roleName, member, pool, adapter, extra } = params\n return [\n {\n name: `assignRoles(${roleName} member)`,\n functionName: 'assignRoles',\n args: [member, [params.roleKey], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [params.roleKey, pool] },\n {\n name: `scopeFunction(dispatch, ${roleName} custom adapter)`,\n functionName: 'scopeFunction',\n args: [\n params.roleKey,\n pool,\n DISPATCH_SELECTOR,\n buildDispatchCustomConditions(adapter, extra),\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport type { ConditionFlat } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { DISPATCH_SELECTOR, roleKey } from './dispatchCustomRole'\n\n/**\n * Deleverager role: burn the Safe's existing positions only — never mint.\n *\n * Enforced with plain static conditions, no adapter and no state oracle:\n * every `positionSizes` entry must be 0. A size-0 entry either burns a held\n * position or reverts the whole dispatch — a size-0 mint is impossible\n * (option legs trip `ChunkHasZeroLiquidity` in the SFPM; pure-loan tokenIds\n * die in the end-of-dispatch solvency pass / positions-hash validation).\n *\n * Trade-off vs an oracle-based check: the key cannot settle streamia (settle\n * requires `sizes[i] == storedSize`, unknowable pre-execution). Strictly a\n * risk-reduction key: safe for a watchdog keeper or dead-man's-switch.\n */\nexport const DELEVERAGER_ROLE_KEY = roleKey('deleverager')\n\nconst ZERO_WORD = `0x${'0'.repeat(64)}` as Hex\n\nexport function buildDeleveragerDispatchConditions(): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — unconstrained (any held tokenId may be burnt)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 2: arg1 finalPositionIdList\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes — EVERY entry must be 0 (burn-or-revert)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.ArrayEvery, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7-9: array element types\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 3,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: ZERO_WORD,\n },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-13: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\nexport function buildDeleveragerRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n roleKey?: Hex\n}): ScopeStep[] {\n const key = params.roleKey ?? DELEVERAGER_ROLE_KEY\n return [\n {\n name: 'assignRoles(deleverager member)',\n functionName: 'assignRoles',\n args: [params.member, [key], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [key, params.pool] },\n {\n name: 'scopeFunction(dispatch, burn-only: all sizes == 0)',\n functionName: 'scopeFunction',\n args: [\n key,\n params.pool,\n DISPATCH_SELECTOR,\n buildDeleveragerDispatchConditions(),\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","import { type Address, type Hex, toFunctionSelector, zeroAddress } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\n\n/**\n * Liquidator role: scopes ONLY `PanopticLiquidator.liquidate(LiquidateParams)`\n * on the helper. `initializePool`, `execute`, `multicall`, `sweep`, and\n * `quoteLiquidation` are never scoped.\n *\n * Split of enforcement (must match the LiquidatorCondition contract and the\n * hand-encoded tree in zodiac-modules/test/LiquidatorRolesFork.t.sol, which is\n * the golden spec for this builder):\n * - THIS TREE pins the static fields: pool ∈ allowlist, account ∉ {safe,\n * helper}, swap targets ∈ {router, 0}, streamia flags = 0, and — via\n * ExecutionOptions.None — zero outer msg.value (attached value is excluded\n * from the helper's minDelta floors, so it must never flow through the\n * role; native shortfalls are funded via nativeFundingAmount instead).\n * - THE ADAPTER (Custom node on positionIdListTo; Roles hands it full\n * calldata) enforces the cross-field invariants: flash/swap tokens ∈ pool\n * underlyings, swap groups zeroed together or exact nonzero amounts,\n * nativeFundingAmount only on native pools, floors ≥ 0 with one positive.\n */\nexport const LIQUIDATE_SELECTOR = toFunctionSelector(\n 'liquidate((address,address,uint256[],uint256,address,uint256,uint256,address,bytes,address,uint256,address,bytes,address,uint256,int256,int256))',\n)\n\nexport interface LiquidatorConditionsParams {\n /** Deployed LiquidatorCondition adapter. */\n adapter: Address\n /** The Safe (avatar) — excluded as a liquidation target. */\n safe: Address\n /** The PanopticLiquidator helper — also excluded as a target. */\n helper: Address\n /** Pinned swap router (Uniswap Universal Router). */\n router: Address\n /** PanopticPool allowlist (at least one). */\n pools: readonly Address[]\n /** Trailing 12 bytes of the Custom compValue (unused by the adapter). */\n extra?: Hex\n}\n\n/** BFS ConditionFlat tree over liquidate's single LiquidateParams tuple. */\nexport function buildLiquidatorConditions(params: LiquidatorConditionsParams): ConditionFlat[] {\n const { adapter, safe, helper, router, pools, extra = '0x' } = params\n if (pools.length === 0) throw new Error('liquidator role needs at least one pool')\n\n const pass = (parent: number, paramType: ConditionFlat['paramType']): ConditionFlat => ({\n parent,\n paramType,\n operator: Operator.Pass,\n compValue: '0x',\n })\n\n const conditions: ConditionFlat[] = [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: the LiquidateParams tuple\n { parent: 0, paramType: ParameterType.Tuple, operator: Operator.Matches, compValue: '0x' },\n // 2: pool — Or(EqualTo(pool_i)) allowlist\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n // 3: account — Nor(EqualTo(safe), EqualTo(helper))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Nor, compValue: '0x' },\n // 4: positionIdListTo — carries the Custom adapter (full-calldata hook)\n {\n parent: 1,\n paramType: ParameterType.Array,\n operator: Operator.Custom,\n compValue: customCompValue(adapter, extra),\n },\n // 5: usePremiaAsCollateral — pinned to zero\n {\n parent: 1,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: '0x0000000000000000000000000000000000000000000000000000000000000000',\n },\n pass(1, ParameterType.Static), // 6: flashToken\n pass(1, ParameterType.Static), // 7: flashAmount\n pass(1, ParameterType.Static), // 8: nativeFundingAmount\n // 9: preSwapTarget — Or(EqualTo(router), EqualTo(0))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n pass(1, ParameterType.Dynamic), // 10: preSwapCallData\n pass(1, ParameterType.Static), // 11: preSwapTokenIn\n pass(1, ParameterType.Static), // 12: preSwapAmountIn\n // 13: swapTarget — Or(EqualTo(router), EqualTo(0))\n { parent: 1, paramType: ParameterType.None, operator: Operator.Or, compValue: '0x' },\n pass(1, ParameterType.Dynamic), // 14: swapCallData\n pass(1, ParameterType.Static), // 15: swapTokenIn\n pass(1, ParameterType.Static), // 16: swapAmountIn\n pass(1, ParameterType.Static), // 17: minDelta0\n pass(1, ParameterType.Static), // 18: minDelta1\n ]\n\n // Children (parents nondecreasing): pool allowlist under 2.\n for (const pool of pools) {\n conditions.push({\n parent: 2,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(pool),\n })\n }\n // account exclusions under 3.\n for (const excluded of [safe, helper]) {\n conditions.push({\n parent: 3,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(excluded),\n })\n }\n // positionIdListTo element template under 4.\n conditions.push(pass(4, ParameterType.Static))\n // swap target pins under 9 and 13.\n for (const parent of [9, 13]) {\n conditions.push({\n parent,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(router),\n })\n conditions.push({\n parent,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(zeroAddress),\n })\n }\n\n return conditions\n}\n\n/** assignRoles → scopeTarget → scopeFunction for the liquidator role. */\nexport function buildLiquidatorRoleSteps(\n params: LiquidatorConditionsParams & { roleKey: Hex; member: Address },\n): ScopeStep[] {\n return [\n {\n name: 'assignRoles(liquidator member)',\n functionName: 'assignRoles',\n args: [params.member, [params.roleKey], [true]],\n },\n {\n name: 'scopeTarget(helper)',\n functionName: 'scopeTarget',\n args: [params.roleKey, params.helper],\n },\n {\n name: 'scopeFunction(liquidate, liquidator conditions)',\n functionName: 'scopeFunction',\n args: [\n params.roleKey,\n params.helper,\n LIQUIDATE_SELECTOR,\n buildLiquidatorConditions(params),\n // No Send: zero outer msg.value is load-bearing (see module docblock).\n ExecutionOptions.None,\n ],\n },\n ]\n}\n","/**\n * Bit-field masks over the Panoptic v2 tokenId layout, mirroring\n * `contracts/lib/TokenIdMasks.sol` (kept in lockstep by golden unit tests).\n *\n * Layout (packages/panoptic-v2-core/contracts/types/TokenId.sol):\n * - bits [0, 64) poolId\n * - each leg is 48 bits, starting at 64 + legIndex*48, packing\n * asset(+0,1b) | optionRatio(+1,7b) | isLong(+8) | tokenType(+9)\n * | riskPartner(+10,2b) | strike(+12,24b) | width(+36,12b)\n */\n\nconst POOL_ID_SIZE = 64n\nconst LEG_SIZE = 48n\nconst MAX_LEGS = 4n\n\n/** Mask with 1-bits over a `bits`-wide field at `fieldOffset` in every leg. */\nexport function legFieldMask(fieldOffset: bigint, bits: bigint): bigint {\n const field = (1n << bits) - 1n\n let mask = 0n\n for (let leg = 0n; leg < MAX_LEGS; leg++) {\n mask |= field << (POOL_ID_SIZE + leg * LEG_SIZE + fieldOffset)\n }\n return mask\n}\n\n/** Mask with 1-bits over every leg's 12-bit width field. */\nexport function loanWidthFieldsMask(): bigint {\n return legFieldMask(36n, 12n)\n}\n\n/** Mask with 1-bits over every leg's 24-bit strike field. */\nexport function strikeFieldsMask(): bigint {\n return legFieldMask(12n, 24n)\n}\n\n/** Mask with 1-bits over every leg's 7-bit optionRatio field. */\nexport function optionRatioFieldsMask(): bigint {\n return legFieldMask(1n, 7n)\n}\n\n/** True iff every leg of the tokenId has width == 0 (a pure loan/credit). */\nexport function isPureLoanTokenId(tokenId: bigint): boolean {\n return (tokenId & loanWidthFieldsMask()) === 0n\n}\n\n/** The 32-byte mask + expected value for a Zodiac Roles v2 Bitmask condition. */\nexport function loanBitmaskCondition(): { mask: `0x${string}`; expected: `0x${string}` } {\n const mask = loanWidthFieldsMask()\n const toBytes32 = (v: bigint) => `0x${v.toString(16).padStart(64, '0')}` as `0x${string}`\n return { mask: toBytes32(mask), expected: toBytes32(0n) }\n}\n","import type { Hex } from 'viem'\n\nimport { type ConditionFlat, addressEqualCompValue } from '../conditions'\nimport { Operator, ParameterType } from '../constants'\nimport { loanBitmaskCondition } from '../tokenIdMask'\n\n/**\n * Loan-only hedger role scope (migrated from apps/hedger-bot scripts/lib).\n *\n * ⚠️ VALIDATE ON A FORK BEFORE MAINNET. The ConditionFlat encoding below is\n * security-critical. Dry-run `scopeFunction` on an anvil/Tenderly fork and\n * assert that the role CAN mint/burn a pure width=0 loan via dispatch and\n * CANNOT dispatch a tokenId with any width>0 leg.\n *\n * The scope constrains PanopticPool.dispatch(positionIdList, finalPositionIdList,\n * positionSizes, tickAndSpreadLimits, usePremiaAsCollateral, builderCode) so that\n * EVERY element of `positionIdList` (arg 0 — the tokenIds actually minted/burned)\n * is a pure loan: `tokenId & widthFieldsMask == 0`. All other args pass freely;\n * `finalPositionIdList` is intentionally NOT constrained (it legitimately contains\n * the user's option positions that remain open).\n */\n\n/**\n * Bitmask compValue layout (Roles v2 `PermissionChecker._bitmask`): a 32-byte\n * word packing `uint16 shift | bytes15 mask | bytes15 expected`, where `shift`\n * is a BYTE offset from the start (left / most-significant end) of the value\n * and the 15-byte mask is applied LEFT-aligned to `bytes32(value[shift:])`.\n *\n * The four 12-bit width fields span tokenId bits 100–255 (leg 3's width sits in\n * the top two bytes), which is wider than one 15-byte window. So the loan\n * constraint is expressed as TWO windows AND-ed together:\n * - shift 0: tokenId bytes 0..14 (bits 136–255) — covers legs 1, 2, 3\n * - shift 17: tokenId bytes 17..31 (bits 0–119) — covers leg 0\n * Bytes 15–16 (bits 120–135) contain no width bits.\n */\nexport const LOAN_BITMASK_WINDOW_SHIFTS = [0, 17] as const\n\nexport function loanBitmaskCompValueAt(shiftBytes: number): Hex {\n const { mask } = loanBitmaskCondition()\n const maskBytes = mask.slice(2) // 64 hex chars, byte 0 first\n const window = maskBytes.slice(shiftBytes * 2, shiftBytes * 2 + 30).padEnd(30, '0')\n const shift = shiftBytes.toString(16).padStart(4, '0')\n return `0x${shift}${window}${'0'.repeat(30)}` as Hex // expected = all zeros\n}\n\n/**\n * Build the ConditionFlat[] tree scoping dispatch to loan-only positionIdList.\n *\n * Roles v2 `Integrity.sol` requirements honored here:\n * - BFS order: parent indices must be non-decreasing (NotBFS).\n * - Every Array-typed node needs >=1 child describing the element type\n * (UnsuitableChildCount); ArrayEvery needs exactly 1.\n * - And nodes use ParameterType.None and an empty compValue.\n */\nexport function buildLoanOnlyDispatchConditions(): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdList — every element must satisfy subtree [7]\n { parent: 0, paramType: ParameterType.Array, operator: Operator.ArrayEvery, compValue: '0x' },\n // 2: arg1 finalPositionIdList — unconstrained (holds user option positions)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 3: arg2 positionSizes\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 tickAndSpreadLimits (int24[3][])\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg5 builderCode\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7: positionIdList element (uint256 tokenId) — both width windows must be zero\n { parent: 1, paramType: ParameterType.None, operator: Operator.And, compValue: '0x' },\n // 8: finalPositionIdList element\n { parent: 2, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 9: positionSizes element\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 10: tickAndSpreadLimits element (int24[3] — statically encoded, 3 words)\n { parent: 4, paramType: ParameterType.Tuple, operator: Operator.Pass, compValue: '0x' },\n // 11-12: the two AND-ed bitmask windows over the tokenId\n {\n parent: 7,\n paramType: ParameterType.Static,\n operator: Operator.Bitmask,\n compValue: loanBitmaskCompValueAt(LOAN_BITMASK_WINDOW_SHIFTS[0]),\n },\n {\n parent: 7,\n paramType: ParameterType.Static,\n operator: Operator.Bitmask,\n compValue: loanBitmaskCompValueAt(LOAN_BITMASK_WINDOW_SHIFTS[1]),\n },\n // 13-15: int24[3] members\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n { parent: 10, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n// ---------------------------------------------------------------------------\n// Cross-pool scope: MultiSend unwrap + per-inner-call scopes.\n//\n// The bot batches [CT.withdraw, router.execute, CT.deposit] via Safe MultiSend,\n// routed through Roles with a MultiSend unwrapper registered so each inner call\n// is re-checked against these scopes. Selectors below are the inner targets.\n// ---------------------------------------------------------------------------\n\n/** ERC4626 CollateralTracker withdraw(uint256 assets, address receiver, address owner). */\nexport const WITHDRAW_SELECTOR = '0xb460af94' as const\n/** ERC4626 CollateralTracker deposit(uint256 assets, address receiver). */\nexport const DEPOSIT_SELECTOR = '0x6e553f65' as const\n/** Uniswap UniversalRouter execute(bytes,bytes[],uint256). */\nexport const EXECUTE_SELECTOR = '0x3593564c' as const\n\n/**\n * Scope CT.withdraw so tokens can only be pulled to the Safe: receiver == owner\n * == Safe. Without this, a compromised bot key could withdraw the Safe's\n * collateral to an arbitrary address — this is the critical cross-pool scope.\n */\nexport function buildWithdrawConditions(safe: `0x${string}`): ConditionFlat[] {\n const safeEq = addressEqualCompValue(safe)\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' }, // assets\n { parent: 0, paramType: ParameterType.Static, operator: Operator.EqualTo, compValue: safeEq }, // receiver\n { parent: 0, paramType: ParameterType.Static, operator: Operator.EqualTo, compValue: safeEq }, // owner\n ]\n}\n\n/** Scope CT.deposit so the shares are credited to the Safe: receiver == Safe. */\nexport function buildDepositConditions(safe: `0x${string}`): ConditionFlat[] {\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' }, // assets\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(safe),\n }, // receiver\n ]\n}\n","import { type Hex, toFunctionSelector } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { roleKey } from './dispatchCustomRole'\n\n/**\n * Maintenance role: full `dispatchFrom` access — settle streamia on, force-\n * exercise, and liquidate third-party accounts using the Safe's capital.\n * No adapter needed; the pool itself hash-validates the position lists.\n *\n * The only pin is `account != Safe` (Nor(EqualTo(safe))) so the maintenance\n * key can never force-exercise or liquidate the Safe's own book.\n * `positionIdListFrom` (the caller's solvency list) is intentionally\n * unconstrained — the Safe may legitimately hold option positions.\n *\n * dispatchFrom is payable ⇒ ExecutionOptions.Send.\n */\nexport const MAINTENANCE_ROLE_KEY = roleKey('maintenance')\n\n/** LeftRightUnsigned is a uint256 value type. */\nexport const DISPATCH_FROM_SELECTOR = toFunctionSelector(\n 'dispatchFrom(uint256[],address,uint256[],uint256[],uint256)',\n)\n\nexport function buildDispatchFromConditions(safe: `0x${string}`): ConditionFlat[] {\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 positionIdListFrom (caller solvency list)\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 2: arg1 account — anything but the Safe itself\n { parent: 0, paramType: ParameterType.None, operator: Operator.Nor, compValue: '0x' },\n // 3: arg2 positionIdListTo\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 4: arg3 positionIdListToFinal\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n // 5: arg4 usePremiaAsCollateral (LeftRightUnsigned)\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 6: arg0 element\n { parent: 1, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 7: Nor child — account == Safe (negated by the parent)\n {\n parent: 2,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: addressEqualCompValue(safe),\n },\n // 8: arg2 element\n { parent: 3, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n // 9: arg3 element\n { parent: 4, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\nexport function buildMaintenanceRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n safe: `0x${string}`\n roleKey?: Hex\n}): ScopeStep[] {\n const key = params.roleKey ?? MAINTENANCE_ROLE_KEY\n return [\n {\n name: 'assignRoles(maintenance member)',\n functionName: 'assignRoles',\n args: [params.member, [key], [true]],\n },\n { name: 'scopeTarget(pool)', functionName: 'scopeTarget', args: [key, params.pool] },\n {\n name: 'scopeFunction(dispatchFrom, account != safe, Send)',\n functionName: 'scopeFunction',\n args: [\n key,\n params.pool,\n DISPATCH_FROM_SELECTOR,\n buildDispatchFromConditions(params.safe),\n ExecutionOptions.Send,\n ],\n },\n ]\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { sizeCapExtra } from '../conditions'\nimport { buildDispatchCustomRoleSteps, roleKey } from './dispatchCustomRole'\n\n/**\n * Roller role: close one position and reopen it identical-except-strike (roll\n * out-of-range positions back into range). Enforced on-chain by the stateless\n * `RollerCondition` adapter (strike-mask equality + one-burn-one-mint shape).\n *\n * The reopened size is bounded by `sizeCap` (0n = uncapped, leaving only\n * dispatch's solvency check as the ceiling) — there is no pre-state oracle,\n * so \"same size as before\" cannot be enforced.\n */\nexport const ROLLER_ROLE_KEY = roleKey('roller')\n\nexport function buildRollerRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed RollerCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}): ScopeStep[] {\n return buildDispatchCustomRoleSteps({\n roleName: 'roller',\n roleKey: params.roleKey ?? ROLLER_ROLE_KEY,\n member: params.member,\n pool: params.pool,\n adapter: params.adapter,\n extra: sizeCapExtra(params.sizeCap ?? 0n),\n })\n}\n","import { type Hex, toFunctionSelector, zeroHash } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { type ConditionFlat, addressEqualCompValue, customCompValue } from '../conditions'\nimport { ExecutionOptions, Operator, ParameterType } from '../constants'\nimport { buildDepositConditions, DEPOSIT_SELECTOR } from './loanHedger'\n\n/** SFPM `multicall(bytes[])`. */\nexport const MULTICALL_SELECTOR = toFunctionSelector('multicall(bytes[])')\n/** Safe `MultiSend.multiSend(bytes)` — the batch entrypoint the Roles unwrapper is registered for. */\nexport const MULTISEND_SELECTOR = toFunctionSelector('multiSend(bytes)')\n/** WETH9 `deposit()` (wrap native ETH → WETH; payable). */\nexport const WETH_DEPOSIT_SELECTOR = toFunctionSelector('deposit()')\n/** WETH9 `withdraw(uint256)` (unwrap WETH → native ETH). */\nexport const WETH_WITHDRAW_SELECTOR = toFunctionSelector('withdraw(uint256)')\n/** Panoptic CT solvency-aware withdrawal used while the Safe has open positions. */\nexport const WITHDRAW_WITH_POSITIONS_SELECTOR = toFunctionSelector(\n 'withdraw(uint256,address,address,uint256[],bool)',\n)\n\n/**\n * Scope the solvency-aware CT withdrawal to the Safe and to the conservative\n * `usePremiaAsCollateral=false` mode. The position list remains dynamic because\n * it must exactly match the Safe's live Panoptic portfolio.\n */\nexport function buildWithdrawWithPositionsConditions(safe: `0x${string}`): ConditionFlat[] {\n const safeEq = addressEqualCompValue(safe)\n return [\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n { parent: 0, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: safeEq,\n },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: safeEq,\n },\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Pass, compValue: '0x' },\n {\n parent: 0,\n paramType: ParameterType.Static,\n operator: Operator.EqualTo,\n compValue: zeroHash,\n },\n { parent: 4, paramType: ParameterType.Static, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/**\n * Encode a `uint64` SFPM poolId as the `bytes12 extra` of the SfpmSwapCondition\n * compValue. The adapter reads it as `uint64(uint96(extra))`, i.e. big-endian\n * right-aligned in the 12 bytes (same convention as `sizeCapExtra`).\n */\nexport function sfpmPoolIdPinExtra(poolId: bigint): Hex {\n if (poolId <= 0n || poolId >= 1n << 64n) {\n throw new Error(`sfpmPoolIdPinExtra: poolId must be a nonzero uint64, got ${poolId}`)\n }\n return `0x${poolId.toString(16).padStart(24, '0')}` as Hex\n}\n\n/**\n * ConditionFlat tree scoping `SFPM.multicall(bytes[])` to the SfpmSwapCondition\n * adapter. The whole check lives in the adapter (Operator.Custom on arg0); the\n * other nodes are the structural template Integrity.sol requires — a Calldata\n * root and the `bytes[]` array with its element type.\n */\nexport function buildSfpmSwapConditions(\n adapter: `0x${string}`,\n poolIdPin: bigint,\n): ConditionFlat[] {\n const compValue = customCompValue(adapter, sfpmPoolIdPinExtra(poolIdPin))\n return [\n // 0: root over calldata\n { parent: 0, paramType: ParameterType.Calldata, operator: Operator.Matches, compValue: '0x' },\n // 1: arg0 bytes[] — carries the Custom adapter check\n { parent: 0, paramType: ParameterType.Array, operator: Operator.Custom, compValue },\n // 2: array element type (bytes → Dynamic)\n { parent: 1, paramType: ParameterType.Dynamic, operator: Operator.Pass, compValue: '0x' },\n ]\n}\n\n/**\n * Steps that extend an existing bot role with the off-venue SFPM swap surface.\n *\n * The bot batches `[CT(tokenIn).withdraw(with position list),\n * SFPM.multicall(mint+burn), CT(tokenOut).deposit]`\n * via Safe MultiSend, routed through Roles with a MultiSend unwrapper registered\n * so each inner call is re-checked against the scopes below.\n *\n * Reuses the existing bot `roleKey` (no `assignRoles`) — `execTransactionWithRole`\n * authorizes one role per tx and the batch mixes CT + SFPM calls, so all inner\n * calls must live under one key. The loan-only dispatch scope on that role is\n * orthogonal and unchanged.\n *\n * `setTransactionUnwrapper` is **modifier-global**, not per-role: registering it\n * affects every role on the modifier.\n */\nexport function buildSfpmSwapVenueSteps(params: {\n roleKey: Hex\n safe: `0x${string}`\n sfpm: `0x${string}`\n /** CollateralTracker for token0. */\n collateralTracker0: `0x${string}`\n /** CollateralTracker for token1. */\n collateralTracker1: `0x${string}`\n /** Deployed SfpmSwapCondition (stateless, canonical per chain). */\n adapter: `0x${string}`\n /** The registered `uint64` SFPM poolId of the allowed swap pool. */\n poolIdPin: bigint\n /** Safe MultiSendCallOnly address (the batch entrypoint). */\n multiSendCallOnly: `0x${string}`\n /** Canonical MultiSend unwrapper adapter for this chain. */\n multiSendUnwrapper: `0x${string}`\n /**\n * Which collateral asset is native ETH (its CT `deposit` is payable and needs\n * value; the batch wraps/unwraps around the swap). `'none'` for two-ERC20 pools.\n */\n nativeCollateral?: 'token0' | 'token1' | 'none'\n /** WETH9 address — required when `nativeCollateral` is not `'none'`. */\n weth9?: `0x${string}`\n}): ScopeStep[] {\n const {\n roleKey,\n safe,\n sfpm,\n collateralTracker0,\n collateralTracker1,\n adapter,\n poolIdPin,\n multiSendCallOnly,\n multiSendUnwrapper,\n } = params\n const nativeCollateral = params.nativeCollateral ?? 'none'\n\n // The native-ETH CT's deposit is payable (deposit by sending value), so it\n // needs ExecutionOptions.Send; ERC20 CT deposits take no value.\n const depositOptions = (side: 'token0' | 'token1') =>\n nativeCollateral === side ? ExecutionOptions.Send : ExecutionOptions.None\n\n const scopeCollateralTracker = (\n ct: `0x${string}`,\n side: 'token0' | 'token1',\n label: string,\n ): ScopeStep[] => [\n { name: `scopeTarget(${label})`, functionName: 'scopeTarget', args: [roleKey, ct] },\n {\n name: `scopeFunction(${label}.withdraw(with positions) → Safe)`,\n functionName: 'scopeFunction',\n args: [\n roleKey,\n ct,\n WITHDRAW_WITH_POSITIONS_SELECTOR,\n buildWithdrawWithPositionsConditions(safe),\n ExecutionOptions.None,\n ],\n },\n {\n name: `scopeFunction(${label}.deposit → Safe)`,\n functionName: 'scopeFunction',\n args: [roleKey, ct, DEPOSIT_SELECTOR, buildDepositConditions(safe), depositOptions(side)],\n },\n ]\n\n const steps: ScopeStep[] = [\n {\n name: 'setTransactionUnwrapper(MultiSend)',\n functionName: 'setTransactionUnwrapper',\n args: [multiSendCallOnly, MULTISEND_SELECTOR, multiSendUnwrapper],\n },\n { name: 'scopeTarget(SFPM)', functionName: 'scopeTarget', args: [roleKey, sfpm] },\n {\n name: 'scopeFunction(SFPM.multicall, SfpmSwapCondition)',\n functionName: 'scopeFunction',\n args: [\n roleKey,\n sfpm,\n MULTICALL_SELECTOR,\n buildSfpmSwapConditions(adapter, poolIdPin),\n ExecutionOptions.None,\n ],\n },\n ...scopeCollateralTracker(collateralTracker0, 'token0', 'CT0'),\n ...scopeCollateralTracker(collateralTracker1, 'token1', 'CT1'),\n ]\n\n // Bridge native ETH ↔ WETH around the v3 swap when a collateral asset is native.\n if (nativeCollateral !== 'none') {\n if (params.weth9 === undefined) {\n throw new Error('buildSfpmSwapVenueSteps: weth9 is required when nativeCollateral is set')\n }\n steps.push(\n { name: 'scopeTarget(WETH9)', functionName: 'scopeTarget', args: [roleKey, params.weth9] },\n {\n name: 'allowFunction(WETH9.deposit, Send)',\n functionName: 'allowFunction',\n args: [roleKey, params.weth9, WETH_DEPOSIT_SELECTOR, ExecutionOptions.Send],\n },\n {\n name: 'allowFunction(WETH9.withdraw)',\n functionName: 'allowFunction',\n args: [roleKey, params.weth9, WETH_WITHDRAW_SELECTOR, ExecutionOptions.None],\n },\n )\n }\n\n return steps\n}\n","import type { Hex } from 'viem'\n\nimport type { ScopeStep } from '../applySteps'\nimport { sizeCapExtra } from '../conditions'\nimport { buildDispatchCustomRoleSteps, roleKey } from './dispatchCustomRole'\n\n/**\n * Size-adjuster role: replace one position with an identical-except-optionRatio\n * one — reduce a short whose long side was purchased, or grow a long as more\n * options are sold. Enforced on-chain by the stateless `SizeAdjusterCondition`\n * adapter (ratio-mask equality + one-burn-one-mint shape).\n *\n * Without a pre-state oracle the relative notional cap is not enforceable;\n * set `sizeCap` (uint96, 0n = uncapped) to bound the mint size absolutely.\n */\nexport const SIZE_ADJUSTER_ROLE_KEY = roleKey('size-adjuster')\n\nexport function buildSizeAdjusterRoleSteps(params: {\n member: `0x${string}`\n pool: `0x${string}`\n adapter: `0x${string}` // deployed SizeAdjusterCondition (stateless, shared per chain)\n sizeCap?: bigint\n roleKey?: Hex\n}): ScopeStep[] {\n return buildDispatchCustomRoleSteps({\n roleName: 'size-adjuster',\n roleKey: params.roleKey ?? SIZE_ADJUSTER_ROLE_KEY,\n member: params.member,\n pool: params.pool,\n adapter: params.adapter,\n extra: sizeC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