Skip to content

Commit

Permalink
feat: add TOKEN_ADDRESSES as consts
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Nov 21, 2024
1 parent 4b25998 commit 5f7fdae
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 57 deletions.
29 changes: 29 additions & 0 deletions consts/token-addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { LIDO_TOKENS } from '@lidofinance/lido-ethereum-sdk';

// At the moment, we have doubts about using the code in the widget:
// the code```
// const stethAddress = await lidoSDK.core.getContractAddress(
// LIDO_CONTRACT_NAMES.lido,
// );
// ```
//
// At the moment it is only used in:
// - features/withdrawals/request/withdrawal-rates/integrations.ts
// - utils/get-bebop-rate.ts
// - utils/get-open-ocean-rate.ts
//

export type TOKENS =
| Exclude<(typeof LIDO_TOKENS)[keyof typeof LIDO_TOKENS], 'unstETH'>
| 'LDO';

export const TOKEN_ADDRESSES: Record<TOKENS, string> = {
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
LDO: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
};

export const getRateTokenAddress = (token: TOKENS): string => {
return TOKEN_ADDRESSES[token] || '';
};
20 changes: 1 addition & 19 deletions features/withdrawals/request/withdrawal-rates/integrations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { formatEther, getAddress } from 'viem';
import { LIDO_TOKENS } from '@lidofinance/lido-ethereum-sdk';

import { ZERO } from 'modules/web3';
import { OPEN_OCEAN_REFERRAL_ADDRESS } from 'consts/external-links';
import { MATOMO_CLICK_EVENTS_TYPES } from 'consts/matomo-click-events';
import { getRateTokenAddress } from 'consts/token-addresses';

import { getOneInchRate } from 'utils/get-one-inch-rate';
import { getBebopRate } from 'utils/get-bebop-rate';
Expand All @@ -12,24 +12,6 @@ import { standardFetcher } from 'utils/standardFetcher';

import { BebopIcon, OneInchIcon, OpenOceanIcon, ParaSwapIcon } from './icons';

// TODO: temp
type TOKENS =
| Exclude<(typeof LIDO_TOKENS)[keyof typeof LIDO_TOKENS], 'unstETH'>
| 'LDO';

// TODO: temp
const TOKEN_ADDRESSES: Record<TOKENS, string> = {
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
LDO: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
};

// TODO: temp
const getRateTokenAddress = (token: TOKENS): string => {
return TOKEN_ADDRESSES[token] || '';
};

import type {
DexWithdrawalApi,
DexWithdrawalIntegrationMap,
Expand Down
20 changes: 1 addition & 19 deletions utils/get-bebop-rate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAddress } from 'viem';
import { LIDO_TOKENS } from '@lidofinance/lido-ethereum-sdk';

import { config } from 'config';
import { TOKENS, getRateTokenAddress } from 'consts/token-addresses';
import { standardFetcher } from './standardFetcher';

type BebopGetQuotePartial = {
Expand All @@ -27,24 +27,6 @@ type BebopGetQuotePartial = {

type RateCalculationResult = { rate: number; toReceive: bigint };

// TODO: temp
type TOKENS =
| Exclude<(typeof LIDO_TOKENS)[keyof typeof LIDO_TOKENS], 'unstETH'>
| 'LDO';

// TODO: temp
const TOKEN_ADDRESSES: Record<TOKENS, string> = {
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
LDO: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
};

// TODO: temp
const getRateTokenAddress = (token: TOKENS): string => {
return TOKEN_ADDRESSES[token] || '';
};

export const getBebopRate = async (
amount: bigint,
fromToken: TOKENS,
Expand Down
20 changes: 1 addition & 19 deletions utils/get-open-ocean-rate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatEther } from 'viem';
import { LIDO_TOKENS } from '@lidofinance/lido-ethereum-sdk';

import { TOKENS, getRateTokenAddress } from 'consts/token-addresses';
import { standardFetcher } from './standardFetcher';

type OpenOceanGetGasPartial = {
Expand Down Expand Up @@ -50,24 +50,6 @@ const calculateRateReceive = (
return { rate, toReceive };
};

// TODO: temp
type TOKENS =
| Exclude<(typeof LIDO_TOKENS)[keyof typeof LIDO_TOKENS], 'unstETH'>
| 'LDO';

// TODO: temp
const TOKEN_ADDRESSES: Record<TOKENS, string> = {
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
LDO: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
};

// TODO: temp
const getRateTokenAddress = (token: TOKENS): string => {
return TOKEN_ADDRESSES[token] || '';
};

export const getOpenOceanRate = async (
amount: bigint,
fromToken: TOKENS,
Expand Down

0 comments on commit 5f7fdae

Please sign in to comment.