New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@generationsoftware/pt-v5-autotasks-library

Package Overview
Dependencies
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@generationsoftware/pt-v5-autotasks-library - npm Package Compare versions

Comparing version 1.4.6 to 1.5.0

2

dist/constants/network.d.ts
export declare const CHAIN_IDS: {
mainnet: number;
optimism: number;
gnosis: number;
base: number;
arbitrum: number;
scroll: number;
gnosisChiado: number;

@@ -7,0 +9,0 @@ baseSepolia: number;

export const CHAIN_IDS = {
mainnet: 1,
optimism: 10,
gnosis: 100,
base: 8453,
arbitrum: 42161,
scroll: 534352,
gnosisChiado: 10200,

@@ -16,4 +18,6 @@ baseSepolia: 84532,

[CHAIN_IDS.optimism]: '10 - Optimism',
[CHAIN_IDS.gnosis]: '100 - Gnosis',
[CHAIN_IDS.base]: '8453 - Base',
[CHAIN_IDS.arbitrum]: '42161 - Arbitrum',
[CHAIN_IDS.scroll]: '534352 - Scroll',
[CHAIN_IDS.gnosisChiado]: '10200 - Gnosis Chiado',

@@ -31,2 +35,4 @@ [CHAIN_IDS.baseSepolia]: '84532 - Base Sepolia',

[CHAIN_IDS.arbitrum]: { decimals: 18, symbol: 'ETH' },
[CHAIN_IDS.scroll]: { decimals: 18, symbol: 'ETH' },
[CHAIN_IDS.gnosis]: { decimals: 18, symbol: 'XDAI' },
[CHAIN_IDS.gnosisChiado]: { decimals: 18, symbol: 'XDAI' },

@@ -33,0 +39,0 @@ [CHAIN_IDS.baseSepolia]: { decimals: 18, symbol: 'ETH' },

24

dist/constants/tokens.d.ts

@@ -12,2 +12,4 @@ export declare const KNOWN_TOKENS: {

LINK: string;
PRZWETH: string;
PRZUSDC: string;
USDCE?: undefined;

@@ -22,4 +24,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -251,2 +251,4 @@ PRZLUSD?: undefined;

LINK?: undefined;
PRZWETH?: undefined;
PRZUSDC?: undefined;
USDCE?: undefined;

@@ -261,4 +263,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -309,2 +309,4 @@ PRZLUSD?: undefined;

LINK?: undefined;
PRZWETH?: undefined;
PRZUSDC?: undefined;
USDCE?: undefined;

@@ -319,4 +321,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -371,2 +371,4 @@ PRZLUSD?: undefined;

LINK?: undefined;
PRZWETH?: undefined;
PRZUSDC?: undefined;
USDCE?: undefined;

@@ -381,4 +383,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -430,2 +430,4 @@ PRZLUSD?: undefined;

LINK?: undefined;
PRZWETH?: undefined;
PRZUSDC?: undefined;
USDCE?: undefined;

@@ -440,4 +442,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -486,2 +486,4 @@ PRZLUSD?: undefined;

OP?: undefined;
PRZWETH?: undefined;
PRZUSDC?: undefined;
USDCE?: undefined;

@@ -496,4 +498,2 @@ SNX?: undefined;

WSTETH?: undefined;
PRZUSDC?: undefined;
PRZWETH?: undefined;
PRZDAI?: undefined;

@@ -500,0 +500,0 @@ PRZLUSD?: undefined;

@@ -13,2 +13,4 @@ import { CHAIN_IDS } from './network.js';

LINK: '0x514910771af9ca656af840dff83e8264ecf986ca',
PRZWETH: '0x3acd377da549010a197b9ed0f271e1f621e4b62e',
PRZUSDC: '0x96fe7b5762bd4405149a9a313473e68a8e870f6c',
},

@@ -146,3 +148,5 @@ [CHAIN_IDS.optimism]: {

export const LIQUIDATION_TOKEN_ALLOW_LIST = {
[CHAIN_IDS.mainnet]: [],
[CHAIN_IDS.mainnet]: [
...Object.values(KNOWN_TOKENS[CHAIN_IDS.mainnet]).map((tokenAddress) => tokenAddress.toLowerCase()),
],
[CHAIN_IDS.optimism]: [

@@ -149,0 +153,0 @@ ...Object.values(KNOWN_TOKENS[CHAIN_IDS.optimism]).map((tokenAddress) => tokenAddress.toLowerCase()),

import nodeFetch from 'node-fetch';
import debug from 'debug';
import { ethers, BigNumber, Contract } from 'ethers';

@@ -10,6 +11,16 @@ import { getPrizePoolInfo, getContract, getSubgraphPrizeVaults, flagClaimedRpc, } from '@generationsoftware/pt-v5-utils-js';

import { ClaimerAbi } from './abis/ClaimerAbi.js';
import { NETWORK_NATIVE_TOKEN_INFO } from './constants/network.js';
import { CHAIN_IDS, NETWORK_NATIVE_TOKEN_INFO } from './constants/network.js';
import { sendPopulatedTx } from './helpers/sendPopulatedTx.js';
const debugClaimer = debug('claimer');
const TOTAL_CLAIM_COUNT_PER_TRANSACTION = 30;
const NUM_CANARY_TIERS = 2;
const GAS_LIMIT = 20_000_000;
const LOWER_GAS_LIMIT_CHAINS = [
CHAIN_IDS.scrollSepolia,
CHAIN_IDS.scroll,
CHAIN_IDS.gnosisChiado,
CHAIN_IDS.gnosis,
];
const LOWER_GAS_LIMIT = 10_000_000;
const LOWER_TOTAL_CLAIM_COUNT_PER_TRANSACTION = 15;
export async function runPrizeClaimer(contracts, config) {

@@ -101,13 +112,24 @@ const { chainId, covalentApiKey, wallet, provider, subgraphUrl } = config;

if (claimPrizesParams.winners.length > 0) {
printSpacer();
console.log(chalk.green(`Execute Claim Transaction for Tier #${tierWords(context, Number(tier))}`));
printSpacer();
const populatedTx = await claimerContract.populateTransaction.claimPrizes(...Object.values(claimPrizesParams));
const gasLimit = 20000000;
const tx = await sendPopulatedTx(provider, wallet, populatedTx, gasLimit);
console.log(chalk.greenBright.bold('Transaction sent! ✔'));
console.log(chalk.blueBright.bold('Transaction hash:', tx.hash));
console.log('Waiting on transaction to be confirmed ...');
await provider.waitForTransaction(tx.hash);
console.log('Tx confirmed !');
const countPerTx = LOWER_GAS_LIMIT_CHAINS.includes(chainId)
? LOWER_TOTAL_CLAIM_COUNT_PER_TRANSACTION
: TOTAL_CLAIM_COUNT_PER_TRANSACTION;
for (let n = 0; n <= claimPrizesParams.winners.length; n += countPerTx) {
const start = n;
const end = n + countPerTx;
const paramsClone = structuredClone(claimPrizesParams);
paramsClone.winners = paramsClone.winners.slice(start, end);
paramsClone.prizeIndices = paramsClone.prizeIndices.slice(start, end);
logClaims(paramsClone);
printSpacer();
printSpacer();
console.log(chalk.green(`Execute Claim Transaction for Tier #${tierWords(context, Number(tier))}, claims ${start + 1} to ${Math.min(end, claimPrizesParams.winners.length)} `));
const populatedTx = await claimerContract.populateTransaction.claimPrizes(...Object.values(paramsClone));
const gasLimit = LOWER_GAS_LIMIT_CHAINS.includes(chainId) ? LOWER_GAS_LIMIT : GAS_LIMIT;
const tx = await sendPopulatedTx(provider, wallet, populatedTx, gasLimit);
console.log(chalk.greenBright.bold('Transaction sent! ✔'));
console.log(chalk.blueBright.bold('Transaction hash:', tx.hash));
console.log(chalk.dim('Waiting on transaction to be confirmed ...'));
await provider.waitForTransaction(tx.hash);
console.log(chalk.dim('Transaction confirmed !'));
}
}

@@ -144,3 +166,3 @@ else {

const calculateProfit = async (provider, vault, tier, claimerContract, groupedClaims, tierRemainingPrizeCounts, context, config, rewardRecipient) => {
const { chainId, covalentApiKey, minProfitThresholdUsd } = config;
const { chainId, covalentApiKey } = config;
printSpacer();

@@ -151,3 +173,3 @@ const nativeTokenMarketRateUsd = await getNativeTokenMarketRateUsd(chainId, covalentApiKey);

const gasCost = await getGasCost(provider, chainId, vault, tier, claimerContract, groupedClaims, rewardRecipient, nativeTokenMarketRateUsd, '100');
const { claimCount, claimRewardUsd, totalCostUsd, minVrgdaFeePerClaim } = await getClaimInfo(context, provider, claimerContract, tier, groupedClaims, tierRemainingPrizeCounts, gasCost, minProfitThresholdUsd);
const { claimCount, claimRewardUsd, totalCostUsd, minVrgdaFeePerClaim } = await getClaimInfo(context, provider, claimerContract, tier, groupedClaims, tierRemainingPrizeCounts, gasCost, config);
const claimsSlice = groupedClaims.slice(0, claimCount);

@@ -161,7 +183,7 @@ const claimPrizesParams = buildParams(vault, tier, claimsSlice, rewardRecipient, minVrgdaFeePerClaim);

console.log(chalk.greenBright(`$${roundTwoDecimalPlaces(netProfitUsd)} = ($${roundTwoDecimalPlaces(claimRewardUsd)} - $${roundTwoDecimalPlaces(totalCostUsd)})`), chalk.dim(`$${netProfitUsd} = ($${claimRewardUsd} - $${totalCostUsd})`));
printSpacer();
const profitable = claimCount >= 1;
if (profitable) {
console.log(chalk.yellow(`Submitting transaction to claim ${claimCount} prize(s):`));
logClaims(claimsSlice);
printSpacer();
printSpacer();
console.log(chalk.yellow(`Submitting transaction(s) to claim ${claimCount} prize(s):`));
}

@@ -177,7 +199,10 @@ else {

};
const logClaims = (claims) => {
printSpacer();
claims.forEach((claim) => console.log(`${claim.vault}-${claim.winner}-${claim.tier}-${claim.prizeIndex}`));
printSpacer();
printSpacer();
const logClaims = (params) => {
debugClaimer('claimPrizesParamsClone');
debugClaimer(params);
for (let x = 0; x < params.winners.length; x++) {
const winner = params.winners[x];
const prizeIndex = params.prizeIndices[x];
debugClaimer(`${params.vault}-${winner}-${params.tier}-${prizeIndex}`);
}
};

@@ -277,3 +302,4 @@ const getContext = async (chainId, contracts, prizePool, provider, covalentApiKey) => {

};
const getClaimInfo = async (context, provider, claimerContract, tier, claims, tierRemainingPrizeCounts, gasCost, minProfitThresholdUsd) => {
const getClaimInfo = async (context, provider, claimerContract, tier, claims, tierRemainingPrizeCounts, gasCost, config) => {
const { chainId, minProfitThresholdUsd } = config;
let claimCount = 0;

@@ -320,5 +346,3 @@ let claimReward = BigNumber.from(0);

claimRewardUsd = nextClaimRewardUsd;
if (netProfitUsd > previousNetProfitUsd &&
netProfitUsd > minProfitThresholdUsd &&
numClaims < TOTAL_CLAIM_COUNT_PER_TRANSACTION) {
if (netProfitUsd > previousNetProfitUsd && netProfitUsd > minProfitThresholdUsd) {
tierRemainingPrizeCounts[tier.toString()]--;

@@ -325,0 +349,0 @@ const claimRewardUnpacked = claimReward[0] ? claimReward[0] : claimReward;

{
"name": "@generationsoftware/pt-v5-autotasks-library",
"version": "1.4.6",
"version": "1.5.0",
"description": "Library of shared utils to run PoolTogether v5 hyperstructure autotasks.",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc