Skip to content

Commit

Permalink
refactor looksrare
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Oct 3, 2024
1 parent db59223 commit cf93610
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions fees/looksrare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Adapter, ChainBlocks, FetchOptions } from "../adapters/types";
import { Adapter, FetchOptions } from "../adapters/types";
import { ETHEREUM } from "../helpers/chains";
import { Chain } from '@defillama/sdk/build/general';

const address = "0x0000000000e655fae4d56241588680f86e3b2377";
const topic0_taker_bid = "0x3ee3de4684413690dee6fff1a0a4f92916a1b97d1c5a83cdf24671844306b2e3";
Expand All @@ -10,40 +9,37 @@ const eventAbis = {
"TakerBid": "event TakerBid((bytes32 orderHash, uint256 orderNonce, bool isNonceInvalidated) nonceInvalidationParameters, address bidUser, address bidRecipient, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts)",
}

const graphs = (_chain: Chain) => {
return async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, }: FetchOptions) => {

const logs_bid = await getLogs({
target: address,
topics: [topic0_taker_bid],
eventAbi:eventAbis.TakerBid
})

const logs_ask = await getLogs({
target: address,
topics: [topic0_taker_ask],
eventAbi:eventAbis.TakerAsk,
})
const logs = logs_bid.concat(logs_ask)
const dailyFees = createBalances()
logs.map((tx: any) => {
dailyFees.add(tx.currency, tx.feeAmounts[2])
});

return {
timestamp,
dailyFees: dailyFees,
dailyRevenue: dailyFees,
dailyHoldersRevenue: dailyFees,
};
const fetch = async ({ createBalances, getLogs, }: FetchOptions) => {

const logs_bid = await getLogs({
target: address,
topics: [topic0_taker_bid],
eventAbi: eventAbis.TakerBid
})

const logs_ask = await getLogs({
target: address,
topics: [topic0_taker_ask],
eventAbi: eventAbis.TakerAsk,
})
const logs = logs_bid.concat(logs_ask)
const dailyFees = createBalances()
logs.map((tx: any) => {
dailyFees.add(tx.currency, tx.feeAmounts[2])
});

return {
dailyFees: dailyFees,
dailyRevenue: dailyFees,
dailyHoldersRevenue: dailyFees,
};
};


const adapter: Adapter = {
version: 2,
adapter: {
[ETHEREUM]: {
fetch: graphs(ETHEREUM),
fetch,
start: 1640775864,
},
}
Expand Down

0 comments on commit cf93610

Please sign in to comment.