Skip to content

Commit

Permalink
Merge branch 'master' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
mantasfam committed Oct 8, 2024
2 parents c555447 + 30ea040 commit e9bb767
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_USERNAME=
REDIS_PASSWORD=
SOLANA_BOTTLENECK_MIN_TIME=500
SOLANA_BOTTLENECK_MIN_TIME=500
22 changes: 9 additions & 13 deletions src/factory/providers/optimism/synthetix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ const QUERY_NO_BLOCK = gql`

async function getSnxHolders(block, chain) {
let holders = [];
try {
for (let i = 0; i <= 5000; i += 1000) {
const holder = (
await request(GRAPHQL_ENDPOINT, QUERY_NO_BLOCK, {
block,
skip: i,
})
).snxholders;
holders = [...holders, ...holder];
}
} catch (e) {
console.log(`Issue with SubGraph on block ${block}`);
holders = await getSnxHolders(block - basicUtil.getDelay(chain), chain);

for (let i = 0; i <= 5000; i += 1000) {
const holder = (
await request(GRAPHQL_ENDPOINT, QUERY_NO_BLOCK, {
block,
skip: i,
})
).snxholders;
holders = [...holders, ...holder];
}

return holders;
Expand Down
6 changes: 4 additions & 2 deletions src/factory/providers/solana/orca/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
}

const poolInfo = (await axios.get(WHIRLPOOL_Endpoint)).data;
const filteredPools = poolInfo.whirlpools.filter((pool) => pool.tvl >= 50000);

const promisesForTokenBalance = [];
poolInfo.whirlpools.forEach((pool) => {
filteredPools.forEach((pool) => {
promisesForTokenBalance.push(
getTokenBalance(pool.tokenA.mint, pool.address, web3),
);
Expand All @@ -68,7 +70,7 @@ async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
);
});
const results = await Promise.all(promisesForTokenBalance);
poolInfo.whirlpools.forEach((pool) => {
filteredPools.forEach((pool) => {
if (!balances[pool.tokenA.mint]) {
balances[pool.tokenA.mint] = BigNumber(results[0]);
} else {
Expand Down
45 changes: 1 addition & 44 deletions src/web3Provider/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ export class Solana {
detail: `solana - API call encountered an error.`,
endpoint: 'solana.call',
});

throw res.error;
}

log.info({
message: `Response from method ${method}: ${JSON.stringify(
res.result,
)}`,
detail: `solana - API call returned successfully.`,
endpoint: 'solana.call',
});

return res.result;
} catch (e) {
log.error({
Expand All @@ -75,11 +68,6 @@ export class Solana {

async getBlockNumber() {
const res = await this.call('getSlot', []);
log.info({
message: `Fetched block number: ${res}`,
detail: `solana - Fetched block number using getSlot.`,
endpoint: 'solana.getBlockNumber',
});
return res;
}

Expand All @@ -93,11 +81,6 @@ export class Solana {
res = await this.call('getBlockTime', [slot]);

if (res && !res.error) {
log.info({
message: `Found block at slot ${slot} with timestamp: ${res}`,
detail: `solana - Block found successfully.`,
endpoint: 'solana.getBlock',
});
break;
}
slot += 1;
Expand All @@ -118,11 +101,6 @@ class Contract {
constructor(abi, address) {
this.abi = abi;
this.address = address;
log.info({
message: `Contract instance created for address: ${address}`,
detail: `solana - Contract creation logged.`,
endpoint: 'solana.Contract.constructor',
});
}

async call(method, params) {
Expand Down Expand Up @@ -156,14 +134,6 @@ class Contract {
throw res.error;
}

log.info({
message: `Response from method ${method}: ${JSON.stringify(
res.result,
)} for contract ${this.address}`,
detail: `solana - Contract API call returned successfully.`,
endpoint: 'solana.Contract.call',
});

return res.result;
} catch (e) {
log.error({
Expand All @@ -182,11 +152,6 @@ class Contract {
return {
call: async () => {
const res = await this.call('getTokenSupply', [this.address]);
log.info({
message: `Total supply fetched: ${res.value.amount} for contract ${this.address}`,
detail: `solana - Fetched total supply of contract.`,
endpoint: 'solana.Contract.methods.totalSupply.call',
});
return res.value.amount;
},
};
Expand All @@ -213,14 +178,6 @@ class Contract {
}
});

log.info({
message: `Balance fetched for account ${account}: ${balance.toFixed()} for contract ${
this.address
}`,
detail: `solana - Balance fetched successfully.`,
endpoint: 'solana.Contract.methods.balanceOf.call',
});

return balance.toFixed();
},
};
Expand Down

0 comments on commit e9bb767

Please sign in to comment.