Skip to content

Commit

Permalink
disable pooltracker
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Nov 29, 2024
1 parent 40b9412 commit d5727e3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 101 deletions.
105 changes: 54 additions & 51 deletions src/dex/cables/cables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,57 +663,60 @@ export class Cables extends SimpleExchange implements IDex<any> {
tokenAddress: Address,
limit: number,
): Promise<PoolLiquidity[]> {

Check failure on line 665 in src/dex/cables/cables.ts

View workflow job for this annotation

GitHub Actions / Node 16.x sample

A function whose declared type is neither 'void' nor 'any' must return a value.
const tokens = (await this.getCachedTokens()) as { [key: string]: Token };
const token = Object.values(tokens).find(
token => token.address.toLowerCase() === tokenAddress.toLowerCase(),
);

if (!token) {
return [];
}

const tokenPriceUsd = await this.dexHelper.getTokenUSDPrice(
token,
BigInt(10 ** token.decimals),
);

const erc20BalanceCalldata = this.erc20Interface.encodeFunctionData(
'balanceOf',
[this.mainnetRFQAddress],
);
const tokenBalanceMultiCall = [
{
target: token.address,
callData: erc20BalanceCalldata,
},
];
const res = (
await this.dexHelper.multiContract.methods
.aggregate(tokenBalanceMultiCall)
.call()
).returnData[0];

let tokenLiquidity = BigInt(res);

let tokenLiquidityUsd =
(tokenLiquidity * BigInt(tokenPriceUsd * 1_000_000)) /
BigInt(1_000_000 * 10 ** token.decimals);

let tokenWithLiquidity = [];

tokenWithLiquidity.push({
exchange: this.dexKey,
address: this.mainnetRFQAddress,
connectorTokens: [
{
address: token.address,
decimals: token.decimals,
},
],
liquidityUSD: Number(tokenLiquidityUsd),
});

return tokenWithLiquidity;
// const tokens = (await this.getCachedTokens()) as { [key: string]: Token };
// const token = Object.values(tokens).find(
// token => token.address.toLowerCase() === tokenAddress.toLowerCase(),
// );
//
// console.log('TOKEN: ', token);
//
// if (!token) {
// return [];
// }
//
// const tokenPriceUsd = await this.dexHelper.getTokenUSDPrice(
// token,
// BigInt(10 ** token.decimals),
// );
//
// const erc20BalanceCalldata = this.erc20Interface.encodeFunctionData(
// 'balanceOf',
// [this.mainnetRFQAddress],
// );
//
// const tokenBalanceMultiCall = [
// {
// target: token.address,
// callData: erc20BalanceCalldata,
// },
// ];
// const res = (
// await this.dexHelper.multiContract.methods
// .aggregate(tokenBalanceMultiCall)
// .call()
// ).returnData[0];
//
// let tokenLiquidity = BigInt(res);
//
// let tokenLiquidityUsd =
// (tokenLiquidity * BigInt(tokenPriceUsd * 1_000_000)) /
// BigInt(1_000_000 * 10 ** token.decimals);
//
// let tokenWithLiquidity = [];
//
// tokenWithLiquidity.push({
// exchange: this.dexKey,
// address: this.mainnetRFQAddress,
// connectorTokens: [
// {
// address: token.address,
// decimals: token.decimals,
// },
// ],
// liquidityUSD: Number(tokenLiquidityUsd),
// });
//
// return tokenWithLiquidity;
}

/**
Expand Down
51 changes: 1 addition & 50 deletions src/dex/dexalot/dexalot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,56 +1035,7 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
tokenAddress: Address,
limit: number,
): Promise<PoolLiquidity[]> {
const normalizedTokenAddress = this.normalizeAddress(tokenAddress);
const pairs = (await this.getCachedPairs()) || {};
this.tokensMap = (await this.getCachedTokens()) || {};
const tokensAddr = (await this.getCachedTokensAddr()) || {};
const token = this.getTokenFromAddress(normalizedTokenAddress);
if (!token) {
return [];
}

const tokenSymbol = token.symbol?.toLowerCase() || '';

let pairsByLiquidity = [];
for (const pairName of Object.keys(pairs)) {
if (!pairName.includes(tokenSymbol)) {
continue;
}

const tokensInPair = pairName.split('/');
if (tokensInPair.length !== 2) {
continue;
}

const [baseToken, quoteToken] = tokensInPair;
const addr = tokensAddr[baseToken.toLowerCase()];
let outputToken = this.getTokenFromAddress(addr);
if (baseToken === tokenSymbol) {
const addr = tokensAddr[quoteToken.toLowerCase()];
outputToken = this.getTokenFromAddress(addr);
}

const denormalizedToken = this.denormalizeToken(outputToken);

pairsByLiquidity.push({
exchange: this.dexKey,
address: this.mainnetRFQAddress,
connectorTokens: [
{
address: denormalizedToken.address,
decimals: denormalizedToken.decimals,
},
],
liquidityUSD: pairs[pairName].liquidityUSD,
});
}

pairsByLiquidity.sort(
(a: PoolLiquidity, b: PoolLiquidity) => b.liquidityUSD - a.liquidityUSD,
);

return pairsByLiquidity.slice(0, limit);
return []; // not implemented
}

getAPIReqParams(endpoint: string, method: Method): DexalotAPIParameters {
Expand Down

0 comments on commit d5727e3

Please sign in to comment.