Skip to content
Open
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
6 changes: 4 additions & 2 deletions bridge-aggregators/socket/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Interface } from "ethers";
import { FetchOptions, FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { SocketVaults } from "./contracts";
import { normalizeAddress } from "@defillama/sdk/build/util";
import * as sdk from '@defillama/sdk'

const SocketVaultAbis = {
TokensDeposited: 'event TokensDeposited(address connector, address depositor, address receiver, uint256 depositAmount)',
Expand All @@ -11,9 +11,11 @@ const SocketVaultAbis = {
}

export function getToken(chain: string, vaultAddress: string): string | null {
vaultAddress = sdk.util.normalizeAddress(vaultAddress)

if (SocketVaults[chain]) {
for (const [vault, token] of Object.entries(SocketVaults[chain])) {
if (normalizeAddress(vault) === normalizeAddress(vaultAddress)) {
if (sdk.util.normalizeAddress(vault) === vaultAddress) {
return token;
}
}
Expand Down
7 changes: 3 additions & 4 deletions cli/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { getLatestBlock } from "@defillama/sdk/build/util";
import { SimpleAdapter, whitelistedDimensionKeys, } from "../adapters/types";
import { humanizeNumber } from "@defillama/sdk/build/computeTVL/humanizeNumber";

import * as sdk from "@defillama/sdk"
import * as sdk from "@defillama/sdk"

const humanizeNumber = sdk.util.humanizeNumber;
const getLatestBlock = sdk.blocks.getLatestBlock;
export const ERROR_STRING = '------ ERROR ------'

export function checkArguments(argv: string[]) {
Expand Down Expand Up @@ -43,7 +42,7 @@
Object.entries(element).forEach(([attribute, value]) => {
if (attribute === 'timestamp' && !value) return;
if (!exclude2Print.includes(attribute)) {
const valueFormatted = typeof value === 'object' ? JSON.stringify(value, null, 2) : attribute === "timestamp" ? value + ` (${new Date((value as any) * 1e3).toISOString()})` : humanizeNumber(Number(value))

Check failure on line 45 in cli/utils.ts

View workflow job for this annotation

GitHub Actions / ts-check

This expression is not callable.
console.info(`${camelCaseToSpaces(attribute === "timestamp" ? "endTimestamp" : attribute)}: ${valueFormatted}`)
// if (valueFormatted !== undefined && typeof methodology === 'object' && methodology[attribute.slice(5)])
// console.log("└─ Methodology:", methodology?.[attribute.slice(5)])
Expand Down Expand Up @@ -88,7 +87,7 @@
Object.entries(element).forEach(([attribute, value]) => {
if (attribute === 'timestamp' && !value) return;
if (!exclude2Print.includes(attribute)) {
const valueFormatted = typeof value === 'object' ? JSON.stringify(value, null, 2) : attribute === "timestamp" ? value + ` (${new Date((value as any) * 1e3).toISOString()})` : humanizeNumber(Number(value))

Check failure on line 90 in cli/utils.ts

View workflow job for this annotation

GitHub Actions / ts-check

This expression is not callable.
item[getLabel(attribute)] = valueFormatted
}
})
Expand All @@ -111,7 +110,7 @@
}
})
Object.entries(aggData).forEach(([key, value]) => {
aggregated[getLabel(key)] = typeof value === 'object' ? JSON.stringify(value, null, 2) : humanizeNumber(Number(value))

Check failure on line 113 in cli/utils.ts

View workflow job for this annotation

GitHub Actions / ts-check

This expression is not callable.
})
printTable['Aggregate'] = aggregated
}
Expand Down
4 changes: 2 additions & 2 deletions dexs/kyo-fi-v3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sliceIntoChunks } from "@defillama/sdk/build/util";
import * as sdk from '@defillama/sdk'
import { FetchOptions, FetchResult, SimpleAdapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";

Expand Down Expand Up @@ -28,7 +28,7 @@ const fetch = async (_: any, _1: any, fetchOptions: FetchOptions): Promise<Fetch
});

const targetChunkSize = 50;
const pairChunks = sliceIntoChunks(pairs, targetChunkSize);
const pairChunks = sdk.util.sliceIntoChunks(pairs, targetChunkSize);

for (let i = 0; i < pairChunks.length; i++) {
const chunk = pairChunks[i];
Expand Down
3 changes: 1 addition & 2 deletions dexs/puppyfun/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { lookupBlock } from "@defillama/sdk/build/util";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { addGasTokensReceived, addTokensReceived, getETHReceived, nullAddress } from '../../helpers/token';
import { addTokensReceived, getETHReceived, nullAddress } from '../../helpers/token';
import fetchURL from "../../utils/fetchURL";

const TOKEN_ADDRESS = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
Expand Down
3 changes: 1 addition & 2 deletions dexs/velodrome-slipstream/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as sdk from "@defillama/sdk";
import { sliceIntoChunks } from "@defillama/sdk/build/util";
import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

Expand Down Expand Up @@ -89,7 +88,7 @@ const fetch = async (_: any, _1: any, fetchOptions: FetchOptions): Promise<Fetch

sdk.log('velodrome pairs', pairs.length, 'all pairs', pairs.length, chain)
const targetChunkSize = 10;
const pairChunks = sliceIntoChunks(pairs, targetChunkSize);
const pairChunks = sdk.util.sliceIntoChunks(pairs, targetChunkSize);

for (let chunkIndex = 0; chunkIndex < pairChunks.length; chunkIndex++) {
const targets = pairChunks[chunkIndex];
Expand Down
4 changes: 2 additions & 2 deletions fees/aftermath-fi-amm.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { httpPost } from "../utils/fetchURL";
import { FetchResult, SimpleAdapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { sliceIntoChunks } from "@defillama/sdk/build/util";
import * as sdk from '@defillama/sdk'


const fetch = async (): Promise<FetchResult> => {
const pools = await httpPost('https://aftermath.finance/api/pools', {})
const poolObjectIds = pools.map((pool: any) => pool.objectId)
const chunks = sliceIntoChunks(poolObjectIds, 42)
const chunks = sdk.util.sliceIntoChunks(poolObjectIds, 42)
let i = 0
let dailyVolume = 0
let dailyFees = 0
Expand Down
4 changes: 3 additions & 1 deletion fees/beraborrow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { Interface, ZeroAddress } from "ethers";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import BigNumber from "bignumber.js";
import { normalizeAddress } from "@defillama/sdk/build/util";
import * as sdk from '@defillama/sdk'

const normalizeAddress = sdk.util.normalizeAddress;

const TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';

Expand Down
2 changes: 0 additions & 2 deletions fees/jup-ape.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Dependencies, FetchOptions, SimpleAdapter } from "../adapters/types";
// import { queryAllium } from "../helpers/allium";
import { queryDuneSql } from "../helpers/dune";
import { CHAIN } from "../helpers/chains";
// import { getSolanaReceived } from "../helpers/token";

const JUP_FEE_RECEIVER = '5YET3YapxD6to6rqPqTWB3R9pSbURy6yduuUtoZkzoPX';

Expand Down
5 changes: 3 additions & 2 deletions fees/resolv/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getTokenTransfers } from "@defillama/sdk/build/util/indexer";

import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { METRIC } from "../../helpers/metrics";
import * as sdk from '@defillama/sdk'

const USR = '0x66a1e37c9b0eaddca17d3662d6c05f4decf3e110';
const ST_USR = '0x6c8984bc7DBBeDAf4F6b2FD766f16eBB7d10AAb4';
Expand Down Expand Up @@ -38,7 +39,7 @@ const breakdownMethodology = {
const getOtherRevenues = async (options: FetchOptions) => {
const [fromBlock, toBlock] = await Promise.all([options.getStartBlock(), options.api.getBlock()])

return getTokenTransfers({
return sdk.indexer.getTokenTransfers({
chain: options.chain,
target: FEE_COLLECTOR,
fromAddressFilter: ADDRESSES_FROM,
Expand Down
7 changes: 3 additions & 4 deletions helpers/aave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { BaseAdapter, FetchOptions, IStartTimestamp } from "../../adapters/types
import * as sdk from "@defillama/sdk";
import AaveAbis from './abi';
import {decodeReserveConfig} from "./helper";
import { normalizeAddress } from "@defillama/sdk/build/util";
import { METRIC } from '../../helpers/metrics';

export interface AaveLendingPoolConfig {
Expand Down Expand Up @@ -167,7 +166,7 @@ export async function getPoolFees(pool: AaveLendingPoolConfig, options: FetchOpt
protocolFee: number;
}} = {}
for (let i = 0; i < reservesList.length; i++) {
reserveLiquidationConfigs[normalizeAddress(reservesList[i])] = {
reserveLiquidationConfigs[sdk.util.normalizeAddress(reservesList[i])] = {
bonus: Number(reserveConfigs[i].liquidationBonus),
protocolFee: liquidationProtocolFees[i],
}
Expand Down Expand Up @@ -198,8 +197,8 @@ export async function getPoolFees(pool: AaveLendingPoolConfig, options: FetchOpt
*/

const e = Number(event.liquidatedCollateralAmount)
const x = reserveLiquidationConfigs[normalizeAddress(event.collateralAsset)].bonus / PercentageMathDecimals
const y = reserveLiquidationConfigs[normalizeAddress(event.collateralAsset)].protocolFee / PercentageMathDecimals
const x = reserveLiquidationConfigs[sdk.util.normalizeAddress(event.collateralAsset)].bonus / PercentageMathDecimals
const y = reserveLiquidationConfigs[sdk.util.normalizeAddress(event.collateralAsset)].protocolFee / PercentageMathDecimals

// protocol fees from liquidation bonus
const b = (e - e / x)
Expand Down
3 changes: 2 additions & 1 deletion helpers/alliumDex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchOptions } from "../adapters/types"
import { Dependencies, FetchOptions } from "../adapters/types"
import { queryAllium } from "./allium"
import { CHAIN } from "./chains"

Expand All @@ -21,6 +21,7 @@ export function alliumSolanaDexExport(dex_id: string, protocol: string, start: s
}

return {
dependencies: [Dependencies.ALLIUM],
adapter: {
[CHAIN.SOLANA]: {
fetch,
Expand Down
3 changes: 1 addition & 2 deletions helpers/curve/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CallsParams } from "@defillama/sdk/build/types";
import { FetchOptions } from "../../adapters/types";
import { formatAddress } from "../../utils/utils";

Expand Down Expand Up @@ -154,7 +153,7 @@ export async function getAllPools(options: FetchOptions, config: ICurveDexConfig
export async function getPoolTokens(options: FetchOptions, poolAddresses: Array<string>, config: ICurveDexConfig): Promise<{[key: string]: IDexPool}> {
const pools: {[key: string]: IDexPool} = {}

const coinsCalls: Array<CallsParams> = []
const coinsCalls: Array<any> = []
for (const poolAddress of poolAddresses) {
for (let i = 0; i < MAX_TOKENS_COUNT; i++) {
coinsCalls.push({
Expand Down
Loading