feat: bridges, PMM, flash workflow, token-aggregation, and deployment docs
- CCIP/trustless bridge contracts, GRU tokens, DEX/PMM tests, reserve vault. - Token-aggregation service routes, planner, chain config, relay env templates. - Config snapshots and multi-chain deployment markdown updates. - gitignore services/btc-intake/dist/ (tsc output); do not track dist. Run forge build && forge test before deploy (large solc graph). Made-with: Cursor
This commit is contained in:
@@ -23,6 +23,17 @@ jest.mock('../../database/repositories/pool-repo', () => ({
|
||||
getPoolsByChain: jest.fn().mockResolvedValue([]),
|
||||
})),
|
||||
}));
|
||||
jest.mock('../../indexer/cross-chain-indexer', () => ({
|
||||
buildCrossChainReport: jest.fn().mockResolvedValue({
|
||||
generatedAt: '2026-03-30T00:00:00.000Z',
|
||||
chainId: 138,
|
||||
crossChainPools: [],
|
||||
volumeByLane: [],
|
||||
atomicSwapVolume24h: 0,
|
||||
bridgeVolume24hTotal: 0,
|
||||
events: [],
|
||||
}),
|
||||
}));
|
||||
jest.mock('../middleware/cache');
|
||||
|
||||
function createApp() {
|
||||
@@ -49,8 +60,16 @@ describe('Report API', () => {
|
||||
baseUrl = started.baseUrl;
|
||||
});
|
||||
|
||||
afterAll((done) => {
|
||||
server.close(done);
|
||||
afterAll(async () => {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.close((error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/cmc', () => {
|
||||
@@ -85,4 +104,345 @@ describe('Report API', () => {
|
||||
expect(Array.isArray(body.tokens)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/all', () => {
|
||||
it('includes GRU transport summary for operator visibility', async () => {
|
||||
const res = await fetch(`${baseUrl}/api/v1/report/all?chainId=138`);
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as Record<string, any>;
|
||||
expect(body.gruTransport?.system?.name).toBe('GRU Monetary Transport Layer');
|
||||
expect(body.gruTransport?.summary).toMatchObject({
|
||||
transportPairs: expect.any(Number),
|
||||
runtimeReadyTransportPairs: expect.any(Number),
|
||||
});
|
||||
expect(body.gruTransport?.gasAssetFamilies).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
familyKey: 'eth_l2',
|
||||
backingMode: 'hybrid_cap',
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/gas-registry', () => {
|
||||
it('returns both chain summaries and runtime pairs for gas rollout consumers', async () => {
|
||||
const res = await fetch(`${baseUrl}/api/v1/report/gas-registry`);
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as Record<string, any>;
|
||||
expect(body.gasAssetFamilies).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
familyKey: 'eth_mainnet',
|
||||
}),
|
||||
])
|
||||
);
|
||||
expect(body.runtimePairs).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
key: '138-1-cETH-cWETH',
|
||||
familyKey: 'eth_mainnet',
|
||||
destinationChainId: 1,
|
||||
destinationChainName: 'Ethereum Mainnet',
|
||||
wrappedNativeQuoteSymbol: 'WETH',
|
||||
stableQuoteSymbol: 'USDC',
|
||||
}),
|
||||
])
|
||||
);
|
||||
expect(body.chains).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
chainId: 1,
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/token-list', () => {
|
||||
it('surfaces both V1 and V2 Chain 138 canonical GRU deployments explicitly', async () => {
|
||||
const res = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=138`);
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as Record<string, any>;
|
||||
expect(body.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cUSDT',
|
||||
chainId: 138,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
symbol: 'cUSDT_V2',
|
||||
chainId: 138,
|
||||
familySymbol: 'cUSDT',
|
||||
deploymentVersion: 'v2',
|
||||
preferredForX402: true,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
symbol: 'cUSDC',
|
||||
chainId: 138,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
symbol: 'cUSDC_V2',
|
||||
chainId: 138,
|
||||
familySymbol: 'cUSDC',
|
||||
deploymentVersion: 'v2',
|
||||
preferredForX402: true,
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('surfaces the cUSDW hub asset on Chain 138 and cWUSDW on active edge chains', async () => {
|
||||
const chain138Res = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=138`);
|
||||
expect(chain138Res.status).toBe(200);
|
||||
const chain138Body = (await chain138Res.json()) as Record<string, any>;
|
||||
expect(chain138Body.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cUSDW',
|
||||
chainId: 138,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const bscRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=56`);
|
||||
expect(bscRes.status).toBe(200);
|
||||
const bscBody = (await bscRes.json()) as Record<string, any>;
|
||||
expect(bscBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWUSDW',
|
||||
chainId: 56,
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('surfaces cAUSDT on Chain 138 when configured and cWAUSDT on active edge chains', async () => {
|
||||
const chain138Res = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=138`);
|
||||
expect(chain138Res.status).toBe(200);
|
||||
const chain138Body = (await chain138Res.json()) as Record<string, any>;
|
||||
expect(chain138Body.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cAUSDT',
|
||||
chainId: 138,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const bscRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=56`);
|
||||
expect(bscRes.status).toBe(200);
|
||||
const bscBody = (await bscRes.json()) as Record<string, any>;
|
||||
expect(bscBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWAUSDT',
|
||||
chainId: 56,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const polygonRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=137`);
|
||||
expect(polygonRes.status).toBe(200);
|
||||
const polygonBody = (await polygonRes.json()) as Record<string, any>;
|
||||
expect(polygonBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWAUSDT',
|
||||
chainId: 137,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const avalancheRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=43114`);
|
||||
expect(avalancheRes.status).toBe(200);
|
||||
const avalancheBody = (await avalancheRes.json()) as Record<string, any>;
|
||||
expect(avalancheBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWAUSDT',
|
||||
chainId: 43114,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const celoRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=42220`);
|
||||
expect(celoRes.status).toBe(200);
|
||||
const celoBody = (await celoRes.json()) as Record<string, any>;
|
||||
expect(celoBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWAUSDT',
|
||||
chainId: 42220,
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('surfaces cBTC on Chain 138 and cWBTC on the staged public mesh with monetary-unit metadata', async () => {
|
||||
const chain138Res = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=138`);
|
||||
expect(chain138Res.status).toBe(200);
|
||||
const chain138Body = (await chain138Res.json()) as Record<string, any>;
|
||||
expect(chain138Body.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cBTC',
|
||||
chainId: 138,
|
||||
registryFamily: 'monetary_unit',
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const mainnetRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=1`);
|
||||
expect(mainnetRes.status).toBe(200);
|
||||
const mainnetBody = (await mainnetRes.json()) as Record<string, any>;
|
||||
expect(mainnetBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWBTC',
|
||||
chainId: 1,
|
||||
registryFamily: 'monetary_unit',
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('surfaces gas-native canonicals on Chain 138 and mirrored cW gas tokens on their public lanes', async () => {
|
||||
const chain138Res = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=138`);
|
||||
expect(chain138Res.status).toBe(200);
|
||||
const chain138Body = (await chain138Res.json()) as Record<string, any>;
|
||||
expect(chain138Body.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cETH',
|
||||
chainId: 138,
|
||||
registryFamily: 'gas_native',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
symbol: 'cETHL2',
|
||||
chainId: 138,
|
||||
registryFamily: 'gas_native',
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const optimismRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=10`);
|
||||
expect(optimismRes.status).toBe(200);
|
||||
const optimismBody = (await optimismRes.json()) as Record<string, any>;
|
||||
expect(optimismBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWETHL2',
|
||||
chainId: 10,
|
||||
registryFamily: 'gas_native',
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
const mainnetRes = await fetch(`${baseUrl}/api/v1/report/token-list?chainId=1`);
|
||||
expect(mainnetRes.status).toBe(200);
|
||||
const mainnetBody = (await mainnetRes.json()) as Record<string, any>;
|
||||
expect(mainnetBody.tokens).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
symbol: 'cWETH',
|
||||
chainId: 1,
|
||||
registryFamily: 'gas_native',
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/cw-registry', () => {
|
||||
it('reads the live cW registry from deployment-status json when available', async () => {
|
||||
const previousPath = process.env.DEPLOYMENT_STATUS_JSON_PATH;
|
||||
const tempPath = `/tmp/token-aggregation-cw-registry-${Date.now()}.json`;
|
||||
|
||||
process.env.DEPLOYMENT_STATUS_JSON_PATH = tempPath;
|
||||
await import('fs/promises').then((fs) =>
|
||||
fs.writeFile(
|
||||
tempPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
version: 'test-1',
|
||||
updated: '2026-04-04',
|
||||
chains: {
|
||||
'56': {
|
||||
name: 'BSC',
|
||||
cwTokens: {
|
||||
cWAUSDT: '0xe1a51Bc037a79AB36767561B147eb41780124934',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
const res = await fetch(`${baseUrl}/api/v1/report/cw-registry?chainId=56`);
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as Record<string, any>;
|
||||
expect(body.source).toBe('deployment-status-file');
|
||||
expect(body.complete).toBe(true);
|
||||
expect(body.version).toBe('test-1');
|
||||
expect(body.chains).toEqual([
|
||||
expect.objectContaining({
|
||||
chainId: 56,
|
||||
name: 'BSC',
|
||||
tokens: [
|
||||
expect.objectContaining({
|
||||
symbol: 'cWAUSDT',
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]);
|
||||
} finally {
|
||||
await import('fs/promises').then((fs) => fs.unlink(tempPath).catch(() => undefined));
|
||||
if (previousPath === undefined) {
|
||||
delete process.env.DEPLOYMENT_STATUS_JSON_PATH;
|
||||
} else {
|
||||
process.env.DEPLOYMENT_STATUS_JSON_PATH = previousPath;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/report/gas-registry', () => {
|
||||
it('reads the live gas rollout registry from deployment-status json when available', async () => {
|
||||
const res = await fetch(`${baseUrl}/api/v1/report/gas-registry?chainId=10`);
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as Record<string, any>;
|
||||
expect(body.source).toBe('deployment-status-file');
|
||||
expect(body.gasAssetFamilies).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
familyKey: 'eth_l2',
|
||||
backingMode: 'hybrid_cap',
|
||||
}),
|
||||
])
|
||||
);
|
||||
expect(body.chains).toEqual([
|
||||
expect.objectContaining({
|
||||
chainId: 10,
|
||||
families: [
|
||||
expect.objectContaining({
|
||||
familyKey: 'eth_l2',
|
||||
mirroredSymbol: 'cWETHL2',
|
||||
dodoPmm: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
quote: 'WETH',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user