Skip to content
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
714188a
feat: Add Solana USDC deposit system with Anchor program
aayusha59 Jan 18, 2026
caea3cb
Merge pull request #5 from aayusha59/solana-devnet
aayusha59 Jan 18, 2026
44e1ce3
vault
aayusha59 Jan 18, 2026
a4ea0fb
Merge pull request #6 from aayusha59/solana-devnet
aayusha59 Jan 18, 2026
1996a7f
transactions working for vault + portfolio
aayusha59 Jan 18, 2026
916c5bc
Merge pull request #7 from aayusha59/solana-devnet
aayusha59 Jan 18, 2026
bd8a8d7
onchain storage
aayusha59 Jan 18, 2026
c8c8a13
Merge pull request #8 from aayusha59/feature/on-chain-position-storage
aayusha59 Jan 18, 2026
f987a6d
Added script
umara25 Jan 18, 2026
78949f3
Merge branch 'main' of https://github.com/aayusha59/polyield into Gen…
umara25 Jan 18, 2026
294e206
Merge pull request #9 from aayusha59/main
aayusha59 Jan 18, 2026
2590c83
Merge pull request #11 from aayusha59/Generate-Devwallet
umara25 Jan 18, 2026
e10835c
Merge branch 'main' of https://github.com/aayusha59/polyield into fea…
aayusha59 Jan 18, 2026
2aa3a03
made changes
aayusha59 Jan 18, 2026
a59e908
Merge pull request #13 from aayusha59/feature/on-chain-position-storage
aayusha59 Jan 18, 2026
85e7756
database configired with postgres and supabase. can hide/show if its …
aayusha59 Jan 18, 2026
e58b3c7
Merge pull request #15 from aayusha59/database
aayusha59 Jan 18, 2026
26c9f18
.
aayusha59 Jan 18, 2026
936efcf
how it works
aayusha59 Jan 18, 2026
dd08121
Merge pull request #16 from aayusha59/how-it-works
aayusha59 Jan 18, 2026
fb8f193
Polyield to "Poly Yield" rebrand
aayusha59 Jan 18, 2026
632dc23
Merge pull request #17 from aayusha59/how-it-works
aayusha59 Jan 18, 2026
ef0a77b
how it works fixed
aayusha59 Jan 18, 2026
bcc93af
Merge pull request #18 from aayusha59/how-it-works
aayusha59 Jan 18, 2026
21802a6
faq + --> "PolyYield" rebrand
aayusha59 Jan 18, 2026
557ae52
.
aayusha59 Jan 18, 2026
a411414
Merge pull request #19 from aayusha59/faq
aayusha59 Jan 18, 2026
79eae3e
Merge pull request #20 from aayusha59/main
aayusha59 Jan 18, 2026
e033008
hid nonsense + header fix
aayusha59 Jan 18, 2026
b6d6b6b
Merge branch 'faq' of https://github.com/aayusha59/polyield into faq
aayusha59 Jan 18, 2026
8f4438a
Merge pull request #21 from aayusha59/faq
aayusha59 Jan 18, 2026
8ba9427
remove lead
aayusha59 Jan 18, 2026
21b2a5b
Merge pull request #22 from aayusha59/faq
aayusha59 Jan 18, 2026
6f2fb2d
chore: update Next.js to 16.1.3 for security
aayusha59 Jan 18, 2026
4429507
navbar scroll
aayusha59 Jan 18, 2026
7fa7424
Merge pull request #23 from aayusha59/faq
aayusha59 Jan 18, 2026
a02cd61
some changes
aayusha59 Jan 18, 2026
a364205
Merge pull request #24 from aayusha59/faq
aayusha59 Jan 18, 2026
b45c896
poly x solana
aayusha59 Jan 18, 2026
b2d0cb1
Merge pull request #26 from aayusha59/faq
aayusha59 Jan 18, 2026
01e7939
"powered by"
aayusha59 Jan 18, 2026
76ebe48
Merge pull request #27 from aayusha59/faq
aayusha59 Jan 18, 2026
7c4d97d
mobile optimized
aayusha59 Jan 18, 2026
af505e2
Merge pull request #28 from aayusha59/faq
aayusha59 Jan 18, 2026
eccc2d8
yield calculation and breakdown
aayusha59 Jan 18, 2026
26d7e5d
Merge pull request #29 from aayusha59/faq
aayusha59 Jan 18, 2026
a7f7ab4
feat: integrate Anchor program for deposits
aayusha59 Jan 18, 2026
d20e112
Merge pull request #30 from aayusha59/anchor-vault
aayusha59 Jan 18, 2026
f93f59b
Create README.md for PolyYield project
aayusha59 Jan 20, 2026
e19302d
Add warning about scams in README
aayusha59 Jan 21, 2026
e22a1c0
chore: update .gitignore
aayusha59 Mar 28, 2026
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
19 changes: 19 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[toolchain]
anchor_version = "0.30.1"

[features]
seeds = false
skip-lint = false

[programs.devnet]
polyield_vault = "FWGiD7WhXu8k7eDtEwr3ZbXbvqwL7kdJgNfugrSVJ7F3"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
134 changes: 134 additions & 0 deletions BRANCH_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Database Branch - Implementation Summary

## What Was Changed

This branch replaces the localStorage-based position tracking system with a persistent Supabase database solution. Users can now access their positions and market history from any browser or device by simply connecting their wallet.

## Files Created

### Database Infrastructure
- **`lib/database/supabase.ts`** - Supabase client initialization with environment variable validation
- **`lib/database/types.ts`** - TypeScript type definitions for the `user_positions` table
- **`lib/database/positions-service.ts`** - Service layer with functions for CRUD operations
- **`lib/database/migrations/001_initial_schema.sql`** - SQL migration to create tables and indexes

### Documentation
- **`SUPABASE_SETUP.md`** - Quick setup guide for configuring Supabase
- **`DATABASE_IMPLEMENTATION.md`** - Comprehensive implementation documentation
- **`BRANCH_SUMMARY.md`** - This file

## Files Modified

### Hooks
- **`hooks/use-positions.ts`**
- Added Supabase database integration
- Implemented automatic fallback to localStorage if Supabase not configured
- Added `isLoading`, `error`, and `refreshPositions` to return values
- Updated `addPosition` to be async and accept `transactionSignature` parameter

- **`hooks/use-deposit.ts`**
- Updated `deposit` function signature to accept `marketQuestion` and `expiryTimestamp`
- Added automatic position saving to database after successful transactions
- Graceful error handling if database save fails (transaction still succeeds)

### Components
- **`components/deposit-modal.tsx`**
- Updated `handleDeposit` to pass new required parameters
- Ensures positions are saved to database with transaction signatures

### Dependencies
- **`package.json`** / **`pnpm-lock.yaml`**
- Added `@supabase/supabase-js` v2.90.1

## Key Features

✅ **Cross-Device Persistence** - Positions stored by wallet address, accessible from any browser/device
✅ **Transaction Tracking** - Each position includes the Solana transaction signature
✅ **Automatic Fallback** - Gracefully falls back to localStorage if Supabase not configured
✅ **No Hardcoded Secrets** - All credentials in `.env.local` (not committed to repo)
✅ **Type Safety** - Full TypeScript types for database operations
✅ **Optimized Queries** - Database indexes for fast lookups by wallet, market, and status

## Environment Variables Required

Create a `.env.local` file with:

```bash
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
```

**Note:** `.env.local` is already in `.gitignore` and will not be committed.

## Setup Steps

1. **Create Supabase Project** at [supabase.com](https://supabase.com)
2. **Run Migration**: Execute `lib/database/migrations/001_initial_schema.sql` in Supabase SQL Editor
3. **Configure Environment**: Create `.env.local` with your Supabase credentials
4. **Restart Dev Server**: `pnpm dev`

For detailed instructions, see `SUPABASE_SETUP.md`

## Database Schema

### `user_positions` Table
```sql
- id (UUID, primary key)
- wallet_address (TEXT, indexed)
- market_id (TEXT, indexed)
- market_question (TEXT)
- position (TEXT: 'YES' or 'NO')
- amount (DECIMAL)
- transaction_signature (TEXT)
- timestamp (TIMESTAMPTZ)
- expiry_timestamp (TIMESTAMPTZ)
- status (TEXT: 'active', 'claimed', or 'refunded')
- created_at (TIMESTAMPTZ)
- updated_at (TIMESTAMPTZ, auto-updated)
```

## Backward Compatibility

- ✅ Works without Supabase (falls back to localStorage)
- ✅ No breaking changes to existing functionality
- ⚠️ Existing localStorage positions won't auto-migrate (manual migration possible)

## Testing Checklist

- [ ] Create Supabase project and run migration
- [ ] Configure `.env.local` with Supabase credentials
- [ ] Connect wallet and make a test deposit
- [ ] Verify position appears in Supabase dashboard
- [ ] Disconnect wallet, reconnect, verify positions load
- [ ] Test on different browser/device with same wallet
- [ ] Test without `.env.local` (should fallback to localStorage)

## Next Steps / Future Enhancements

- [ ] Implement position status updates (claimed/refunded)
- [ ] Add real-time subscriptions for live position updates
- [ ] Implement wallet-based RLS policies for production
- [ ] Create admin interface for market resolution
- [ ] Add position migration tool from localStorage to Supabase
- [ ] Implement analytics dashboard for position tracking

## Commit Message Suggestion

```
feat: Replace localStorage with Supabase database for position tracking

- Add Supabase client and database service layer
- Create user_positions table with wallet address indexing
- Update hooks to save/fetch positions from database
- Implement automatic fallback to localStorage if not configured
- Store transaction signatures with each position
- Enable cross-device position access via wallet connection

All API keys configured via .env.local (not hardcoded)
```

## Questions or Issues?

Refer to:
- `SUPABASE_SETUP.md` - Setup instructions
- `DATABASE_IMPLEMENTATION.md` - Technical details and troubleshooting
Loading