Skip to content

Commit

Permalink
Merge pull request #88 from matt5346/overnight-csv
Browse files Browse the repository at this point in the history
Overnight csv
  • Loading branch information
nitish-91 authored May 1, 2024
2 parents b794094 + 2664b1d commit 31dbc94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion adapters/overnight/src/sdk/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const RPC_URLS = {


export const SNAPSHOTS_BLOCKS = [
0, 500000
0, 4169748
];

export const CHUNKS_SPLIT = 20;
Expand Down
32 changes: 17 additions & 15 deletions adapters/overnight/src/sdk/subgraphDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ const countNetRebase = async (
console.log("Loading", index, " -> ", usersMinted.size)
}

const rebased = balanceDiff.minus(val).plus(userRedeem).plus(balanceTo);
const valToSave = rebased.gt(0) ? rebased.toFixed() : "0";
// rebase counting
// const rebased = balanceDiff.minus(val).plus(userRedeem).plus(balanceTo);
// const valToSave = rebased.gt(0) ? rebased.toFixed() : "0";

usersRebaseProfit.set(key, valToSave);
usersRebaseProfit.set(key, balanceTo);
} catch(e) {
console.log(e)
console.log("ERROR FOR:", {
Expand Down Expand Up @@ -281,6 +282,7 @@ export const getRebaseForUsersByPoolAtBlock = async ({
// 0x58aacbccaec30938cb2bb11653cad726e5c4194a usdc/usd+
// 0xc5f4c5c2077bbbac5a8381cf30ecdf18fde42a91 usdt+/usd+
const getPoolsData = async (blockNumber: number, blockTimestamp: number): Promise<CSVRow[]> => {
if (new BN(blockNumber).eq(0)) return [];
let whereQuery = blockNumber ? `where: { blockNumber_lt: ${blockNumber} }` : "";
const poolsData = SUBGRAPH_URLS[CHAINS.LINEA][PROTOCOLS.OVN]

Expand Down Expand Up @@ -342,12 +344,12 @@ const getPoolsData = async (blockNumber: number, blockTimestamp: number): Promis
const lpValueStr = lpValue.toString();
// Accumulate CSV row data
csvRows.push({
user_address: key,
token_address: LP_LYNEX,
token_symbol: LP_LYNEX_SYMBOL,
token_balance: BigInt(lpValueStr),
block_number: blockNumber,
timestamp: blockTimestamp,
user_address: key.toLowerCase(),
token_address: LP_LYNEX,
token_balance: BigInt(lpValueStr),
token_symbol: LP_LYNEX_SYMBOL,
usd_price: 0
});
})
Expand Down Expand Up @@ -376,23 +378,23 @@ const getRebaseData = async (block: number, blockTimestamp: number): Promise<CSV

positionsRebaseUsd.forEach((value, key) => {
csvRows.push({
user_address: key,
token_symbol: USD_PLUS_SYMBOL,
token_balance: BigInt(value),
token_address: USD_PLUS_LINEA,
block_number: block,
timestamp: blockTimestamp,
user_address: key.toLowerCase(),
token_address: USD_PLUS_LINEA,
token_balance: BigInt(value),
token_symbol: USD_PLUS_SYMBOL,
usd_price: 0
});
});
positionsRebaseUsdt.forEach((value, key) => {
csvRows.push({
user_address: key,
token_symbol: USDT_PLUS_SYMBOL,
token_balance: BigInt(value),
token_address: USDT_PLUS_LINEA,
block_number: block,
timestamp: blockTimestamp,
user_address: key.toLowerCase(),
token_address: USDT_PLUS_LINEA,
token_balance: BigInt(value),
token_symbol: USDT_PLUS_SYMBOL,
usd_price: 0
});
});
Expand Down

0 comments on commit 31dbc94

Please sign in to comment.