forked from koshikraj/ottopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathportfolio-provider.ts
More file actions
30 lines (28 loc) · 1.14 KB
/
Copy pathportfolio-provider.ts
File metadata and controls
30 lines (28 loc) · 1.14 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
import { config } from '../config.js'
import {
ZerionPortfolioConnector,
cached,
type PortfolioConnector,
} from '../connectors/portfolio/index.js'
/**
* The one portfolio connector, behind the one cache.
*
* Both surfaces read balances — the web app for the portfolio page, the MCP
* surface for `get_portfolio` — and they have to share an instance, not merely
* a class: the cache in front of the vendor is what keeps an agent polling and
* a person refreshing from spending the quota twice on the same wallet.
*
* Null when there is no key. A deployment with Privy wired up and no Zerion
* key should still sign people in and link wallets — only the numbers are
* missing — so each surface says "not configured" for balances alone rather
* than refusing everything.
*/
export const portfolioProvider: PortfolioConnector | null = config.zerionApiKey
? cached(
new ZerionPortfolioConnector({
apiKey: config.zerionApiKey,
...(config.zerionApiUrl ? { baseUrl: config.zerionApiUrl } : {}),
}),
)
: null
if (!portfolioProvider) console.error('[portfolio] balances disabled — ZERION_API_KEY is not set')