Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .cursor/rules/cursor-rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description: Guidelines for creating and maintaining Cursor rules to ensure consistency and effectiveness.
globs: .cursor/rules/*.mdc
alwaysApply: true
---

- **Required Rule Structure:**
```markdown
---
description: Clear, one-line description of what the rule enforces
globs: path/to/files/*.ext, other/path/**/*
alwaysApply: boolean
---

- **Main Points in Bold**
- Sub-points with details
- Examples and explanations
```

- **File References:**
- Use `[filename](mdc:path/to/file)` ([filename](mdc:filename)) to reference files
- Example: [prisma.mdc](mdc:.cursor/rules/prisma.mdc) for rule references
- Example: [schema.prisma](mdc:prisma/schema.prisma) for code references

- **Code Examples:**
- Use language-specific code blocks
```typescript
// ✅ DO: Show good examples
const goodExample = true;

// ❌ DON'T: Show anti-patterns
const badExample = false;
```

- **Rule Content Guidelines:**
- Start with high-level overview
- Include specific, actionable requirements
- Show examples of correct implementation
- Reference existing code when possible
- Keep rules DRY by referencing other rules

- **Rule Maintenance:**
- Update rules when new patterns emerge
- Add examples from actual codebase
- Remove outdated patterns
- Cross-reference related rules

- **Best Practices:**
- Use bullet points for clarity
- Keep descriptions concise
- Include both DO and DON'T examples
- Reference actual code over theoretical examples
- Use consistent formatting across rules
37 changes: 37 additions & 0 deletions .cursor/rules/frontend-app.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
description: Match existing React/TypeScript and formatting style used in frontend/app
globs: frontend/app/**/*.{ts,tsx,js,jsx}
alwaysApply: true
---

- **General TypeScript / imports**
- Use TypeScript with explicit types on public APIs and utility functions where it adds clarity; allow inference for simple component return types.
- Prefer `export function Name()` for components and utilities; use `export default function` for Next.js `page.tsx`/`layout.tsx`.
- Use **named imports** grouped and ordered: framework/libs (`react`, `next/*`), then aliased app imports (`@/src/...`, `@/styled-system/...`), then relative imports (`./Something`).
- Use **double quotes** for imports and strings in TS/TSX, and **semicolons** consistently.
- Prefer narrow types: literal template types for addresses (e.g. `` `0x${string}` ``) and specific maps (`Record<number, AppChainConfig>`, `{ [symbol: string]: Vault }`).

- **React components**
- For client components, start with `"use client";` on the first line when hooks or browser APIs are used.
- Declare props inline for small components: `export function Comp({ x }: { x: string }) { ... }`; use separate interfaces/types only when props are reused or complex.
- Place hooks at the top of the component in a logical order: data/config hooks, then price/balance hooks, then modal/router hooks.
- Keep JSX **return blocks compact and declarative**: minimal logic in JSX; derive values above and pass them down as props.
- Use descriptive, PascalCase component and screen names (`VaultPoolScreen`, `AppLayout`, `MobileScreen`).

- **JSX & styling**
- Use `className={css({ ... })}` for styling with JS object syntax and camelCased CSS keys; keep style objects relatively flat and readable.
- When JSX props span multiple lines, format one prop per line and end the prop list with a trailing comma where allowed.
- Prefer semantic, readable JSX structure: outer layout wrapper(s), then main content, then panels/cards/sections; avoid deeply nested inline logic.
- For long JSX blocks (e.g. cards, panels), pass callbacks and configuration via props instead of inlining large chunks of logic inside the component.

- **Utilities & data structures**
- Implement utilities as pure functions in `utils`-style modules with clear naming (`debounce`, `roundToDecimal`, `jsonStringifyWithBigInt`, `bigIntAbs`).
- Use small, focused helpers for domain operations (e.g. `getAllVaults` that returns `{ vaults, vaultAssets, vaultsArray }`) rather than mixing data derivation with rendering.
- Prefer `type` aliases for structured data (`Vault`, `Token`, `AppChainConfig`) and maps (`VaultMap`, `TokenMap`) and keep them grouped at the top of config files.

- **Formatting & readability**
- Use 2-space indentation, trailing commas in multiline argument/prop lists and object literals, and break long expressions across lines for clarity.
- Keep comments minimal and purposeful (e.g. short behavioral notes like `// switch to mainnet if it's a bvUSD vault`), not redundant with the code.
- Keep files focused: screens/components in `screens` directories, layout in `AppLayout`, configuration in `config`/`env`, and services in `services`.

I’ll follow this rule set for any future edits or new code under `frontend/app` so that my changes match the existing style and conventions.
72 changes: 72 additions & 0 deletions .cursor/rules/self-improve.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
description: Guidelines for continuously improving Cursor rules based on emerging code patterns and best practices.
globs: **/*
alwaysApply: true
---

- **Rule Improvement Triggers:**
- New code patterns not covered by existing rules
- Repeated similar implementations across files
- Common error patterns that could be prevented
- New libraries or tools being used consistently
- Emerging best practices in the codebase

- **Analysis Process:**
- Compare new code with existing rules
- Identify patterns that should be standardized
- Look for references to external documentation
- Check for consistent error handling patterns
- Monitor test patterns and coverage

- **Rule Updates:**
- **Add New Rules When:**
- A new technology/pattern is used in 3+ files
- Common bugs could be prevented by a rule
- Code reviews repeatedly mention the same feedback
- New security or performance patterns emerge

- **Modify Existing Rules When:**
- Better examples exist in the codebase
- Additional edge cases are discovered
- Related rules have been updated
- Implementation details have changed

- **Example Pattern Recognition:**
```typescript
// If you see repeated patterns like:
const data = await prisma.user.findMany({
select: { id: true, email: true },
where: { status: 'ACTIVE' }
});

// Consider adding to [prisma.mdc](mdc:.cursor/rules/prisma.mdc):
// - Standard select fields
// - Common where conditions
// - Performance optimization patterns
```

- **Rule Quality Checks:**
- Rules should be actionable and specific
- Examples should come from actual code
- References should be up to date
- Patterns should be consistently enforced

- **Continuous Improvement:**
- Monitor code review comments
- Track common development questions
- Update rules after major refactors
- Add links to relevant documentation
- Cross-reference related rules

- **Rule Deprecation:**
- Mark outdated patterns as deprecated
- Remove rules that no longer apply
- Update references to deprecated rules
- Document migration paths for old patterns

- **Documentation Updates:**
- Keep examples synchronized with code
- Update references to external docs
- Maintain links between related rules
- Document breaking changes
Follow [cursor_rules.mdc](mdc:.cursor/rules/cursor_rules.mdc) for proper rule formatting and structure.
1 change: 1 addition & 0 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"next": "^14.2.23",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-markdown": "^10.1.0",
"recharts": "^2.15.2",
"sharp": "^0.33.5",
"ts-pattern": "^5.6.0",
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/bitvault-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function useVault({ chainId, vaultAddress, vaultSymbol}: { chainId: numbe
: dnZero

return {
apr7d: vaultSymbol !== "sbvUSD" ? 0 : dnumOrNull(Number(stats.sbvUSD[0].apy7d) / 100, 4),
apr30d: vaultSymbol !== "sbvUSD" ? 0 : dnumOrNull(Number(stats.sbvUSD[0].apy30d) / 100, 4),
apr7d: vaultSymbol !== "sbvUSD" ? DNUM_0 : dnumOrNull(Number(stats.sbvUSD[0].apy7d) / 100, 4),
apr30d: vaultSymbol !== "sbvUSD" ? DNUM_0 : dnumOrNull(Number(stats.sbvUSD[0].apy30d) / 100, 4),
collateral,
totalDeposited: totalAssets,
price: totalSupply > dnZero && totalAssets > dnZero ? dn.div(totalAssets, totalSupply, decimals) : dnOne,
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/comps/AppLayout/AccountButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { match, P } from "ts-pattern";
import { MenuItem } from "./MenuItem";
import { supportedChainIcons } from "@/src/config/chains";

export function AccountButton({ size = "small" }: { size?: "small" | "mini" }) {
export function AccountButton({ size = "mini" }: { size?: "small" | "mini" }) {
return (
<ShowAfter delay={500}>
<ConnectKitButton.Custom>
Expand Down
22 changes: 9 additions & 13 deletions frontend/app/src/comps/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,28 @@ export function AppLayout({
</div>
<div
className={css({
display: { base: "none", medium: "grid" },
display: "grid" ,
gridTemplateRows: "auto 1fr auto",
gap: 48,
maxWidth: `calc(${LAYOUT_WIDTH}px + 48px)`,
gap: 4,
maxWidth: `calc(${LAYOUT_WIDTH}px + 4px)`,
margin: "0 auto",
padding: "24px 0",
width: "100%",
})}
>
<TopBar />
<div
className={css({
width: "100%",
width: "80%",
minHeight: 0,
padding: "0 24px",
minWidth: { base: 0, medium: 1200 },
margin: "0 auto",
})}
>
{children}
</div>
<BottomBar />
</div>

<MobileScreen />

</div>
);
}
Expand Down Expand Up @@ -106,13 +104,11 @@ function MobileScreen() {
gap: 16,
width: "90%",
height: "48px",
margin: "16px auto",
margin: "0px auto",
padding: "0 16px",
fontSize: 16,
fontWeight: 500,
background: "fieldSurface",
border: "1px solid token(colors.fieldBorder)",
borderRadius: 16,
borderBottom: "1px solid token(colors.fieldBorder)",
})}
>
<Link
Expand Down Expand Up @@ -166,7 +162,7 @@ function MobileScreen() {
<div
className={css({
width: "90%",
margin: "0 auto",
margin: "12px auto",
display: "flex",
flexDirection: "column",
gap: 24,
Expand Down
Loading