-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathnativeToken.ts
More file actions
29 lines (25 loc) · 895 Bytes
/
nativeToken.ts
File metadata and controls
29 lines (25 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Address } from 'viem';
import { Token } from './token';
/**
* NativeToken extends BaseToken and adds mandatory wrapped token functionality
* This class is specifically designed for native tokens that always have a wrapped version
*/
export class NativeToken extends Token {
public readonly wrapped: Address;
public constructor(
chainId: number,
address: Address,
decimals: number,
wrapped: Address,
symbol?: string,
name?: string,
) {
// Call parent constructor with core properties
super(chainId, address, decimals, symbol, name);
// Set wrapped address (always mandatory for native tokens)
this.wrapped = wrapped.toLowerCase() as Address;
}
public isUnderlyingEqual(token: NativeToken) {
return this.chainId === token.chainId && this.wrapped === token.wrapped;
}
}