Skip to content

Commit

Permalink
refactor: Add TMGVTestToken parameter to buildToken function. (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxencerb authored Jun 13, 2024
1 parent ea1400d commit 22689cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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
>
}

0 comments on commit 22689cf

Please sign in to comment.