diff --git a/scripts/gas-refund-program/staking/2.0/migrations.ts b/scripts/gas-refund-program/staking/2.0/migrations.ts index f9338a67..8e27d852 100644 --- a/scripts/gas-refund-program/staking/2.0/migrations.ts +++ b/scripts/gas-refund-program/staking/2.0/migrations.ts @@ -4,7 +4,6 @@ import { sePSPMigrations, SePSPMigrationsData, } from '../../../../src/models/sePSPMigrations'; -import { ExtendedCovalentGasRefundTransaction } from '../../types'; import ERC20StateTracker, { Transfer } from './ERC20StateTracker'; import { GRP_V2_SUPPORTED_CHAINS_STAKING } from '../../../../src/lib/gas-refund/gas-refund'; @@ -15,6 +14,7 @@ import { grp2GlobalConfig, } from '../../../../src/lib/gas-refund/config'; import { CHAIN_ID_MAINNET } from '../../../../src/lib/constants'; +import { ExtendedCovalentGasRefundTransaction } from '../../../../src/types-from-scripts'; const transform = ( events: Transfer[], @@ -77,35 +77,36 @@ export async function getMigrationsTxs({ }, }); - const migrationsTxs: ExtendedCovalentGasRefundTransaction[] = await Promise.all( - allMigrationsEpoch.map(async v => { - const { account, chainId, blockNumber, txHash } = v; - - const tx = await getTransaction({ - chainId, - txHash, - }); - - const txTimestamp = Math.floor( - new Date(tx.block_signed_at).getTime() / 1000, - ).toString(); - - assert( - blockNumber === tx.block_height, - 'block numbers for tx should match', - ); - - return { - txHash, - txOrigin: account, - txGasPrice: tx.gas_price.toString(), // legacy - verify unit - blockNumber: blockNumber.toString(), // legacy - timestamp: txTimestamp, - txGasUsed: tx.gas_spent.toString(), // legacy - contract: MIGRATION_SEPSP2_100_PERCENT_KEY, - }; - }), - ); + const migrationsTxs: ExtendedCovalentGasRefundTransaction[] = + await Promise.all( + allMigrationsEpoch.map(async v => { + const { account, chainId, blockNumber, txHash } = v; + + const tx = await getTransaction({ + chainId, + txHash, + }); + + const txTimestamp = Math.floor( + new Date(tx.block_signed_at).getTime() / 1000, + ).toString(); + + assert( + blockNumber === tx.block_height, + 'block numbers for tx should match', + ); + + return { + txHash, + txOrigin: account, + txGasPrice: tx.gas_price.toString(), // legacy - verify unit + blockNumber: blockNumber.toString(), // legacy + timestamp: txTimestamp, + txGasUsed: tx.gas_spent.toString(), // legacy + contract: MIGRATION_SEPSP2_100_PERCENT_KEY, + }; + }), + ); return migrationsTxs.filter( t => +t.timestamp >= startTimestamp && +t.timestamp <= endTimestamp, diff --git a/scripts/gas-refund-program/token-pricing/coingecko.ts b/scripts/gas-refund-program/token-pricing/coingecko.ts index c202073b..27d69dc6 100644 --- a/scripts/gas-refund-program/token-pricing/coingecko.ts +++ b/scripts/gas-refund-program/token-pricing/coingecko.ts @@ -5,10 +5,10 @@ import { CHAIN_ID_OPTIMISM, CHAIN_ID_POLYGON, } from '../../../src/lib/constants'; -import { HistoricalPrice } from '../types'; import { constructHttpClient } from '../../../src/lib/utils/http-client'; import { startOfDayMilliSec } from '../../../src/lib/utils/helpers'; import { assert } from 'ts-essentials'; +import { HistoricalPrice } from '../../../src/types-from-scripts'; export const coingeckoClient = constructHttpClient({ axiosConfig: { diff --git a/scripts/gas-refund-program/transactions-indexing/fetchRefundableTransactions.ts b/scripts/gas-refund-program/transactions-indexing/fetchRefundableTransactions.ts index 04174c7c..ccbec17d 100644 --- a/scripts/gas-refund-program/transactions-indexing/fetchRefundableTransactions.ts +++ b/scripts/gas-refund-program/transactions-indexing/fetchRefundableTransactions.ts @@ -24,7 +24,7 @@ import { MIGRATION_SEPSP2_100_PERCENT_KEY } from '../staking/2.0/utils'; import { isTruthy } from '../../../src/lib/utils'; import { AUGUSTUS_SWAPPERS_V6_OMNICHAIN } from '../../../src/lib/constants'; import { fetchParaswapV6StakersTransactions } from '../../../src/lib/paraswap-v6-stakers-transactions'; -import { ExtendedCovalentGasRefundTransaction } from '../types'; +import { ExtendedCovalentGasRefundTransaction } from '../../../src/types-from-scripts'; // empirically set to maximise on processing time without penalising memory and fetching constraigns const SLICE_DURATION = 4 * ONE_HOUR_SEC; diff --git a/scripts/gas-refund-program/transactions-indexing/transaction-resolver.ts b/scripts/gas-refund-program/transactions-indexing/transaction-resolver.ts index 94df6989..219f5c74 100644 --- a/scripts/gas-refund-program/transactions-indexing/transaction-resolver.ts +++ b/scripts/gas-refund-program/transactions-indexing/transaction-resolver.ts @@ -14,7 +14,6 @@ import { SPSPAddresses } from '../../../src/lib/staking/spsp-helper'; import { covalentGetTXsForContractV3 } from './txs-covalent'; import StakesTracker from '../staking/stakes-tracker'; import { getSuccessfulSwaps } from './swaps-subgraph'; -import { ExtendedCovalentGasRefundTransaction } from '../types'; import { GasRefundConsiderContractTXsStartEpoch, GasRefundV2EpochFlip, @@ -34,6 +33,7 @@ import { MIGRATION_SEPSP2_100_PERCENT_KEY } from '../staking/2.0/utils'; import { grp2ConfigByChain } from '../../../src/lib/gas-refund/config'; import { assert } from 'ts-essentials'; import { fetchTxGasUsed } from '../../../src/lib/fetch-tx-gas-used'; +import { ExtendedCovalentGasRefundTransaction } from '../../../src/types-from-scripts'; type GetAllTXsInput = { startTimestamp: number; diff --git a/scripts/gas-refund-program/transactions-indexing/txs-covalent.ts b/scripts/gas-refund-program/transactions-indexing/txs-covalent.ts index 42182cac..a345340f 100644 --- a/scripts/gas-refund-program/transactions-indexing/txs-covalent.ts +++ b/scripts/gas-refund-program/transactions-indexing/txs-covalent.ts @@ -4,12 +4,12 @@ import { getBulkTimeBucketTxsWithinInterval, } from '../../../src/lib/utils/covalent'; import { covalentClient } from '../../../src/lib/utils/data-providers-clients'; +import { CHAIN_ID_OPTIMISM } from '../../../src/lib/constants'; import { - CovalentAPI, CovalentTransaction, + CovalentAPI, ExtendedCovalentGasRefundTransaction, -} from '../types'; -import { CHAIN_ID_OPTIMISM } from '../../../src/lib/constants'; +} from '../../../src/types-from-scripts'; interface GetContractTXsByNetworkInput { chainId: number; @@ -109,7 +109,9 @@ export const covalentGetTXsForContractV3 = async ({ endTimestamp, chainId, contract, -}: GetContractTXsByNetworkInput): Promise => { +}: GetContractTXsByNetworkInput): Promise< + ExtendedCovalentGasRefundTransaction[] +> => { assert( contract.toLowerCase() === contract, 'contract address should be lower cased', diff --git a/src/lib/paraswap-v6-stakers-transactions.ts b/src/lib/paraswap-v6-stakers-transactions.ts index f036d2b7..87ff0046 100644 --- a/src/lib/paraswap-v6-stakers-transactions.ts +++ b/src/lib/paraswap-v6-stakers-transactions.ts @@ -1,5 +1,5 @@ import { assert } from 'ts-essentials'; -import type { ExtendedCovalentGasRefundTransaction } from '../../scripts/gas-refund-program/types'; +import { ExtendedCovalentGasRefundTransaction } from '../types-from-scripts'; import axios from 'axios'; import { CHAIN_ID_OPTIMISM } from './constants'; import BigNumber from 'bignumber.js'; diff --git a/scripts/gas-refund-program/types.ts b/src/types-from-scripts.ts similarity index 100% rename from scripts/gas-refund-program/types.ts rename to src/types-from-scripts.ts