51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
/**
|
||
|
|
* Resolve Tezos wUSDC/wUSDT and related token addresses from Plenty API.
|
||
|
|
* Output: JSON suitable for TEZOS_TOKEN_REGISTRY or env config.
|
||
|
|
* Run: node scripts/resolve-tezos-tokens-from-plenty.js
|
||
|
|
*/
|
||
|
|
|
||
|
|
const PLENTY_TOKENS_URL = 'https://api.plenty.network/config/tokens';
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
try {
|
||
|
|
const res = await fetch(PLENTY_TOKENS_URL, { signal: AbortSignal.timeout(10000) });
|
||
|
|
if (!res.ok) {
|
||
|
|
console.error('Plenty API error:', res.status);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
const tokens = await res.json();
|
||
|
|
const bySymbol = {};
|
||
|
|
for (const t of tokens) {
|
||
|
|
const sym = (t.symbol || t.tokenSymbol || '').toUpperCase();
|
||
|
|
if (sym && t.address) bySymbol[sym] = { ...t, symbol: sym };
|
||
|
|
}
|
||
|
|
const wusdc = bySymbol['WUSDC'] || bySymbol['Wrapped USDC'];
|
||
|
|
const wusdt = bySymbol['WUSDT'] || bySymbol['Wrapped USDT'];
|
||
|
|
const usdc = bySymbol['USDC'];
|
||
|
|
const usdt = bySymbol['USDT'];
|
||
|
|
const out = {
|
||
|
|
wUSDC: wusdc?.address || null,
|
||
|
|
wUSDT: wusdt?.address || null,
|
||
|
|
USDC: usdc?.address || null,
|
||
|
|
USDT: usdt?.address || null,
|
||
|
|
source: PLENTY_TOKENS_URL,
|
||
|
|
timestamp: new Date().toISOString(),
|
||
|
|
};
|
||
|
|
console.log(JSON.stringify(out, null, 2));
|
||
|
|
} catch (err) {
|
||
|
|
console.error('Failed to fetch Plenty tokens:', err.message);
|
||
|
|
console.log(JSON.stringify({
|
||
|
|
wUSDC: null,
|
||
|
|
wUSDT: null,
|
||
|
|
USDC: null,
|
||
|
|
USDT: null,
|
||
|
|
error: err.message,
|
||
|
|
note: 'Update TEZOS_TOKEN_REGISTRY manually or retry when Plenty API is available',
|
||
|
|
}, null, 2));
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
main();
|