-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathschemas.ts
More file actions
56 lines (51 loc) · 2.35 KB
/
Copy pathschemas.ts
File metadata and controls
56 lines (51 loc) · 2.35 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
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}$/);
const marketIdSchema = z.string().regex(/^0x[a-fA-F0-9]{64}$/);
export const getMorphoPositionsInput = z.object({
wallet: walletSchema,
chain: chainEnum.default("ethereum"),
/**
* Morpho Blue market IDs (bytes32 each) to check. If omitted, the server
* discovers the wallet's markets by scanning Morpho Blue event logs
* (Supply / Borrow / SupplyCollateral with `onBehalf == wallet`). Pass this
* explicitly as a fast path when the set of markets is already known —
* discovery on cold lookups walks from Morpho's deploy block to head in
* ~10k-block chunks and can take several seconds.
*/
marketIds: z.array(marketIdSchema).optional(),
});
const baseMarketAction = z.object({
wallet: walletSchema,
chain: chainEnum.default("ethereum"),
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
>;