Skip to content

Commit

Permalink
Merge pull request #118 from paraswap/fix/deps
Browse files Browse the repository at this point in the history
avoid even dep on types
  • Loading branch information
alexshchur authored Jun 26, 2024
2 parents fcab8ae + d220536 commit 6fe5cb1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 38 deletions.
61 changes: 31 additions & 30 deletions scripts/gas-refund-program/staking/2.0/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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[],
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/gas-refund-program/token-pricing/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions scripts/gas-refund-program/transactions-indexing/txs-covalent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,7 +109,9 @@ export const covalentGetTXsForContractV3 = async ({
endTimestamp,
chainId,
contract,
}: GetContractTXsByNetworkInput): Promise<ExtendedCovalentGasRefundTransaction[]> => {
}: GetContractTXsByNetworkInput): Promise<
ExtendedCovalentGasRefundTransaction[]
> => {
assert(
contract.toLowerCase() === contract,
'contract address should be lower cased',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/paraswap-v6-stakers-transactions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
File renamed without changes.

0 comments on commit 6fe5cb1

Please sign in to comment.