Skip to content

Commit

Permalink
chore: field redefinition and supply/borrow amount inscription
Browse files Browse the repository at this point in the history
  • Loading branch information
climberNeedEquipment committed Jun 6, 2024
1 parent 61ba980 commit bcc6667
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions adapters/layerbank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ interface BlockData {
}

type OutputDataSchemaRow = {
protocol: string;
date: number;
block_number: number;
timestamp: number;
user_address: string;
token_address: string;
token_balance: bigint;
token_symbol: string; //token symbol should be empty string if it is not available
usd_price: number; //assign 0 if not available
market: string;
supply_token: bigint;
borrow_token: bigint;
};

export const getUserTVLByBlock = async (blocks: BlockData) => {
Expand Down Expand Up @@ -55,23 +55,19 @@ export const getUserTVLByBlock = async (blocks: BlockData) => {
await updateBorrowBalances(states);

states.forEach((state) => {
const amount = state.lentAmount - state.borrowAmount;

if (bigMath.abs(amount) < 1) return;

const marketInfo = marketInfos.find(
(mi) => mi.underlyingAddress == state.token.toLowerCase()
);

// Accumulate CSV row data
csvRows.push({
protocol: "Layerbank",
date: blocks.blockTimestamp,
block_number: blocks.blockNumber,
timestamp: blocks.blockTimestamp,
user_address: state.account,
token_address: state.token,
token_balance: amount,
token_symbol: marketInfo?.underlyingSymbol ?? "",
usd_price: 0,
market: state.token,
supply_token: state.lentAmount,
borrow_token: state.borrowAmount,
});
});

Expand Down

0 comments on commit bcc6667

Please sign in to comment.