Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overnight csv #88

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading