Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m22s
CI/CD Pipeline / Security Scanning (push) Successful in 2m30s
CI/CD Pipeline / Lint and Format (push) Failing after 44s
CI/CD Pipeline / Terraform Validation (push) Failing after 27s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 31s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 56s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 29s
Validation / validate-genesis (push) Successful in 34s
Validation / validate-terraform (push) Failing after 39s
Validation / validate-kubernetes (push) Failing after 14s
Validation / validate-smart-contracts (push) Failing after 20s
Validation / validate-security (push) Failing after 1m19s
Validation / validate-documentation (push) Failing after 27s
Verify Deployment / Verify Deployment (push) Failing after 1m13s
Co-authored-by: Cursor <cursoragent@cursor.com>
87 lines
2.7 KiB
JavaScript
87 lines
2.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.inferCurrencyCode = inferCurrencyCode;
|
|
exports.resolveOmnlLineM2 = resolveOmnlLineM2;
|
|
exports.withM2Capabilities = withM2Capabilities;
|
|
exports.mergeExchangeTokensWithM2Registry = mergeExchangeTokensWithM2Registry;
|
|
exports.findM2TokenByAddress = findM2TokenByAddress;
|
|
exports.findM2TokenBySymbol = findM2TokenBySymbol;
|
|
const money_supply_1 = require("./money-supply");
|
|
const CURRENCY_FROM_SYMBOL = {
|
|
USD: 'USD',
|
|
EUR: 'EUR',
|
|
GBP: 'GBP',
|
|
AUD: 'AUD',
|
|
JPY: 'JPY',
|
|
CHF: 'CHF',
|
|
CAD: 'CAD',
|
|
XAU: 'XAU',
|
|
BTC: 'BTC',
|
|
ETH: 'ETH',
|
|
BNB: 'BNB',
|
|
POL: 'POL',
|
|
AVAX: 'AVAX',
|
|
CRO: 'CRO',
|
|
XDAI: 'XDAI',
|
|
CELO: 'CELO',
|
|
WEMIX: 'WEMIX',
|
|
};
|
|
function inferCurrencyCode(symbol) {
|
|
const s = symbol.toUpperCase();
|
|
for (const [key, code] of Object.entries(CURRENCY_FROM_SYMBOL)) {
|
|
if (s.includes(key))
|
|
return code;
|
|
}
|
|
if (s.startsWith('C') && s.length > 1) {
|
|
for (const [key, code] of Object.entries(CURRENCY_FROM_SYMBOL)) {
|
|
if (s.slice(1).includes(key))
|
|
return code;
|
|
}
|
|
}
|
|
return 'USD';
|
|
}
|
|
function resolveOmnlLineM2(currencyCode, symbol) {
|
|
const ccy = (currencyCode || inferCurrencyCode(symbol ?? 'USD')).toUpperCase();
|
|
return `${ccy}-M2`;
|
|
}
|
|
function withM2Capabilities(token, overrides = {}) {
|
|
const currencyCode = token.currencyCode ?? inferCurrencyCode(token.symbol);
|
|
return {
|
|
symbol: token.symbol,
|
|
name: token.name,
|
|
address: token.address,
|
|
decimals: token.decimals,
|
|
native: token.native,
|
|
currencyCode,
|
|
moneyLayer: 'M2',
|
|
omnlLine: token.omnlLine ?? resolveOmnlLineM2(currencyCode, token.symbol),
|
|
loadFromGl: money_supply_1.GL_CODES.M2_BROAD,
|
|
swappable: true,
|
|
convertible: true,
|
|
transferableInternal: true,
|
|
transferableExternal: true,
|
|
...overrides,
|
|
};
|
|
}
|
|
function mergeExchangeTokensWithM2Registry(baseTokens, registry) {
|
|
const byAddress = new Map();
|
|
for (const t of registry.tokens) {
|
|
byAddress.set(t.address.toLowerCase(), t);
|
|
}
|
|
for (const t of baseTokens) {
|
|
const key = t.address.toLowerCase();
|
|
if (!byAddress.has(key)) {
|
|
byAddress.set(key, withM2Capabilities(t));
|
|
}
|
|
}
|
|
return Array.from(byAddress.values()).sort((a, b) => a.symbol.localeCompare(b.symbol));
|
|
}
|
|
function findM2TokenByAddress(registry, address) {
|
|
const lower = address.toLowerCase();
|
|
return registry.tokens.find((t) => t.address.toLowerCase() === lower);
|
|
}
|
|
function findM2TokenBySymbol(registry, symbol) {
|
|
const s = symbol.trim().toLowerCase();
|
|
return registry.tokens.find((t) => t.symbol.toLowerCase() === s);
|
|
}
|