Skip to content

Commit dcde903

Browse files
committed
fix(addresses): extend customizationlogic to wrapping
1 parent 5ca1703 commit dcde903

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/blue-sdk/src/addresses.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,7 @@ export const getChainAddresses = (chainId: number): ChainAddresses => {
381381
* Assumptions:
382382
* - unwrapped token has same number of decimals than wrapped tokens.
383383
*/
384-
export const unwrappedTokensMapping: Record<
385-
ChainId,
386-
Record<Address, Address>
387-
> = {
384+
const _unwrappedTokensMapping: Record<ChainId, Record<Address, Address>> = {
388385
[ChainId.EthMainnet]: {
389386
[_addressesRegistry[ChainId.EthMainnet].wbIB01]:
390387
_addressesRegistry[ChainId.EthMainnet].bIB01,
@@ -507,11 +504,15 @@ export const convexWrapperTokens: Record<number, Set<Address>> = {
507504

508505
export let addressesRegistry = Object.freeze(_addressesRegistry);
509506
export let addresses = addressesRegistry as Record<number, ChainAddresses>;
507+
export let unwrappedTokensMapping = Object.freeze(_unwrappedTokensMapping);
510508

511509
export function registerCustomAddresses(
512510
customAddresses:
513511
| Record<keyof typeof _addressesRegistry, DeepPartial<ChainAddresses>>
514-
| Record<number, ChainAddresses>,
512+
| Record<number, ChainAddresses> = {},
513+
{
514+
unwrappedTokens,
515+
}: { unwrappedTokens?: Record<number, Record<Address, Address>> } = {},
515516
) {
516517
// biome-ignore lint/suspicious/noExplicitAny: type is not trivial and not important here
517518
const customizer = (objValue: any, _srcValue: any, key: string) => {
@@ -522,4 +523,9 @@ export function registerCustomAddresses(
522523
addresses = addressesRegistry = Object.freeze(
523524
mergeWith({}, _addressesRegistry, customAddresses, customizer),
524525
);
526+
527+
if (unwrappedTokens)
528+
unwrappedTokensMapping = Object.freeze(
529+
mergeWith({}, _unwrappedTokensMapping, unwrappedTokens, customizer),
530+
);
525531
}

0 commit comments

Comments
 (0)