forked from Vesting-Vault/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-portfolio.js
More file actions
43 lines (35 loc) · 1.15 KB
/
test-portfolio.js
File metadata and controls
43 lines (35 loc) · 1.15 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
// Test file for portfolio endpoint
const express = require('express');
const cors = require('cors');
const app = express();
const port = 3000;
// Middleware
app.use(cors());
app.use(express.json());
app.get('/', (req, res) => {
res.json({
project: 'Vesting Vault',
status: 'Tracking Locked Tokens',
contract: 'CD5QF6KBAURVUNZR2EVBJISWSEYGDGEEYVH2XYJJADKT7KFOXTTIXLHU'
});
});
// Portfolio aggregation endpoint
app.get('/api/user/:address/portfolio', (req, res) => {
const { address } = req.params;
// Mock data for demonstration - replace with actual vault data
const mockVaults = [
{ type: 'advisor', locked: 80, claimable: 15 },
{ type: 'investor', locked: 20, claimable: 5 }
];
// Calculate totals
const total_locked = mockVaults.reduce((sum, vault) => sum + vault.locked, 0);
const total_claimable = mockVaults.reduce((sum, vault) => sum + vault.claimable, 0);
// Return the portfolio summary
res.json({
total_locked,
total_claimable,
vaults: mockVaults,
address
});
});
app.listen(port, () => console.log(`Vesting API running on port ${port}`));