Skip to content

Commit

Permalink
refactor: update chain name handling and include environment logging
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Jan 15, 2025
1 parent cab8cc2 commit 5468349
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 11 additions & 2 deletions adapters/utils/runAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Balances, ChainApi, getEventLogs, getProvider, elastic } from '@defillama/sdk'
import { Balances, ChainApi, getEventLogs, getProvider, elastic, log } from '@defillama/sdk'
import { BaseAdapter, ChainBlocks, DISABLED_ADAPTER_KEY, Fetch, FetchGetLogsOptions, FetchOptions, FetchResultGeneric, FetchV2, } from '../types'
import { getBlock } from "../../helpers/getBlock";
import { getUniqStartOfTodayTimestamp } from '../../helpers/getUniSubgraphFees';
import * as _env from '../../helpers/env'

// to trigger inclusion of the env.ts file
const _include_env = _env.getEnv('BITLAYER_RPC')

const ONE_DAY_IN_SECONDS = 60 * 60 * 24

Expand Down Expand Up @@ -93,7 +97,12 @@ export default async function runAdapter(volumeAdapter: BaseAdapter, cleanCurren
async function getOptionsObject(timestamp: number, chain: string, chainBlocks: ChainBlocks): Promise<FetchOptions> {
const withinTwoHours = Math.trunc(Date.now() / 1000) - timestamp < 24 * 60 * 60 // 24 hours
const createBalances: () => Balances = () => {
return new Balances({ timestamp: closeToCurrentTime ? undefined : timestamp, chain })
let _chain = chain
// workaround for mismatch in chain names between dimensions repo and rest of the codebase
switch (chain) {
case 'bitlayer': _chain = 'btr'; break;
}
return new Balances({ timestamp: closeToCurrentTime ? undefined : timestamp, chain: _chain })
}
const toTimestamp = timestamp - 1
const fromTimestamp = toTimestamp - ONE_DAY_IN_SECONDS
Expand Down
6 changes: 1 addition & 5 deletions options/jaspervault/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { Adapter, FetchOptions, ChainEndpoints } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { GraphQLClient, gql } from 'graphql-request';
import { Balances, log } from "@defillama/sdk";
import { Balances, } from "@defillama/sdk";
import { Chain } from "@defillama/sdk/build/general";
import BigNumber from "bignumber.js";
import ADDRESSES from '../../helpers/coreAssets.json'
import * as _env from '../../helpers/env'

// to trigger inclusion of the env.ts file
log(_env.getEnv('BITLAYER_RPC'), 'bitlayer')

const iBTC_arbitrum = '0x050C24dBf1eEc17babE5fc585F06116A259CC77A'
const WSOL_arbitrum = '0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07'
Expand Down

0 comments on commit 5468349

Please sign in to comment.