-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathschemas.ts
More file actions
65 lines (60 loc) · 2.77 KB
/
Copy pathschemas.ts
File metadata and controls
65 lines (60 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { z } from "zod";
import { SUPPORTED_CHAINS } from "../../types/index.js";
import { approvalCapSchema } from "../shared/approval.js";
const chainEnum = z.enum(SUPPORTED_CHAINS as unknown as [string, ...string[]]);
const walletSchema = z
.string()
.regex(/^0x[a-fA-F0-9]{40}$/)
.describe("0x-prefixed EVM wallet address (40 hex chars) that will execute this action.");
const marketIdSchema = z
.string()
.regex(/^0x[a-fA-F0-9]{64}$/)
.describe(
"Morpho Blue market id — 32-byte hex (0x + 64 hex chars). Identifies the market's (loanToken, collateralToken, oracle, irm, lltv) tuple. Discover via get_morpho_positions."
);
export const getMorphoPositionsInput = z.object({
wallet: walletSchema,
chain: chainEnum
.default("ethereum")
.describe("EVM chain Morpho Blue is deployed on. Currently only ethereum is enabled."),
marketIds: z
.array(marketIdSchema)
.optional()
.describe(
"Morpho Blue market ids (bytes32 each) to check. If omitted, the server auto-discovers the wallet's markets by scanning Morpho Blue event logs (Supply / Borrow / SupplyCollateral with onBehalf == wallet). Pass explicitly as a fast path — cold discovery walks from Morpho's deploy block to head in ~10k-block chunks and can take several seconds."
),
});
const baseMarketAction = z.object({
wallet: walletSchema,
chain: chainEnum
.default("ethereum")
.describe("EVM chain Morpho Blue is deployed on. Currently only ethereum is enabled."),
marketId: marketIdSchema,
amount: z
.string()
.describe(
'Human-readable decimal amount, NOT raw wei/base units. ' +
'Example: "10" for 10 USDC. Pass "max" for full-balance withdraw/repay.'
),
});
export const prepareMorphoSupplyInput = baseMarketAction.extend({
approvalCap: approvalCapSchema,
});
export const prepareMorphoWithdrawInput = baseMarketAction;
export const prepareMorphoBorrowInput = baseMarketAction;
export const prepareMorphoRepayInput = baseMarketAction.extend({
approvalCap: approvalCapSchema,
});
export const prepareMorphoSupplyCollateralInput = baseMarketAction.extend({
approvalCap: approvalCapSchema,
});
export const prepareMorphoWithdrawCollateralInput = baseMarketAction;
export type GetMorphoPositionsArgs = z.infer<typeof getMorphoPositionsInput>;
export type PrepareMorphoSupplyArgs = z.infer<typeof prepareMorphoSupplyInput>;
export type PrepareMorphoWithdrawArgs = z.infer<typeof prepareMorphoWithdrawInput>;
export type PrepareMorphoBorrowArgs = z.infer<typeof prepareMorphoBorrowInput>;
export type PrepareMorphoRepayArgs = z.infer<typeof prepareMorphoRepayInput>;
export type PrepareMorphoSupplyCollateralArgs = z.infer<typeof prepareMorphoSupplyCollateralInput>;
export type PrepareMorphoWithdrawCollateralArgs = z.infer<
typeof prepareMorphoWithdrawCollateralInput
>;