Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add TMGVTestToken parameter to buildToken function. #86

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-ladybugs-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mangrovedao/mgv": patch
---

Add flag for mgv test tokens
2 changes: 2 additions & 0 deletions src/addresses/tokens/base-sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ export const baseSepoliaWBTC = buildToken({
decimals: 8,
displayDecimals: 5,
priceDisplayDecimals: 6,
mgvTestToken: true,
})

export const baseSepoliaDAI = buildToken({
address: '0x9508B3459Bc95A39CA66c385f1Ae12f03f72f8af',
symbol: 'DAI',
displayDecimals: 2,
priceDisplayDecimals: 2,
mgvTestToken: true,
})

export const baseSepoliaTokens = [
Expand Down
16 changes: 13 additions & 3 deletions src/addresses/tokens/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export type Token<
TDecimals extends number = number,
TDisplayDecimals extends number = number,
TPriceDisplayDecimals extends number = number,
TMGVTestToken extends boolean = boolean,
> = {
address: TAddress
symbol: TSymbol
decimals: TDecimals
displayDecimals: TDisplayDecimals
priceDisplayDecimals: TPriceDisplayDecimals
mgvTestToken: TMGVTestToken
}

export type BuildTokenParms<
Expand All @@ -24,12 +26,14 @@ export type BuildTokenParms<
TDecimals extends number | undefined = number | undefined,
TDisplayDecimals extends number | undefined = number | undefined,
TPriceDisplayDecimals extends number | undefined = number | undefined,
TMGVTestToken extends boolean | undefined = boolean | undefined,
> = {
address: TAddress
symbol: TSymbol
decimals?: TDecimals | undefined
displayDecimals?: TDisplayDecimals | undefined
priceDisplayDecimals?: TPriceDisplayDecimals | undefined
mgvTestToken?: TMGVTestToken | undefined
}

export function buildToken<
Expand All @@ -38,18 +42,21 @@ export function buildToken<
TDecimals extends number | undefined = undefined,
TDisplayDecimals extends number | undefined = undefined,
TPriceDisplayDecimals extends number | undefined = undefined,
TMGVTestToken extends boolean | undefined = undefined,
>({
address,
symbol,
decimals = DEFAULT_DECIMALS,
displayDecimals = DEFAULT_DISPLAY_DECIMALS,
priceDisplayDecimals = DEFAULT_PRICE_DISPLAY_DECIMALS,
mgvTestToken = false,
}: BuildTokenParms<
TAddress,
TSymbol,
TDecimals,
TDisplayDecimals,
TPriceDisplayDecimals
TPriceDisplayDecimals,
TMGVTestToken
>): Token<
TAddress,
TSymbol,
Expand All @@ -59,14 +66,16 @@ export function buildToken<
: typeof DEFAULT_DISPLAY_DECIMALS,
TPriceDisplayDecimals extends number
? TPriceDisplayDecimals
: typeof DEFAULT_PRICE_DISPLAY_DECIMALS
: typeof DEFAULT_PRICE_DISPLAY_DECIMALS,
TMGVTestToken extends boolean ? TMGVTestToken : false
> {
return {
address,
symbol,
decimals,
displayDecimals,
priceDisplayDecimals,
mgvTestToken,
} as Token<
TAddress,
TSymbol,
Expand All @@ -76,6 +85,7 @@ export function buildToken<
: typeof DEFAULT_DISPLAY_DECIMALS,
TPriceDisplayDecimals extends number
? TPriceDisplayDecimals
: typeof DEFAULT_PRICE_DISPLAY_DECIMALS
: typeof DEFAULT_PRICE_DISPLAY_DECIMALS,
TMGVTestToken extends boolean ? TMGVTestToken : false
>
}