Skip to content

Commit

Permalink
market data file now for each vault
Browse files Browse the repository at this point in the history
  • Loading branch information
alfulinku committed Oct 18, 2024
1 parent 1216af7 commit 4d386ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ export interface MarketData {
lltv: number;
}

const marketDataName = `${process.env.METAMORPHO_NAME} marketData.json`;
export function loadMarketData(): { [id: string]: MarketData } {
if (existsSync('marketData.json')) {
return JSON.parse(readFileSync('marketData.json', 'utf-8'));
console.log('loading market data from', marketDataName);
if (existsSync(marketDataName)) {
return JSON.parse(readFileSync(marketDataName, 'utf-8'));
}

return {};
}

export function saveMarketData(marketData: { [id: string]: MarketData }) {
writeFileSync('marketData.json', JSON.stringify(marketData, null, 2));
console.log('saving market data to', marketDataName);
writeFileSync(marketDataName, JSON.stringify(marketData, null, 2));
}

0 comments on commit 4d386ba

Please sign in to comment.