| name | marketplace-bid-ask-system |
| description | Use when working on ERTZU products, asks, bids, matching, buy-now, bid acceptance, order creation, market summaries, or marketplace status rules. |
Marketplace Bid Ask System
When To Use
Use this skill for product detail pages, marketplace grid behavior, ask creation, bid placement, buy-now checkout, seller bid decisions, order creation, market sales, and any SQL/RPC touching marketplace state.
ERTZU-Specific Instructions
- Preserve the StockX-like model: one perfume product page, many seller asks, many buyer bids.
- Buyers can buy the lowest matching active ask or place bids.
- Sellers can place asks and accept eligible active bids.
- Seller ships to ERTZU first; ERTZU verifies before buyer shipment.
- Match on
product_id, fill_level_category, bottle_size_ml, status, price, and expiry.
- Keep lowest ask ordering by lowest price, then oldest creation time.
Files And Areas To Inspect
src/lib/market.ts
src/lib/matching.ts
src/app/listings/page.tsx
src/app/listings/[id]/page.tsx
src/app/sell/page.tsx
src/app/buy/page.tsx
src/app/bid/checkout/page.tsx
src/app/notifications/page.tsx
src/app/checkout/[id]/page.tsx
supabase/schema-v11-marketplace.sql
supabase/schema-v12-bid-rules.sql
supabase/schema-v15-security-hardening.sql
supabase/schema-v17-bid-decisions-payment.sql
supabase/schema-v20-community-ranking-votes.sql
supabase/migrations/*.sql
Concrete Checks
- Verify
selectLowestAsk() and SQL buy_now use equivalent fill/size semantics.
- Verify users cannot buy or bid on their own active asks.
- Verify bid floor rules when active asks exist.
- Verify bid at or above lowest ask routes to buy-now behavior.
- Verify
place_bid, buy_now, accept_bid, decline_bid, cancel_bid, admin_cancel_ask, and admin_cancel_bid enforce auth and blocked-user rules.
- Verify order rows carry buyer, seller, product, ask, bid, final price, currency, fill level, payment intent, shipping address, and status as needed.
- Verify market sales and notifications are written only after valid matches.
- Verify
product_market_summary returns lowest ask, active ask count, highest bid, last sale, and ranking signals used by the UI.
Mistakes To Avoid
- Do not make
/listings/[id] an individual seller listing page.
- Do not rely only on client-side
userIsAsking checks.
- Do not let client-provided prices decide server-side final price.
- Do not ignore bottle size when multiple sizes exist.
- Do not globally cancel a bid when only one eligible seller declines unless all eligible sellers have declined.
- Do not bypass RPCs with direct table updates for high-risk transitions.