@octaflowlabs/onchain-sdk 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,10 +33,10 @@ exports.NETWORKS_REGISTRY = [
33
33
  id: 'polygon-mainnet',
34
34
  name: 'polygon-mainnet',
35
35
  nameForDisplay: 'Polygon Mainnet',
36
- iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
37
36
  chainId: 137,
38
37
  rpcUrl: 'https://polygon.publicnode.com',
39
38
  explorerUrl: 'https://polygonscan.com',
39
+ iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
40
40
  symbol: 'POL',
41
41
  failoverRpcUrl: 'https://polygon.llamarpc.com',
42
42
  blockTime: 2,
@@ -53,6 +53,161 @@ exports.NETWORKS_REGISTRY = [
53
53
  failoverRpcUrl: 'https://arb.llamarpc.com',
54
54
  blockTime: 1,
55
55
  },
56
+ {
57
+ id: 'optimism-mainnet',
58
+ name: 'op-mainnet',
59
+ nameForDisplay: 'Optimism Mainnet',
60
+ chainId: 10,
61
+ rpcUrl: 'https://mainnet.optimism.io',
62
+ explorerUrl: 'https://optimistic.etherscan.io',
63
+ iconUrl: 'https://assets.coingecko.com/coins/images/25244/large/Optimism.png',
64
+ symbol: 'ETH',
65
+ failoverRpcUrl: 'https://optimism.llamarpc.com',
66
+ blockTime: 2,
67
+ },
68
+ {
69
+ id: 'base-mainnet',
70
+ name: 'base-mainnet',
71
+ nameForDisplay: 'Base Mainnet',
72
+ chainId: 8453,
73
+ rpcUrl: 'https://mainnet.base.org',
74
+ explorerUrl: 'https://basescan.org',
75
+ iconUrl: 'https://assets.coingecko.com/coins/images/32480/large/base.png',
76
+ symbol: 'ETH',
77
+ failoverRpcUrl: 'https://base.llamarpc.com',
78
+ blockTime: 2,
79
+ },
80
+ {
81
+ id: 'avalanche-mainnet',
82
+ name: 'avax-mainnet',
83
+ nameForDisplay: 'Avalanche C-Chain',
84
+ chainId: 43114,
85
+ rpcUrl: 'https://api.avax.network/ext/bc/C/rpc',
86
+ explorerUrl: 'https://snowtrace.io',
87
+ iconUrl: 'https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png',
88
+ symbol: 'AVAX',
89
+ failoverRpcUrl: 'https://avalanche.llamarpc.com',
90
+ blockTime: 2,
91
+ },
92
+ {
93
+ id: 'hyperevm-mainnet',
94
+ name: 'hyperevm-mainnet',
95
+ nameForDisplay: 'HyperEVM',
96
+ chainId: 999,
97
+ rpcUrl: 'https://hyperliquid-mainnet.g.alchemy.com/v2/YOUR_KEY',
98
+ explorerUrl: 'https://purrsec.com',
99
+ iconUrl: 'https://assets.coingecko.com/coins/images/52510/large/hyperliquid.png',
100
+ symbol: 'HYPE',
101
+ failoverRpcUrl: 'https://rpc.hyperliquid.xyz/evm',
102
+ blockTime: 1,
103
+ },
104
+ {
105
+ id: 'unichain-mainnet',
106
+ name: 'unichain-mainnet',
107
+ nameForDisplay: 'Unichain Mainnet',
108
+ chainId: 130,
109
+ rpcUrl: 'https://mainnet.unichain.org',
110
+ explorerUrl: 'https://uniscan.xyz',
111
+ iconUrl: 'https://assets.coingecko.com/coins/images/25244/large/Optimism.png',
112
+ symbol: 'ETH',
113
+ failoverRpcUrl: 'https://unichain.llamarpc.com',
114
+ blockTime: 1,
115
+ },
116
+ {
117
+ id: 'gnosis-mainnet',
118
+ name: 'gnosis-mainnet',
119
+ nameForDisplay: 'Gnosis Chain',
120
+ chainId: 100,
121
+ rpcUrl: 'https://rpc.gnosischain.com',
122
+ explorerUrl: 'https://gnosisscan.io',
123
+ iconUrl: 'https://assets.coingecko.com/coins/images/662/large/logo_square_simple_300px.png',
124
+ symbol: 'xDAI',
125
+ failoverRpcUrl: 'https://gnosis.llamarpc.com',
126
+ blockTime: 5,
127
+ },
128
+ {
129
+ id: 'mantle-mainnet',
130
+ name: 'mantle-mainnet',
131
+ nameForDisplay: 'Mantle Mainnet',
132
+ chainId: 5000,
133
+ rpcUrl: 'https://rpc.mantle.xyz',
134
+ explorerUrl: 'https://mantlescan.xyz',
135
+ iconUrl: 'https://assets.coingecko.com/coins/images/30980/large/token-logo.png',
136
+ symbol: 'MNT',
137
+ failoverRpcUrl: 'https://mantle.llamarpc.com',
138
+ blockTime: 2,
139
+ },
140
+ {
141
+ id: 'celo-mainnet',
142
+ name: 'celo-mainnet',
143
+ nameForDisplay: 'Celo Mainnet',
144
+ chainId: 42220,
145
+ rpcUrl: 'https://forno.celo.org',
146
+ explorerUrl: 'https://celoscan.io',
147
+ iconUrl: 'https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg',
148
+ symbol: 'CELO',
149
+ failoverRpcUrl: 'https://celo.llamarpc.com',
150
+ blockTime: 5,
151
+ },
152
+ {
153
+ id: 'blast-mainnet',
154
+ name: 'blast-mainnet',
155
+ nameForDisplay: 'Blast Mainnet',
156
+ chainId: 81457,
157
+ rpcUrl: 'https://rpc.blast.io',
158
+ explorerUrl: 'https://blastscan.io',
159
+ iconUrl: 'https://assets.coingecko.com/coins/images/35494/large/Blast.jpg',
160
+ symbol: 'ETH',
161
+ failoverRpcUrl: 'https://blast.llamarpc.com',
162
+ blockTime: 2,
163
+ },
164
+ {
165
+ id: 'berachain-mainnet',
166
+ name: 'berachain-mainnet',
167
+ nameForDisplay: 'Berachain Mainnet',
168
+ chainId: 80094,
169
+ rpcUrl: 'https://rpc.berachain.com',
170
+ explorerUrl: 'https://berascan.com',
171
+ iconUrl: 'https://assets.coingecko.com/coins/images/36417/large/bera.png',
172
+ symbol: 'BERA',
173
+ failoverRpcUrl: 'https://berachain.llamarpc.com',
174
+ blockTime: 2,
175
+ },
176
+ {
177
+ id: 'linea-mainnet',
178
+ name: 'linea-mainnet',
179
+ nameForDisplay: 'Linea Mainnet',
180
+ chainId: 59144,
181
+ rpcUrl: 'https://rpc.linea.build',
182
+ explorerUrl: 'https://lineascan.build',
183
+ iconUrl: 'https://assets.coingecko.com/coins/images/32234/large/linea.png',
184
+ symbol: 'ETH',
185
+ failoverRpcUrl: 'https://linea.llamarpc.com',
186
+ blockTime: 2,
187
+ },
188
+ {
189
+ id: 'scroll-mainnet',
190
+ name: 'scroll-mainnet',
191
+ nameForDisplay: 'Scroll Mainnet',
192
+ chainId: 534352,
193
+ rpcUrl: 'https://rpc.scroll.io',
194
+ explorerUrl: 'https://scrollscan.com',
195
+ iconUrl: 'https://assets.coingecko.com/coins/images/32760/large/scroll.png',
196
+ symbol: 'ETH',
197
+ failoverRpcUrl: 'https://scroll.llamarpc.com',
198
+ blockTime: 3,
199
+ },
200
+ {
201
+ id: 'plasma-mainnet',
202
+ name: 'plasma-mainnet',
203
+ nameForDisplay: 'Plasma Mainnet',
204
+ chainId: 9745,
205
+ rpcUrl: 'https://rpc.plasma.to',
206
+ explorerUrl: 'https://plasmascan.to',
207
+ iconUrl: '',
208
+ symbol: 'XPL',
209
+ blockTime: 1,
210
+ },
56
211
  ],
57
212
  },
58
213
  {
@@ -0,0 +1,13 @@
1
+ export type StablecoinSymbol = 'USDC' | 'USDT' | 'OSC';
2
+ export interface StablecoinContractData {
3
+ chainId: number;
4
+ symbol: StablecoinSymbol;
5
+ name: string;
6
+ address: string;
7
+ decimals: number;
8
+ }
9
+ export type StablecoinContractsByChainId = Readonly<Record<number, readonly StablecoinContractData[]>>;
10
+ export declare const STABLECOIN_CONTRACTS_BY_CHAIN_ID: StablecoinContractsByChainId;
11
+ export declare const getStablecoinContractsByChainId: (chainId: number | null | undefined) => readonly StablecoinContractData[];
12
+ export declare const getStablecoinContractBySymbolAndChainId: (symbol: StablecoinSymbol, chainId: number | null | undefined) => StablecoinContractData | null;
13
+ export declare const isAllowedStablecoinContract: (chainId: number | null | undefined, contractAddress: string | null | undefined) => boolean;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAllowedStablecoinContract = exports.getStablecoinContractBySymbolAndChainId = exports.getStablecoinContractsByChainId = exports.STABLECOIN_CONTRACTS_BY_CHAIN_ID = void 0;
4
+ /** local imports */
5
+ const normalizeAddress_1 = require("../utils/normalizeAddress");
6
+ exports.STABLECOIN_CONTRACTS_BY_CHAIN_ID = {
7
+ 1: [
8
+ {
9
+ chainId: 1,
10
+ symbol: 'USDC',
11
+ name: 'USD Coin',
12
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
13
+ decimals: 6,
14
+ },
15
+ {
16
+ chainId: 1,
17
+ symbol: 'USDT',
18
+ name: 'Tether USD',
19
+ address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
20
+ decimals: 6,
21
+ },
22
+ ],
23
+ 56: [
24
+ {
25
+ chainId: 56,
26
+ symbol: 'USDC',
27
+ name: 'USD Coin',
28
+ address: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
29
+ decimals: 18,
30
+ },
31
+ {
32
+ chainId: 56,
33
+ symbol: 'USDT',
34
+ name: 'Tether USD',
35
+ address: '0x55d398326f99059ff775485246999027b3197955',
36
+ decimals: 18,
37
+ },
38
+ ],
39
+ 137: [
40
+ {
41
+ chainId: 137,
42
+ symbol: 'USDC',
43
+ name: 'USD Coin Bridged',
44
+ address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
45
+ decimals: 6,
46
+ },
47
+ {
48
+ chainId: 137,
49
+ symbol: 'USDC',
50
+ name: 'USD Coin',
51
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
52
+ decimals: 6,
53
+ },
54
+ {
55
+ chainId: 137,
56
+ symbol: 'USDT',
57
+ name: 'Tether USD',
58
+ address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
59
+ decimals: 6,
60
+ },
61
+ ],
62
+ 11155111: [
63
+ {
64
+ chainId: 11155111,
65
+ symbol: 'USDC',
66
+ name: 'Sepolia USDC',
67
+ address: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
68
+ decimals: 6,
69
+ },
70
+ {
71
+ chainId: 11155111,
72
+ symbol: 'OSC',
73
+ name: 'OSC Test Stablecoin',
74
+ address: '0x4357555de1c8ed60218dd42b0b4f404e31b6d744',
75
+ decimals: 6,
76
+ },
77
+ ],
78
+ };
79
+ const getStablecoinContractsByChainId = (chainId) => {
80
+ if (chainId == null)
81
+ return [];
82
+ return exports.STABLECOIN_CONTRACTS_BY_CHAIN_ID[chainId] || [];
83
+ };
84
+ exports.getStablecoinContractsByChainId = getStablecoinContractsByChainId;
85
+ const getStablecoinContractBySymbolAndChainId = (symbol, chainId) => {
86
+ const contracts = (0, exports.getStablecoinContractsByChainId)(chainId);
87
+ return contracts.find((contract) => contract.symbol === symbol) || null;
88
+ };
89
+ exports.getStablecoinContractBySymbolAndChainId = getStablecoinContractBySymbolAndChainId;
90
+ const isAllowedStablecoinContract = (chainId, contractAddress) => {
91
+ if (chainId == null)
92
+ return false;
93
+ const normalizedAddress = (0, normalizeAddress_1.normalizeEvmAddress)(contractAddress);
94
+ if (!normalizedAddress)
95
+ return false;
96
+ const allowedContracts = (0, exports.getStablecoinContractsByChainId)(chainId);
97
+ if (!allowedContracts.length)
98
+ return false;
99
+ return allowedContracts.some((contract) => contract.address === normalizedAddress);
100
+ };
101
+ exports.isAllowedStablecoinContract = isAllowedStablecoinContract;
@@ -5,6 +5,7 @@ export { ERC20_TOKEN_CONTRACT_ABI };
5
5
  export { GAS_LIMIT_PER_TX_TYPE, MULTICALL3_ADDRESS } from './constants/constants';
6
6
  export { NetworkField, NetworkRegistry, NETWORKS_REGISTRY } from './constants/NETWORKS_REGISTRY';
7
7
  export { BASIC_TOKENS_BY_CHAIN, BasicTokenData, BasicTokenSymbol, ChainTokenDataMap, } from './constants/BASIC_TOKENS_REGISTRY';
8
+ export { STABLECOIN_CONTRACTS_BY_CHAIN_ID, getStablecoinContractBySymbolAndChainId, getStablecoinContractsByChainId, isAllowedStablecoinContract, StablecoinContractData, StablecoinContractsByChainId, StablecoinSymbol, } from './constants/STABLECOINS_REGISTRY';
8
9
  /** basic blockchain exports */
9
10
  export { buildBaseUnsignedTransferTx, buildMaxNativeTransferTx, buildUnsignedTransferTx, } from './blockchain/buildUnsignedTransferTx';
10
11
  export { broadcastTransaction } from './blockchain/broadcastTransaction';
@@ -26,8 +27,10 @@ import NATIVE_TOKENS from './utils/tokens';
26
27
  export { NATIVE_TOKENS };
27
28
  export { formattedAmountForDisplay, parsedAmount } from './utils/formatAmount';
28
29
  export { handleErrorMessages, errorMessagesForBroadcast, errorMessagesForGasLimitEstimation, } from './utils/handleErrorMessages';
29
- export { normalizeAddress } from './utils/normalizeAddress';
30
+ export { normalizeAddress, normalizeEvmAddress } from './utils/normalizeAddress';
30
31
  export { toGwei, tryParseGweiToWei, parseGasLimit } from './utils/parseGasFees';
31
32
  export { getFeePresets, calcReserve, estimateSeconds, getBlockTime, BLOCK_TIME_BY_CHAIN, } from './utils/feePresets';
33
+ /** webhook exports */
34
+ export { extractPoolInboundStablecoinEvents } from './webhooks/alchemyAddressActivity';
32
35
  /** types exports */
33
36
  export { BroadcastTransactionOptions, BuildMaxNativeTransferTxOptions, BuildUnsignedTransferTxOptions, EstimateGasLimitFromProviderProps, GasEstimateResult, TxStatusOptions, BuildBaseUnsignedTransferTxParams, TxStatusResponse, EstimateTransactionOptions, EstimateTransactionResult, PrepareTransactionParams, PrepareTransactionResult, FormatAmountOptions, TransactionRequest, GetBalanceParams, GetBalancesParams, GetBalancesChainRequest, GetBalanceResult, ChainBalances, TokenBalance, ChainGroup, FeePreset, FeePresetLabel, FeeEstimateSeconds, ResolvedFees, EIP1559Fees, LegacyFees, FeeModel, FeeHistoryData, FeeDataInput, } from './types/common';
package/dist/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BLOCK_TIME_BY_CHAIN = exports.getBlockTime = exports.estimateSeconds = exports.calcReserve = exports.getFeePresets = exports.parseGasLimit = exports.tryParseGweiToWei = exports.toGwei = exports.normalizeAddress = exports.errorMessagesForGasLimitEstimation = exports.errorMessagesForBroadcast = exports.handleErrorMessages = exports.parsedAmount = exports.formattedAmountForDisplay = exports.NATIVE_TOKENS = exports.transformBigInt = exports.getShortenData = exports.getShortenTransactionHashOrAddress = exports.signTransaction = exports.signMessage = exports.createWallet = exports.EvmWalletService = exports.fetchFeeSnapshot = exports.prepareTransaction = exports.estimateTransaction = exports.getBalances = exports.getBalance = exports.txStatus = exports.getProvider = exports.estimateGasLimitFromProvider = exports.broadcastTransaction = exports.buildUnsignedTransferTx = exports.buildMaxNativeTransferTx = exports.buildBaseUnsignedTransferTx = exports.BASIC_TOKENS_BY_CHAIN = exports.NETWORKS_REGISTRY = exports.MULTICALL3_ADDRESS = exports.GAS_LIMIT_PER_TX_TYPE = exports.ERC20_TOKEN_CONTRACT_ABI = void 0;
6
+ exports.extractPoolInboundStablecoinEvents = exports.BLOCK_TIME_BY_CHAIN = exports.getBlockTime = exports.estimateSeconds = exports.calcReserve = exports.getFeePresets = exports.parseGasLimit = exports.tryParseGweiToWei = exports.toGwei = exports.normalizeEvmAddress = exports.normalizeAddress = exports.errorMessagesForGasLimitEstimation = exports.errorMessagesForBroadcast = exports.handleErrorMessages = exports.parsedAmount = exports.formattedAmountForDisplay = exports.NATIVE_TOKENS = exports.transformBigInt = exports.getShortenData = exports.getShortenTransactionHashOrAddress = exports.signTransaction = exports.signMessage = exports.createWallet = exports.EvmWalletService = exports.fetchFeeSnapshot = exports.prepareTransaction = exports.estimateTransaction = exports.getBalances = exports.getBalance = exports.txStatus = exports.getProvider = exports.estimateGasLimitFromProvider = exports.broadcastTransaction = exports.buildUnsignedTransferTx = exports.buildMaxNativeTransferTx = exports.buildBaseUnsignedTransferTx = exports.isAllowedStablecoinContract = exports.getStablecoinContractsByChainId = exports.getStablecoinContractBySymbolAndChainId = exports.STABLECOIN_CONTRACTS_BY_CHAIN_ID = exports.BASIC_TOKENS_BY_CHAIN = exports.NETWORKS_REGISTRY = exports.MULTICALL3_ADDRESS = exports.GAS_LIMIT_PER_TX_TYPE = exports.ERC20_TOKEN_CONTRACT_ABI = void 0;
7
7
  /** ABIs exports */
8
8
  const ERC20_TOKEN_CONTRACT_ABI_1 = __importDefault(require("./ABIs/ERC20_TOKEN_CONTRACT_ABI"));
9
9
  exports.ERC20_TOKEN_CONTRACT_ABI = ERC20_TOKEN_CONTRACT_ABI_1.default;
@@ -15,6 +15,11 @@ var NETWORKS_REGISTRY_1 = require("./constants/NETWORKS_REGISTRY");
15
15
  Object.defineProperty(exports, "NETWORKS_REGISTRY", { enumerable: true, get: function () { return NETWORKS_REGISTRY_1.NETWORKS_REGISTRY; } });
16
16
  var BASIC_TOKENS_REGISTRY_1 = require("./constants/BASIC_TOKENS_REGISTRY");
17
17
  Object.defineProperty(exports, "BASIC_TOKENS_BY_CHAIN", { enumerable: true, get: function () { return BASIC_TOKENS_REGISTRY_1.BASIC_TOKENS_BY_CHAIN; } });
18
+ var STABLECOINS_REGISTRY_1 = require("./constants/STABLECOINS_REGISTRY");
19
+ Object.defineProperty(exports, "STABLECOIN_CONTRACTS_BY_CHAIN_ID", { enumerable: true, get: function () { return STABLECOINS_REGISTRY_1.STABLECOIN_CONTRACTS_BY_CHAIN_ID; } });
20
+ Object.defineProperty(exports, "getStablecoinContractBySymbolAndChainId", { enumerable: true, get: function () { return STABLECOINS_REGISTRY_1.getStablecoinContractBySymbolAndChainId; } });
21
+ Object.defineProperty(exports, "getStablecoinContractsByChainId", { enumerable: true, get: function () { return STABLECOINS_REGISTRY_1.getStablecoinContractsByChainId; } });
22
+ Object.defineProperty(exports, "isAllowedStablecoinContract", { enumerable: true, get: function () { return STABLECOINS_REGISTRY_1.isAllowedStablecoinContract; } });
18
23
  /** basic blockchain exports */
19
24
  var buildUnsignedTransferTx_1 = require("./blockchain/buildUnsignedTransferTx");
20
25
  Object.defineProperty(exports, "buildBaseUnsignedTransferTx", { enumerable: true, get: function () { return buildUnsignedTransferTx_1.buildBaseUnsignedTransferTx; } });
@@ -61,6 +66,7 @@ Object.defineProperty(exports, "errorMessagesForBroadcast", { enumerable: true,
61
66
  Object.defineProperty(exports, "errorMessagesForGasLimitEstimation", { enumerable: true, get: function () { return handleErrorMessages_1.errorMessagesForGasLimitEstimation; } });
62
67
  var normalizeAddress_1 = require("./utils/normalizeAddress");
63
68
  Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return normalizeAddress_1.normalizeAddress; } });
69
+ Object.defineProperty(exports, "normalizeEvmAddress", { enumerable: true, get: function () { return normalizeAddress_1.normalizeEvmAddress; } });
64
70
  var parseGasFees_1 = require("./utils/parseGasFees");
65
71
  Object.defineProperty(exports, "toGwei", { enumerable: true, get: function () { return parseGasFees_1.toGwei; } });
66
72
  Object.defineProperty(exports, "tryParseGweiToWei", { enumerable: true, get: function () { return parseGasFees_1.tryParseGweiToWei; } });
@@ -71,3 +77,6 @@ Object.defineProperty(exports, "calcReserve", { enumerable: true, get: function
71
77
  Object.defineProperty(exports, "estimateSeconds", { enumerable: true, get: function () { return feePresets_1.estimateSeconds; } });
72
78
  Object.defineProperty(exports, "getBlockTime", { enumerable: true, get: function () { return feePresets_1.getBlockTime; } });
73
79
  Object.defineProperty(exports, "BLOCK_TIME_BY_CHAIN", { enumerable: true, get: function () { return feePresets_1.BLOCK_TIME_BY_CHAIN; } });
80
+ /** webhook exports */
81
+ var alchemyAddressActivity_1 = require("./webhooks/alchemyAddressActivity");
82
+ Object.defineProperty(exports, "extractPoolInboundStablecoinEvents", { enumerable: true, get: function () { return alchemyAddressActivity_1.extractPoolInboundStablecoinEvents; } });
@@ -0,0 +1,7 @@
1
+ export interface TransactionActivityDedupeInput {
2
+ hash?: string | null;
3
+ log?: {
4
+ logIndex?: string | null;
5
+ } | null;
6
+ }
7
+ export declare const getTransactionActivityDedupeKey: (activity: TransactionActivityDedupeInput) => string | null;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTransactionActivityDedupeKey = void 0;
4
+ const getTransactionActivityDedupeKey = (activity) => {
5
+ const hash = activity.hash?.trim();
6
+ if (!hash)
7
+ return null;
8
+ const logIndex = activity.log?.logIndex?.trim();
9
+ return logIndex ? `${hash}:${logIndex}` : hash;
10
+ };
11
+ exports.getTransactionActivityDedupeKey = getTransactionActivityDedupeKey;
@@ -1 +1,2 @@
1
1
  export declare const normalizeAddress: (address: string) => string;
2
+ export declare const normalizeEvmAddress: (address: string | null | undefined) => string | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeAddress = void 0;
3
+ exports.normalizeEvmAddress = exports.normalizeAddress = void 0;
4
4
  /** npm imports */
5
5
  const ethers_1 = require("ethers");
6
6
  const normalizeAddress = (address) => {
@@ -13,3 +13,14 @@ const normalizeAddress = (address) => {
13
13
  }
14
14
  };
15
15
  exports.normalizeAddress = normalizeAddress;
16
+ const normalizeEvmAddress = (address) => {
17
+ if (!address || typeof address !== 'string')
18
+ return null;
19
+ try {
20
+ return (0, exports.normalizeAddress)(address.trim()).toLowerCase();
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ };
26
+ exports.normalizeEvmAddress = normalizeEvmAddress;
@@ -0,0 +1,39 @@
1
+ export interface AlchemyAddressActivity {
2
+ category?: string;
3
+ asset?: string;
4
+ value?: number | null;
5
+ fromAddress?: string | null;
6
+ toAddress?: string | null;
7
+ hash?: string | null;
8
+ erc721TokenId?: string | number | null;
9
+ rawContract?: {
10
+ address?: string | null;
11
+ } | null;
12
+ log?: {
13
+ removed?: boolean;
14
+ logIndex?: string | null;
15
+ } | null;
16
+ }
17
+ export interface AlchemyAddressActivityPayload {
18
+ id?: string;
19
+ webhookId?: string;
20
+ type?: string;
21
+ event?: {
22
+ network?: string;
23
+ activity?: AlchemyAddressActivity[];
24
+ };
25
+ }
26
+ export interface PoolInboundStablecoinEvent {
27
+ webhookDeliveryId?: string;
28
+ webhookId?: string;
29
+ alchemyNetwork: string;
30
+ chainId: number | null;
31
+ txHash: string;
32
+ fromAddress: string;
33
+ toAddress: string;
34
+ amount: number;
35
+ asset: string;
36
+ tokenContractAddress?: string | null;
37
+ dedupeKey: string;
38
+ }
39
+ export declare function extractPoolInboundStablecoinEvents(payload: AlchemyAddressActivityPayload, poolAddress: string | null | undefined): PoolInboundStablecoinEvent[];
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractPoolInboundStablecoinEvents = extractPoolInboundStablecoinEvents;
4
+ /** local imports */
5
+ const STABLECOINS_REGISTRY_1 = require("../constants/STABLECOINS_REGISTRY");
6
+ const activityDedupe_1 = require("../utils/activityDedupe");
7
+ const normalizeAddress_1 = require("../utils/normalizeAddress");
8
+ const CHAIN_ID_TO_ALCHEMY_NETWORK = {
9
+ 1: 'ETH_MAINNET',
10
+ 56: 'BNB_MAINNET',
11
+ 137: 'MATIC_MAINNET',
12
+ 11155111: 'ETH_SEPOLIA',
13
+ };
14
+ const ALCHEMY_NETWORK_TO_CHAIN_ID = Object.fromEntries(Object.entries(CHAIN_ID_TO_ALCHEMY_NETWORK).map(([chainId, network]) => [
15
+ network,
16
+ Number(chainId),
17
+ ]));
18
+ function chainIdFromAlchemyNetwork(network) {
19
+ if (!network)
20
+ return null;
21
+ const chainId = ALCHEMY_NETWORK_TO_CHAIN_ID[network];
22
+ return chainId === undefined ? null : chainId;
23
+ }
24
+ function extractPoolInboundStablecoinEvents(payload, poolAddress) {
25
+ const poolAddressLower = (0, normalizeAddress_1.normalizeEvmAddress)(poolAddress);
26
+ if (!poolAddressLower)
27
+ return [];
28
+ if (payload.type !== 'ADDRESS_ACTIVITY')
29
+ return [];
30
+ const network = payload.event?.network;
31
+ const chainId = chainIdFromAlchemyNetwork(network);
32
+ const activity = payload.event?.activity;
33
+ if (!activity?.length)
34
+ return [];
35
+ const out = [];
36
+ for (const item of activity) {
37
+ if (item.category !== 'token')
38
+ continue;
39
+ if (item.log?.removed === true)
40
+ continue;
41
+ if (item.erc721TokenId != null && item.erc721TokenId !== '')
42
+ continue;
43
+ if (!(0, STABLECOINS_REGISTRY_1.isAllowedStablecoinContract)(chainId, item.rawContract?.address))
44
+ continue;
45
+ const value = item.value;
46
+ if (value === undefined || value === null || typeof value !== 'number' || !(value > 0))
47
+ continue;
48
+ const to = (0, normalizeAddress_1.normalizeEvmAddress)(item.toAddress);
49
+ const from = (0, normalizeAddress_1.normalizeEvmAddress)(item.fromAddress);
50
+ if (!to || !from)
51
+ continue;
52
+ if (to !== poolAddressLower)
53
+ continue;
54
+ const txHash = item.hash?.trim();
55
+ if (!txHash)
56
+ continue;
57
+ const dedupeKey = (0, activityDedupe_1.getTransactionActivityDedupeKey)(item);
58
+ if (!dedupeKey)
59
+ continue;
60
+ out.push({
61
+ webhookDeliveryId: payload.id,
62
+ webhookId: payload.webhookId,
63
+ alchemyNetwork: network || 'UNKNOWN',
64
+ chainId,
65
+ txHash,
66
+ fromAddress: from,
67
+ toAddress: to,
68
+ amount: value,
69
+ asset: item.asset || '',
70
+ tokenContractAddress: item.rawContract?.address,
71
+ dedupeKey,
72
+ });
73
+ }
74
+ return out;
75
+ }
@@ -1,4 +1,4 @@
1
- export type BasicTokenSymbol = 'ETH' | 'BNB' | 'POL' | 'USDC' | 'USDT' | 'USD₮0' | 'DAI' | 'WETH' | 'WBNB' | 'WBTC' | 'UNI' | 'NTK';
1
+ export type BasicTokenSymbol = 'ETH' | 'BNB' | 'POL' | 'USDC' | 'USDT' | 'USD₮0' | 'USD₮' | 'DAI' | 'DAI.e' | 'WETH' | 'WBNB' | 'WBTC' | 'WBTC.e' | 'UNI' | 'UNI.e' | 'NTK' | 'OP' | 'AVAX' | 'USDt' | 'xDAI' | 'MNT' | 'CELO' | 'HYPE' | 'WHYPE' | 'BERA' | 'XPL' | 'USDC.e';
2
2
  export interface BasicTokenData {
3
3
  id: string;
4
4
  address: string | null;