@continuumdao/ctm-mpc-defi 0.1.4 → 0.2.0
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/dist/agent/catalog.cjs +878 -141
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.cts +756 -12
- package/dist/agent/catalog.d.ts +756 -12
- package/dist/agent/catalog.js +829 -142
- package/dist/agent/catalog.js.map +1 -1
- package/dist/chains/evm/index.cjs +13 -0
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.cts +3 -1
- package/dist/chains/evm/index.d.ts +3 -1
- package/dist/chains/evm/index.js +13 -1
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/index.cjs +825 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +825 -142
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +1987 -0
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -0
- package/dist/protocols/evm/aave-v4/index.d.cts +500 -0
- package/dist/protocols/evm/aave-v4/index.d.ts +500 -0
- package/dist/protocols/evm/aave-v4/index.js +1943 -0
- package/dist/protocols/evm/aave-v4/index.js.map +1 -0
- package/dist/protocols/evm/ethena/index.cjs +965 -0
- package/dist/protocols/evm/ethena/index.cjs.map +1 -0
- package/dist/protocols/evm/ethena/index.d.cts +161 -0
- package/dist/protocols/evm/ethena/index.d.ts +161 -0
- package/dist/protocols/evm/ethena/index.js +943 -0
- package/dist/protocols/evm/ethena/index.js.map +1 -0
- package/dist/protocols/evm/euler-v2/index.cjs +2263 -0
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -0
- package/dist/protocols/evm/euler-v2/index.d.cts +317 -0
- package/dist/protocols/evm/euler-v2/index.d.ts +317 -0
- package/dist/protocols/evm/euler-v2/index.js +2238 -0
- package/dist/protocols/evm/euler-v2/index.js.map +1 -0
- package/dist/protocols/evm/lido/index.cjs +834 -0
- package/dist/protocols/evm/lido/index.cjs.map +1 -0
- package/dist/protocols/evm/lido/index.d.cts +120 -0
- package/dist/protocols/evm/lido/index.d.ts +120 -0
- package/dist/protocols/evm/lido/index.js +809 -0
- package/dist/protocols/evm/lido/index.js.map +1 -0
- package/dist/protocols/evm/maple/index.cjs +707 -0
- package/dist/protocols/evm/maple/index.cjs.map +1 -0
- package/dist/protocols/evm/maple/index.d.cts +109 -0
- package/dist/protocols/evm/maple/index.d.ts +109 -0
- package/dist/protocols/evm/maple/index.js +693 -0
- package/dist/protocols/evm/maple/index.js.map +1 -0
- package/dist/protocols/evm/sky/index.cjs +1254 -0
- package/dist/protocols/evm/sky/index.cjs.map +1 -0
- package/dist/protocols/evm/sky/index.d.cts +218 -0
- package/dist/protocols/evm/sky/index.d.ts +218 -0
- package/dist/protocols/evm/sky/index.js +1229 -0
- package/dist/protocols/evm/sky/index.js.map +1 -0
- package/package.json +37 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/registry.ts","../../../../src/protocols/evm/maple/constants.ts","../../../../src/core/keygen.ts","../../../../src/chains/evm/txParams.ts","../../../../src/chains/evm/fees/chainFees.ts","../../../../src/chains/evm/fees/eip1559Align.ts","../../../../src/protocols/evm/maple/multisign.ts","../../../../src/protocols/evm/maple/index.ts"],"names":["gasPriceGwei","defineChain","createPublicClient","http","parseGwei"],"mappings":";;;AAEA,IAAM,UAA4B,EAAC;AAE5B,SAAS,uBAAuB,GAAA,EAA2B;AAChE,EAAA,MAAM,QAAA,GAAW,QAAQ,SAAA,CAAU,CAAC,MAAM,CAAA,CAAE,EAAA,KAAO,IAAI,EAAE,CAAA;AACzD,EAAA,IAAI,YAAY,CAAA,EAAG;AACjB,IAAA,OAAA,CAAQ,QAAQ,CAAA,GAAI,GAAA;AAAA,EACtB,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,EAClB;AACF;;;AC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AA,GAAoB;AAE1B,IAAM,mBAAA,GAAsC;AAAA,EACjD,EAAA,EAAI,iBAAA;AAAA,EACJ,aAAA,EAAe,KAAA;AAAA,EACf,iBAAiB,GAAA,EAAK;AACpB,IAAA,IAAI,GAAA,CAAI,aAAA,KAAkB,KAAA,EAAO,OAAO,KAAA;AACxC,IAAA,MAAM,CAAA,GAAI,OAAO,GAAA,CAAI,OAAA,KAAY,QAAA,GAAW,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,GAAA,CAAI,OAAO,GAAG,EAAE,CAAA;AACjG,IAAA,OAAO,2BAA2B,CAAC,CAAA;AAAA,EACrC,CAAA;AAAA,EACA,iBAAiB,KAAA,EAAO;AACtB,IAAA,OAAO,KAAA,CAAM,QAAA,KAAa,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,OAAA;AAAA,EACpD,CAAA;AAAA,EACA,OAAA,EAAS;AAAA,IACP,EAAE,EAAA,EAAI,qBAAA,EAAuB,UAAA,EAAY,iBAAA,EAAmB,eAAe,KAAA,EAAO,WAAA,EAAa,+BAAA,EAAiC,YAAA,EAAc,CAAC,QAAA,EAAU,aAAA,EAAe,cAAc,CAAA,EAAG,MAAA,EAAQ,EAAC,EAAE;AAAA,IACpM,EAAE,EAAA,EAAI,4BAAA,EAA8B,UAAA,EAAY,iBAAA,EAAmB,eAAe,KAAA,EAAO,WAAA,EAAa,0BAAA,EAA4B,YAAA,EAAc,CAAC,QAAA,EAAU,aAAA,EAAe,cAAc,CAAA,EAAG,MAAA,EAAQ,EAAC;AAAE;AAE1M;AAEA,sBAAA,CAAuB,mBAAmB,CAAA","file":"index.js","sourcesContent":["import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/** Public Maple Syrup (PoolV2 + SyrupRouter) integration constants. */\n\n/** Attributed deposits per Maple partner guidance (`bytes32` string label). */\nexport const MAPLE_SYRUP_DEPOSIT_DATA_ASCII = '0:continuumdao'\n\nexport const MAPLE_INTEGRATION_DOCS_URL =\n 'https://docs.maple.finance/integrate/ethereum-mainnet/frontend-integration'\n\nexport function mapleGraphqlEndpointForChain(chainId: number): string | null {\n if (chainId === 1) return 'https://api.maple.finance/v2/graphql'\n if (chainId === 11155111) return 'https://sepolia.api.maple.finance/v2/graphql'\n return null\n}\n\nexport function isMapleSyrupSupportedChain(chainId: number): boolean {\n return chainId === 1 || chainId === 11155111\n}\n","import type { KeyGenSubset } from './types.js'\n\nexport type { KeyGenSubset }\n\n/** App-compatible alias used by existing multisign builders. */\nexport type KeyGenSubsetForPermit = KeyGenSubset\n\nexport function firstClientIdFromKeyGen(data: KeyGenSubset | null | undefined): string | null {\n const map = data?.ClientKeys\n if (!map || typeof map !== 'object') return null\n for (const v of Object.values(map)) {\n if (typeof v === 'string' && v.trim()) return v.trim()\n }\n return null\n}\n\nexport function requirePubKeyHex(keyGen: KeyGenSubset): string {\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n return ph\n}\n\nexport function keyListFromKeyGen(keyGen: KeyGenSubset): string[] {\n return keyGen.keylist ?? []\n}\n","/**\n * Proposal-time EVM fields for POST /multiSignRequest (mpc-auth).\n * Same shape as trigger txParams and GET /getSignRequestById?tx_params=1.\n */\n\nexport type ProposalTxParams = {\n nonce: number\n gasLimit: string\n txType: 'eip1559' | 'legacy'\n maxFeePerGas?: string\n maxPriorityFeePerGas?: string\n gasPrice?: string\n}\n\nexport function gasLimitFromEstimateAndChainConfig(\n estimatedGas: bigint,\n chainGasLimit?: number,\n): bigint {\n if (chainGasLimit == null || !Number.isFinite(chainGasLimit) || chainGasLimit <= 0) {\n return estimatedGas\n }\n const cfg = BigInt(Math.floor(chainGasLimit))\n return cfg > estimatedGas ? cfg : estimatedGas\n}\n\nexport function routerSwapGasLimitFromEstimate(\n estimatedGas: bigint,\n chainGasLimit?: number | null,\n): bigint {\n if (chainGasLimit != null && Number.isFinite(chainGasLimit) && chainGasLimit > 0) {\n return gasLimitFromEstimateAndChainConfig(estimatedGas, chainGasLimit)\n }\n return (estimatedGas * 12n + 9n) / 10n\n}\n\nexport function composeFeePayloadToTxParams(\n p: Record<string, unknown>,\n legacy: boolean,\n): ProposalTxParams | undefined {\n const gl = p.txGasLimit ?? p.txgaslimit\n if (gl == null || String(gl).trim() === '') return undefined\n const n = p.txNonce ?? p.txnonce\n let nonce = 0\n if (typeof n === 'bigint') nonce = Number(n)\n else if (typeof n === 'number') nonce = n\n else if (n != null) nonce = parseInt(String(n), 10)\n if (!Number.isFinite(nonce)) nonce = 0\n const gasLimit = String(gl)\n if (legacy) {\n const gp = p.txGasPrice ?? p.txgasprice\n return {\n nonce,\n gasLimit,\n txType: 'legacy',\n gasPrice: gp != null ? String(gp) : '0',\n }\n }\n return {\n nonce,\n gasLimit,\n txType: 'eip1559',\n maxFeePerGas: String(p.txMaxFeePerGas ?? ''),\n maxPriorityFeePerGas: String(p.txMaxPriorityFeePerGas ?? ''),\n }\n}\n\nexport function triggerTxParamsFromComposeBody(body: Record<string, unknown>): ProposalTxParams {\n const existing = body.txParams\n if (existing && typeof existing === 'object' && !Array.isArray(existing)) {\n const o = existing as ProposalTxParams & { gasLimit?: string }\n if (String(o.gasLimit ?? '').trim() !== '') {\n return { ...o }\n }\n }\n const pb = body.proposalTxParams\n if (Array.isArray(pb) && pb.length > 0 && typeof pb[0] === 'object' && pb[0] !== null) {\n const first = pb[0] as ProposalTxParams & { gasLimit?: string }\n if (String(first.gasLimit ?? '').trim() !== '') {\n return { ...first }\n }\n }\n const fromSnapshot = composeFeePayloadToTxParams(\n body,\n body.txMaxFeePerGas == null && body.txMaxPriorityFeePerGas == null,\n )\n if (fromSnapshot) return fromSnapshot\n return {\n nonce: 0,\n gasLimit: '',\n txType: 'legacy',\n gasPrice: '0',\n }\n}\n\nexport function proposalTxParamsToFeeSnapshot(\n params: ProposalTxParams,\n): Record<string, unknown> {\n if (params.txType === 'legacy') {\n return {\n txNonce: params.nonce,\n txGasLimit: params.gasLimit,\n txGasPrice: params.gasPrice ?? '0',\n }\n }\n return {\n txNonce: params.nonce,\n txGasLimit: params.gasLimit,\n txMaxFeePerGas: params.maxFeePerGas ?? '',\n txMaxPriorityFeePerGas: params.maxPriorityFeePerGas ?? '',\n }\n}\n","import { createPublicClient, http, defineChain, formatUnits } from 'viem'\n\nexport interface ChainFeeParams {\n isEip1559: boolean\n baseFeeGwei?: number\n priorityFeeGwei?: number\n gasPriceGwei?: number\n}\n\nexport async function fetchChainFeeParams(\n rpcUrl: string,\n chainId: number | string,\n): Promise<ChainFeeParams> {\n const url = rpcUrl.trim()\n if (!url) return { isEip1559: false }\n\n const chainIdNum = typeof chainId === 'string' ? parseInt(chainId, 10) : chainId\n if (Number.isNaN(chainIdNum)) return { isEip1559: false }\n\n const chain = defineChain({\n id: chainIdNum,\n name: 'Discovery',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [url] } },\n })\n\n const publicClient = createPublicClient({\n chain,\n transport: http(url),\n })\n\n const getGasPriceGwei = async (): Promise<number> => {\n const gasPriceWei = await publicClient.getGasPrice()\n return parseFloat(formatUnits(gasPriceWei, 9))\n }\n\n try {\n const block = await publicClient.getBlock({ blockTag: 'latest' })\n const baseFeePerGas = block?.baseFeePerGas\n if (baseFeePerGas == null || baseFeePerGas === undefined) {\n const gasPriceGwei = await getGasPriceGwei()\n return { isEip1559: false, gasPriceGwei }\n }\n\n const baseFeeGwei = parseFloat(formatUnits(baseFeePerGas, 9))\n\n let priorityFeeGwei: number | undefined\n try {\n const priorityWei = await publicClient.estimateMaxPriorityFeePerGas()\n priorityFeeGwei = parseFloat(formatUnits(priorityWei, 9))\n } catch {\n /* chain may not support eth_maxPriorityFeePerGas */\n }\n\n const gasPriceGwei = await getGasPriceGwei()\n return {\n isEip1559: true,\n baseFeeGwei,\n priorityFeeGwei,\n gasPriceGwei,\n }\n } catch {\n try {\n const gasPriceWei = await publicClient.getGasPrice()\n const gasPriceGwei = parseFloat(formatUnits(gasPriceWei, 9))\n return { isEip1559: false, gasPriceGwei }\n } catch {\n return { isEip1559: false }\n }\n }\n}\n","import { parseGwei } from 'viem'\n\nexport type ResolvedEip1559Fees = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction finalizeEip1559Fees(\n maxFeePerGas: bigint,\n maxPriorityFeePerGas: bigint,\n floor: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint } | null | undefined,\n baseWei: bigint,\n): ResolvedEip1559Fees {\n let maxP = maxPriorityFeePerGas\n let maxF = maxFeePerGas\n if (floor) {\n if (maxP < floor.maxPriorityFeePerGas) maxP = floor.maxPriorityFeePerGas\n if (maxF < floor.maxFeePerGas) maxF = floor.maxFeePerGas\n }\n if (baseWei > 0n && maxF < baseWei + maxP) {\n maxF = baseWei + maxP + parseGwei('0.001')\n }\n if (maxF < maxP) {\n maxF = baseWei > 0n ? baseWei + maxP + parseGwei('0.001') : maxP * 2n\n }\n return { maxFeePerGas: maxF, maxPriorityFeePerGas: maxP }\n}\n\n/** Align EIP-1559 fees with the latest head base fee (same rules as Get Sig). */\nexport function alignEip1559FeesWithLatestBase(\n maxFeePerGas: bigint,\n maxPriorityFeePerGas: bigint,\n latestBlockBaseFeeWei: bigint,\n): ResolvedEip1559Fees {\n return finalizeEip1559Fees(maxFeePerGas, maxPriorityFeePerGas, null, latestBlockBaseFeeWei)\n}\n\nexport function gweiToDecimalString(n: number): string {\n if (!Number.isFinite(n)) return '0'\n if (n === 0) return '0'\n const s = String(n)\n if (s.indexOf('e') !== -1 || s.indexOf('E') !== -1) return n.toFixed(9).replace(/\\.?0+$/, '') || '0'\n return s\n}\n","/**\n * Maple Syrup: stake underlying into PoolV2 via `SyrupRouter.deposit`, exit with `PoolV2.requestRedeem`.\n * Chains: Ethereum mainnet and Sepolia (router + pool addresses from Maple GraphQL).\n */\nimport {\n type Address,\n createPublicClient,\n defineChain,\n encodeFunctionData,\n getAddress,\n http,\n keccak256,\n parseAbi,\n parseGwei,\n parseUnits,\n serializeTransaction,\n stringToBytes,\n toHex,\n} from 'viem'\nimport { firstClientIdFromKeyGen, type KeyGenSubsetForPermit } from '../../../core/keygen.js'\nimport { gasLimitFromEstimateAndChainConfig, type ProposalTxParams } from '../../../chains/evm/txParams.js'\nimport { fetchChainFeeParams } from '../../../chains/evm/fees/chainFees.js'\nimport { alignEip1559FeesWithLatestBase } from '../../../chains/evm/fees/eip1559Align.js'\nimport { MAPLE_SYRUP_DEPOSIT_DATA_ASCII } from './constants.js'\n\nconst AAVE_ERC20_APPROVE_FALLBACK = 100_000n\nexport const MAPLE_SYRUP_DEPOSIT_GAS_FALLBACK = 1_500_000n\nconst MAPLE_SYRUP_DEPOSIT_FALLBACK = MAPLE_SYRUP_DEPOSIT_GAS_FALLBACK\nconst MAPLE_REQUEST_REDEEM_FALLBACK = 1_200_000n\n\nconst erc20AllowanceAbi = parseAbi([\n 'function allowance(address owner, address spender) view returns (uint256)',\n 'function decimals() view returns (uint8)',\n])\nconst erc20ApproveAbi = parseAbi(['function approve(address spender, uint256 amount) returns (bool)'])\n\nconst syrupRouterAbi = parseAbi([\n 'function deposit(uint256 assets, bytes32 depositData)',\n 'function authorizeAndDeposit(uint256 bitmap,uint256 deadline,uint8 auth_v,bytes32 auth_r,bytes32 auth_s,uint256 amount,bytes32 depositData)',\n])\n\nconst poolV2ExitAbi = parseAbi([\n 'function previewDeposit(uint256 assets) view returns (uint256 shares)',\n 'function convertToExitShares(uint256 assets_) view returns (uint256 shares_)',\n 'function requestRedeem(uint256 shares, address receiver) returns (uint256)',\n 'function decimals() view returns (uint8)',\n])\n\nfunction gweiToDecimalString(n: number): string {\n if (!Number.isFinite(n)) return '0'\n if (n === 0) return '0'\n const s = String(n)\n if (s.indexOf('e') !== -1 || s.indexOf('E') !== -1) return n.toFixed(9).replace(/\\.?0+$/, '') || '0'\n return s\n}\n\nfunction formatBytes32DataLabel(s: string): `0x${string}` {\n const b = stringToBytes(s)\n if (b.length > 32) throw new Error('Maple depositData label is too long for bytes32.')\n const padded = new Uint8Array(32)\n padded.set(b)\n return toHex(padded)\n}\n\ntype ChainRow = {\n legacy?: boolean\n gasLimit?: number\n gasMultiplier?: number\n gasPrice?: number\n baseFee?: number\n priorityFee?: number\n baseFeeMultiplier?: number\n}\n\nfunction publicClientForChain(chainId: number, rpcUrl: string) {\n const rpc = rpcUrl.trim()\n if (chainId === 1) {\n const ch = defineChain({\n id: 1,\n name: 'Ethereum',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [rpc] } },\n })\n return createPublicClient({ chain: ch, transport: http(rpc) })\n }\n if (chainId === 11155111) {\n const ch = defineChain({\n id: 11155111,\n name: 'Sepolia',\n nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },\n rpcUrls: { default: { http: [rpc] } },\n })\n return createPublicClient({ chain: ch, transport: http(rpc) })\n }\n throw new Error(`Maple Syrup multisign: unsupported chain id ${chainId}.`)\n}\n\nexport async function readMaplePoolShareDecimals(args: { rpcUrl: string; chainId: number; pool: Address }): Promise<number> {\n const client = publicClientForChain(args.chainId, args.rpcUrl)\n const d = await client.readContract({\n address: getAddress(args.pool),\n abi: poolV2ExitAbi,\n functionName: 'decimals',\n })\n return Number(d)\n}\n\nexport async function readMapleStakePreviewShares(args: {\n rpcUrl: string\n chainId: number\n pool: Address\n assetAmountWei: bigint\n}): Promise<bigint> {\n if (args.assetAmountWei <= 0n) return 0n\n const client = publicClientForChain(args.chainId, args.rpcUrl)\n return client.readContract({\n address: getAddress(args.pool),\n abi: poolV2ExitAbi,\n functionName: 'previewDeposit',\n args: [args.assetAmountWei],\n })\n}\n\nexport async function readMapleUnstakeExitSharesForAssets(args: {\n rpcUrl: string\n chainId: number\n pool: Address\n assetAmountWei: bigint\n}): Promise<bigint> {\n if (args.assetAmountWei <= 0n) return 0n\n const client = publicClientForChain(args.chainId, args.rpcUrl)\n return client.readContract({\n address: getAddress(args.pool),\n abi: poolV2ExitAbi,\n functionName: 'convertToExitShares',\n args: [args.assetAmountWei],\n })\n}\n\ntype MapleStakeStep = { kind: 'approve' | 'deposit' | 'authorizeAndDeposit'; to: Address; data: `0x${string}`; value: bigint }\n\n/** ECDSA v/r/s + bitmap + deadline from Maple for `SyrupRouter.authorizeAndDeposit`. */\nexport type MapleSyrupAuthorizeSig = {\n bitmap: bigint\n deadline: bigint\n v: number\n r: `0x${string}`\n s: `0x${string}`\n}\n\n/** Parse UI fields for first-time Syrup deposit (`authorizeAndDeposit`). */\nexport function parseMapleStakeAuthInputs(args: {\n bitmap: string\n deadline: string\n v: string\n r: string\n s: string\n}): { ok: true; sig: MapleSyrupAuthorizeSig } | { ok: false; message: string } {\n const bitmapT = args.bitmap.trim()\n let bitmap: bigint\n if (!bitmapT) return { ok: false, message: 'Enter authorization bitmap (uint256).' }\n try {\n bitmap = bitmapT.startsWith('0x') || bitmapT.startsWith('0X') ? BigInt(bitmapT) : BigInt(bitmapT)\n } catch {\n return { ok: false, message: 'Bitmap must be a decimal or 0x-prefixed integer.' }\n }\n const deadlineT = args.deadline.trim()\n if (!deadlineT || !/^\\d+$/.test(deadlineT)) {\n return { ok: false, message: 'Deadline must be a Unix timestamp (seconds), decimal digits only.' }\n }\n const deadline = BigInt(deadlineT)\n if (deadline <= 0n) return { ok: false, message: 'Deadline must be positive.' }\n const vT = args.v.trim()\n if (!/^\\d+$/.test(vT)) return { ok: false, message: 'v must be an integer 0–255 (often 27 or 28).' }\n const v = Number(vT)\n if (!Number.isFinite(v) || v < 0 || v > 255) return { ok: false, message: 'v must be between 0 and 255.' }\n let r = args.r.trim()\n let s = args.s.trim()\n if (!r.startsWith('0x')) r = '0x' + r\n if (!s.startsWith('0x')) s = '0x' + s\n if (!/^0x[0-9a-fA-F]{64}$/.test(r)) return { ok: false, message: 'r must be 32 bytes (64 hex chars), optional 0x.' }\n if (!/^0x[0-9a-fA-F]{64}$/.test(s)) return { ok: false, message: 's must be 32 bytes (64 hex chars), optional 0x.' }\n return { ok: true, sig: { bitmap, deadline, v, r: r as `0x${string}`, s: s as `0x${string}` } }\n}\n\nexport async function buildEvmMultisignBodyMapleSyrupDeposit(args: {\n keyGen: KeyGenSubsetForPermit\n chainId: number\n rpcUrl: string\n chainDetail: ChainRow\n useCustomGas: boolean\n customGasChainDetails?: Record<string, unknown> | null\n /** Underlying USDC / USDT (must match the pool’s asset). */\n asset: Address\n syrupRouter: Address\n pool: Address\n amountHuman: string\n assetDecimals: number\n executorAddress: Address\n purposeText: string\n /** Default `deposit`. Use `authorizeAndDeposit` with Maple-issued {@link authorizeSig} for first-time lenders. */\n stakeMethod?: 'deposit' | 'authorizeAndDeposit'\n authorizeSig?: MapleSyrupAuthorizeSig\n}): Promise<{ bodyForSign: Record<string, unknown>; messageToSign: string }> {\n if (args.chainId !== 1 && args.chainId !== 11155111) {\n throw new Error('Maple Syrup deposit is only supported on Ethereum mainnet or Sepolia.')\n }\n const ph = (args.keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n const keyList = args.keyGen.keylist ?? []\n const clientId = firstClientIdFromKeyGen(args.keyGen)\n const asset = getAddress(args.asset)\n const router = getAddress(args.syrupRouter)\n const pool = getAddress(args.pool)\n const executor = getAddress(args.executorAddress)\n const depositData = formatBytes32DataLabel(MAPLE_SYRUP_DEPOSIT_DATA_ASCII)\n\n const publicClient = publicClientForChain(args.chainId, args.rpcUrl)\n\n const dec = args.assetDecimals\n if (!Number.isFinite(dec) || dec < 0 || dec > 255) throw new Error('Invalid asset decimals.')\n const amountWei = parseUnits(args.amountHuman, dec)\n if (amountWei === 0n) throw new Error('Amount is zero after converting with token decimals.')\n\n const stakeMethod = args.stakeMethod ?? 'deposit'\n if (stakeMethod === 'authorizeAndDeposit') {\n const a = args.authorizeSig\n if (!a) throw new Error('authorizeSig is required for authorizeAndDeposit.')\n if (a.v < 0 || a.v > 255) throw new Error('Invalid authorization v (must be 0–255).')\n }\n\n const steps: MapleStakeStep[] = []\n const currentAllowance = await publicClient.readContract({\n address: asset,\n abi: erc20AllowanceAbi,\n functionName: 'allowance',\n args: [executor, router],\n })\n if (currentAllowance < amountWei) {\n if (currentAllowance > 0n) {\n const dataReset = encodeFunctionData({\n abi: erc20ApproveAbi,\n functionName: 'approve',\n args: [router, 0n],\n })\n steps.push({ kind: 'approve', to: asset, data: dataReset, value: 0n })\n }\n const dataApprove = encodeFunctionData({\n abi: erc20ApproveAbi,\n functionName: 'approve',\n args: [router, amountWei],\n })\n steps.push({ kind: 'approve', to: asset, data: dataApprove, value: 0n })\n }\n\n if (stakeMethod === 'authorizeAndDeposit') {\n const a = args.authorizeSig!\n const authCalldata = encodeFunctionData({\n abi: syrupRouterAbi,\n functionName: 'authorizeAndDeposit',\n args: [a.bitmap, a.deadline, a.v, a.r, a.s, amountWei, depositData],\n })\n steps.push({ kind: 'authorizeAndDeposit', to: router, data: authCalldata, value: 0n })\n } else {\n const depositCalldata = encodeFunctionData({\n abi: syrupRouterAbi,\n functionName: 'deposit',\n args: [amountWei, depositData],\n })\n steps.push({ kind: 'deposit', to: router, data: depositCalldata, value: 0n })\n }\n\n const feeParams = await fetchChainFeeParams(args.rpcUrl, args.chainId)\n const legacy = Boolean(args.chainDetail?.legacy) || !feeParams.isEip1559\n const latestBaseFeeWei =\n !legacy ? (await publicClient.getBlock({ blockTag: 'latest' })).baseFeePerGas ?? 0n : 0n\n const useCustomGas = args.useCustomGas\n const gasLimitConfig =\n useCustomGas && args.chainDetail?.gasLimit != null ? Number(args.chainDetail.gasLimit) : undefined\n const gasFeeMultiplier =\n useCustomGas && args.chainDetail?.gasMultiplier != null ? Number(args.chainDetail.gasMultiplier) : undefined\n\n const baseNonce = await publicClient.getTransactionCount({ address: executor, blockTag: 'pending' })\n const messageHashes: string[] = []\n const messageRawBatch: string[] = []\n const proposalTxParamsBatch: ProposalTxParams[] = []\n const batchMeta: Record<string, unknown>[] = []\n let firstTxFeePayload: Record<string, unknown> = {}\n let firstDataNo0x = ''\n\n for (let i = 0; i < steps.length; i++) {\n const s = steps[i]!\n const currentNonce = baseNonce + i\n let estimatedGas: bigint\n const skipFinalStakeEstimateBecausePriorApproves =\n (s.kind === 'deposit' || s.kind === 'authorizeAndDeposit') && i > 0\n if (skipFinalStakeEstimateBecausePriorApproves) {\n estimatedGas = MAPLE_SYRUP_DEPOSIT_FALLBACK\n } else {\n try {\n estimatedGas = await publicClient.estimateGas({\n to: s.to,\n data: s.data,\n value: s.value,\n account: executor,\n })\n } catch (e) {\n if (s.kind === 'deposit' || s.kind === 'authorizeAndDeposit') {\n const msg = e instanceof Error ? e.message : String(e)\n if (/NOT_AUTHORIZED|SR:D:NOT_AUTHORIZED/i.test(msg)) {\n throw new Error(\n stakeMethod === 'authorizeAndDeposit'\n ? 'Maple SyrupRouter rejected authorizeAndDeposit (SR:D:NOT_AUTHORIZED). Check the authorization signature, deadline, and bitmap from Maple; they must match this chain, router, and owner.'\n : 'Maple SyrupRouter rejected deposit (SR:D:NOT_AUTHORIZED): this executor is not allowlisted as a Syrup lender on-chain. ' +\n 'Use authorizeAndDeposit with a Maple-issued signature for the first deposit, or ask Maple to allowlist this address.',\n )\n }\n }\n estimatedGas = s.kind === 'approve' ? AAVE_ERC20_APPROVE_FALLBACK : MAPLE_SYRUP_DEPOSIT_FALLBACK\n }\n }\n const gasLimitI = useCustomGas\n ? gasLimitFromEstimateAndChainConfig(estimatedGas, gasLimitConfig)\n : estimatedGas\n\n if (legacy) {\n let gasPriceWei = await publicClient.getGasPrice()\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n gasPriceWei = (gasPriceWei * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n if (useCustomGas && args.chainDetail?.gasPrice != null && args.chainDetail.gasPrice > 0) {\n const configured = parseGwei(gweiToDecimalString(Number(args.chainDetail.gasPrice)))\n if (configured > gasPriceWei) gasPriceWei = configured\n }\n const ser = serializeTransaction({\n type: 'legacy',\n to: s.to,\n data: s.data,\n value: s.value,\n gas: gasLimitI,\n gasPrice: gasPriceWei,\n nonce: currentNonce,\n chainId: args.chainId,\n })\n const h = keccak256(ser)\n messageHashes.push(h.startsWith('0x') ? h.slice(2) : h)\n messageRawBatch.push(ser)\n proposalTxParamsBatch.push({\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'legacy',\n gasPrice: gasPriceWei.toString(),\n })\n if (i === 0) {\n firstTxFeePayload = { txNonce: currentNonce, txGasLimit: gasLimitI.toString(), txGasPrice: gasPriceWei.toString() }\n firstDataNo0x = s.data.startsWith('0x') ? s.data.slice(2) : s.data\n }\n } else {\n const fetchedBase = feeParams.baseFeeGwei ?? 0\n const fetchedPriority = feeParams.priorityFeeGwei ?? 0\n const configuredBase =\n useCustomGas && args.chainDetail?.baseFee != null ? Number(args.chainDetail.baseFee) : 0\n const configuredPriority =\n useCustomGas && args.chainDetail?.priorityFee != null ? Number(args.chainDetail.priorityFee) : 0\n const effectiveBaseFeeGwei = Math.max(fetchedBase, configuredBase)\n const effectivePriorityFeeGwei = Math.max(fetchedPriority, configuredPriority)\n const baseFeeMultiplierPct =\n useCustomGas && args.chainDetail?.baseFeeMultiplier != null\n ? Math.max(100, Number(args.chainDetail.baseFeeMultiplier))\n : 100\n const baseComponentGwei = (effectiveBaseFeeGwei * baseFeeMultiplierPct) / 100\n const maxFeePerGasGwei = baseComponentGwei + effectivePriorityFeeGwei\n let maxPriorityFeePerGas =\n effectivePriorityFeeGwei > 0 ? parseGwei(gweiToDecimalString(effectivePriorityFeeGwei)) : parseGwei('1')\n let maxFeePerGas = parseGwei(gweiToDecimalString(maxFeePerGasGwei))\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n maxPriorityFeePerGas = (maxPriorityFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n maxFeePerGas = (maxFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n ;({ maxFeePerGas, maxPriorityFeePerGas } = alignEip1559FeesWithLatestBase(\n maxFeePerGas,\n maxPriorityFeePerGas,\n latestBaseFeeWei,\n ))\n const ser = serializeTransaction({\n type: 'eip1559',\n to: s.to,\n data: s.data,\n value: s.value,\n gas: gasLimitI,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce: currentNonce,\n chainId: args.chainId,\n })\n const h = keccak256(ser)\n messageHashes.push(h.startsWith('0x') ? h.slice(2) : h)\n messageRawBatch.push(ser)\n proposalTxParamsBatch.push({\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'eip1559',\n maxFeePerGas: maxFeePerGas.toString(),\n maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n })\n if (i === 0) {\n firstTxFeePayload = {\n txNonce: currentNonce,\n txGasLimit: gasLimitI.toString(),\n txMaxFeePerGas: maxFeePerGas.toString(),\n txMaxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n }\n firstDataNo0x = s.data.startsWith('0x') ? s.data.slice(2) : s.data\n }\n }\n\n const chainIdStr = String(args.chainId)\n if (s.kind === 'approve') {\n batchMeta.push({\n destinationAddress: asset,\n signatureText: JSON.stringify({\n kind: 'MapleSyrup',\n name: 'ERC20.approve',\n note: 'Allow SyrupRouter to pull this deposit amount.',\n spender: router,\n asset,\n pool,\n amountHuman: args.amountHuman,\n }),\n evm: { type: 'maple_syrup_erc20_approve', version: 1, chainId: chainIdStr },\n maple: { step: 'approve_asset', router, pool, asset },\n })\n } else if (s.kind === 'deposit') {\n batchMeta.push({\n destinationAddress: router,\n signatureText: JSON.stringify({\n kind: 'MapleSyrup',\n name: 'SyrupRouter.deposit',\n function: 'deposit(uint256 assets, bytes32 depositData)',\n assets: amountWei.toString(),\n pool,\n router,\n amountHuman: args.amountHuman,\n }),\n evm: { type: 'maple_syrup_router_deposit', version: 1, chainId: chainIdStr },\n maple: { step: 'deposit', router, pool, gasBuildDeposit: { baseGasUnits: gasLimitI.toString() } },\n })\n } else {\n const a = args.authorizeSig!\n batchMeta.push({\n destinationAddress: router,\n signatureText: JSON.stringify({\n kind: 'MapleSyrup',\n name: 'SyrupRouter.authorizeAndDeposit',\n function:\n 'authorizeAndDeposit(uint256 bitmap,uint256 deadline,uint8 auth_v,bytes32 auth_r,bytes32 auth_s,uint256 amount,bytes32 depositData)',\n bitmap: a.bitmap.toString(),\n deadline: a.deadline.toString(),\n auth_v: a.v,\n assets: amountWei.toString(),\n pool,\n router,\n amountHuman: args.amountHuman,\n }),\n evm: { type: 'maple_syrup_router_authorize_and_deposit', version: 1, chainId: chainIdStr },\n maple: { step: 'authorize_and_deposit', router, pool, gasBuildDeposit: { baseGasUnits: gasLimitI.toString() } },\n })\n }\n }\n\n const extraPayload: Record<string, unknown> = { batchMeta }\n if (useCustomGas && args.customGasChainDetails && Object.keys(args.customGasChainDetails).length > 0) {\n extraPayload.customGasChainDetails = args.customGasChainDetails\n }\n const extraJSON = JSON.stringify(extraPayload)\n const firstSigText = (batchMeta[0] as { signatureText: string }).signatureText\n const n = steps.length\n const finalVerb =\n stakeMethod === 'authorizeAndDeposit' ? 'authorizeAndDeposit (permission + deposit)' : 'deposit'\n const purposeSuffix =\n n === 1\n ? `Maple Syrup: 1-tx — ${finalVerb} via SyrupRouter (allowance already set).`\n : `Maple Syrup: ${n}-tx batch — approve asset for SyrupRouter, then ${finalVerb}.`\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: firstDataNo0x,\n messageHashes,\n messageRawBatch,\n destinationChainID: String(args.chainId),\n destinationAddress: steps[0]!.to,\n extraJSON,\n signatureText: firstSigText,\n purpose: (() => {\n const t = args.purposeText.trim()\n return (t ? `${t}\\n\\n` : '') + purposeSuffix\n })(),\n ...firstTxFeePayload,\n proposalTxParams: proposalTxParamsBatch,\n }\n if (clientId) bodyForSign.clientId = clientId\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport async function buildEvmMultisignBodyMaplePoolRequestRedeem(args: {\n keyGen: KeyGenSubsetForPermit\n chainId: number\n rpcUrl: string\n chainDetail: ChainRow\n useCustomGas: boolean\n customGasChainDetails?: Record<string, unknown> | null\n pool: Address\n /** Human amount in **underlying** units (e.g. USDC). */\n underlyingAmountHuman: string\n underlyingDecimals: number\n executorAddress: Address\n purposeText: string\n}): Promise<{ bodyForSign: Record<string, unknown>; messageToSign: string }> {\n if (args.chainId !== 1 && args.chainId !== 11155111) {\n throw new Error('Maple Syrup redeem request is only supported on Ethereum mainnet or Sepolia.')\n }\n const ph = (args.keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n const keyList = args.keyGen.keylist ?? []\n const clientId = firstClientIdFromKeyGen(args.keyGen)\n const pool = getAddress(args.pool)\n const executor = getAddress(args.executorAddress)\n const receiver = executor\n\n const ud = args.underlyingDecimals\n if (!Number.isFinite(ud) || ud < 0 || ud > 255) throw new Error('Invalid underlying decimals.')\n const assetWei = parseUnits(args.underlyingAmountHuman, ud)\n if (assetWei === 0n) throw new Error('Amount is zero after converting with token decimals.')\n\n const publicClient = publicClientForChain(args.chainId, args.rpcUrl)\n const exitShares = await publicClient.readContract({\n address: pool,\n abi: poolV2ExitAbi,\n functionName: 'convertToExitShares',\n args: [assetWei],\n })\n if (exitShares === 0n) throw new Error('Exit shares are zero for this amount; check pool liquidity and amount.')\n\n const data = encodeFunctionData({\n abi: poolV2ExitAbi,\n functionName: 'requestRedeem',\n args: [exitShares, receiver],\n })\n\n const feeParams = await fetchChainFeeParams(args.rpcUrl, args.chainId)\n const legacy = Boolean(args.chainDetail?.legacy) || !feeParams.isEip1559\n const latestBaseFeeWei =\n !legacy ? (await publicClient.getBlock({ blockTag: 'latest' })).baseFeePerGas ?? 0n : 0n\n const useCustomGas = args.useCustomGas\n const gasLimitConfig =\n useCustomGas && args.chainDetail?.gasLimit != null ? Number(args.chainDetail.gasLimit) : undefined\n const gasFeeMultiplier =\n useCustomGas && args.chainDetail?.gasMultiplier != null ? Number(args.chainDetail.gasMultiplier) : undefined\n\n const currentNonce = await publicClient.getTransactionCount({ address: executor, blockTag: 'pending' })\n let estimatedGas: bigint\n try {\n estimatedGas = await publicClient.estimateGas({\n to: pool,\n data,\n value: 0n,\n account: executor,\n })\n } catch {\n estimatedGas = MAPLE_REQUEST_REDEEM_FALLBACK\n }\n const gasLimitI = useCustomGas ? gasLimitFromEstimateAndChainConfig(estimatedGas, gasLimitConfig) : estimatedGas\n\n const chainIdStr = String(args.chainId)\n let firstTxFeePayload: Record<string, unknown> = {}\n let ser: `0x${string}`\n let proposalTxParams0: ProposalTxParams\n\n if (legacy) {\n let gasPriceWei = await publicClient.getGasPrice()\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n gasPriceWei = (gasPriceWei * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n if (useCustomGas && args.chainDetail?.gasPrice != null && args.chainDetail.gasPrice > 0) {\n const configured = parseGwei(gweiToDecimalString(Number(args.chainDetail.gasPrice)))\n if (configured > gasPriceWei) gasPriceWei = configured\n }\n ser = serializeTransaction({\n type: 'legacy',\n to: pool,\n data,\n value: 0n,\n gas: gasLimitI,\n gasPrice: gasPriceWei,\n nonce: currentNonce,\n chainId: args.chainId,\n })\n firstTxFeePayload = {\n txNonce: currentNonce,\n txGasLimit: gasLimitI.toString(),\n txGasPrice: gasPriceWei.toString(),\n }\n proposalTxParams0 = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'legacy',\n gasPrice: gasPriceWei.toString(),\n }\n } else {\n const fetchedBase = feeParams.baseFeeGwei ?? 0\n const fetchedPriority = feeParams.priorityFeeGwei ?? 0\n const configuredBase =\n useCustomGas && args.chainDetail?.baseFee != null ? Number(args.chainDetail.baseFee) : 0\n const configuredPriority =\n useCustomGas && args.chainDetail?.priorityFee != null ? Number(args.chainDetail.priorityFee) : 0\n const effectiveBaseFeeGwei = Math.max(fetchedBase, configuredBase)\n const effectivePriorityFeeGwei = Math.max(fetchedPriority, configuredPriority)\n const baseFeeMultiplierPct =\n useCustomGas && args.chainDetail?.baseFeeMultiplier != null\n ? Math.max(100, Number(args.chainDetail.baseFeeMultiplier))\n : 100\n const baseComponentGwei = (effectiveBaseFeeGwei * baseFeeMultiplierPct) / 100\n const maxFeePerGasGwei = baseComponentGwei + effectivePriorityFeeGwei\n let maxPriorityFeePerGas =\n effectivePriorityFeeGwei > 0 ? parseGwei(gweiToDecimalString(effectivePriorityFeeGwei)) : parseGwei('1')\n let maxFeePerGas = parseGwei(gweiToDecimalString(maxFeePerGasGwei))\n if (useCustomGas && gasFeeMultiplier != null && gasFeeMultiplier > 0) {\n maxPriorityFeePerGas = (maxPriorityFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n maxFeePerGas = (maxFeePerGas * BigInt(100 + gasFeeMultiplier)) / 100n\n }\n ;({ maxFeePerGas, maxPriorityFeePerGas } = alignEip1559FeesWithLatestBase(\n maxFeePerGas,\n maxPriorityFeePerGas,\n latestBaseFeeWei,\n ))\n ser = serializeTransaction({\n type: 'eip1559',\n to: pool,\n data,\n value: 0n,\n gas: gasLimitI,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce: currentNonce,\n chainId: args.chainId,\n })\n firstTxFeePayload = {\n txNonce: currentNonce,\n txGasLimit: gasLimitI.toString(),\n txMaxFeePerGas: maxFeePerGas.toString(),\n txMaxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n }\n proposalTxParams0 = {\n nonce: currentNonce,\n gasLimit: gasLimitI.toString(),\n txType: 'eip1559',\n maxFeePerGas: maxFeePerGas.toString(),\n maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),\n }\n }\n\n const h = keccak256(ser)\n const messageHashes = [h.startsWith('0x') ? h.slice(2) : h]\n const messageRawBatch = [ser]\n const proposalTxParamsBatch: ProposalTxParams[] = [proposalTxParams0]\n\n const firstDataNo0x = data.startsWith('0x') ? data.slice(2) : data\n const batchMeta: Record<string, unknown>[] = [\n {\n destinationAddress: pool,\n signatureText: JSON.stringify({\n kind: 'MapleSyrup',\n name: 'PoolV2.requestRedeem',\n function: 'requestRedeem(uint256 shares, address receiver)',\n shares: exitShares.toString(),\n underlyingAmountHuman: args.underlyingAmountHuman,\n receiver,\n pool,\n }),\n evm: { type: 'maple_pool_v2_request_redeem', version: 1, chainId: chainIdStr },\n maple: { step: 'request_redeem', pool, gasBuildRedeem: { baseGasUnits: gasLimitI.toString() } },\n },\n ]\n\n const extraPayload: Record<string, unknown> = { batchMeta }\n if (useCustomGas && args.customGasChainDetails && Object.keys(args.customGasChainDetails).length > 0) {\n extraPayload.customGasChainDetails = args.customGasChainDetails\n }\n const extraJSON = JSON.stringify(extraPayload)\n const purposeSuffix = 'Maple Syrup: 1-tx — request redeem (queue withdrawal of underlying from pool shares).'\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: firstDataNo0x,\n messageHashes,\n messageRawBatch,\n destinationChainID: String(args.chainId),\n destinationAddress: pool,\n extraJSON,\n signatureText: batchMeta[0]!.signatureText as string,\n purpose: (() => {\n const t = args.purposeText.trim()\n return (t ? `${t}\\n\\n` : '') + purposeSuffix\n })(),\n ...firstTxFeePayload,\n proposalTxParams: proposalTxParamsBatch,\n }\n if (clientId) bodyForSign.clientId = clientId\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n","import type { ProtocolModule } from '../../../core/types.js'\nimport { registerProtocolModule } from '../../../core/registry.js'\nimport { isMapleSyrupSupportedChain } from './constants.js'\n\nexport * from './constants.js'\nexport * from './multisign.js'\n\nexport const MAPLE_PROTOCOL_ID = 'maple-syrup'\n\nexport const mapleProtocolModule: ProtocolModule = {\n id: MAPLE_PROTOCOL_ID,\n chainCategory: 'evm',\n isChainSupported(ctx) {\n if (ctx.chainCategory !== 'evm') return false\n const n = typeof ctx.chainId === 'number' ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10)\n return isMapleSyrupSupportedChain(n)\n },\n isTokenSupported(token) {\n return token.category === 'evm' && token.kind === 'erc20'\n },\n actions: [\n { id: 'maple-syrup.deposit', protocolId: MAPLE_PROTOCOL_ID, chainCategory: 'evm', description: 'Deposit into Maple Syrup pool', commonParams: ['keyGen', 'purposeText', 'useCustomGas'], params: {} },\n { id: 'maple-syrup.request-redeem', protocolId: MAPLE_PROTOCOL_ID, chainCategory: 'evm', description: 'Request redeem from pool', commonParams: ['keyGen', 'purposeText', 'useCustomGas'], params: {} },\n ],\n}\n\nregisterProtocolModule(mapleProtocolModule)\n"]}
|