diff --git a/.changeset/chatty-tips-shop.md b/.changeset/chatty-tips-shop.md new file mode 100644 index 0000000..c35a550 --- /dev/null +++ b/.changeset/chatty-tips-shop.md @@ -0,0 +1,5 @@ +--- +"@mangrovedao/mgv": minor +--- + +Added addresses book in /addresses diff --git a/src/addresses/index.ts b/src/addresses/index.ts new file mode 100644 index 0000000..e97ce6e --- /dev/null +++ b/src/addresses/index.ts @@ -0,0 +1,19 @@ +export type { + Token, + BuildTokenParms, +} from './tokens/index.js' + +export { blastMarkets } from './markets/index.js' + +// --- tokens --- + +export { + blastWETH, + blastUSDB, + blastMetaStreetWETHPUNKS20, + blastMetaStreetWETHPUNKS40, +} from './tokens/index.js' + +// --- mangrove --- + +export { blastMangrove } from './mangrove/index.js' diff --git a/src/addresses/mangrove/blast.ts b/src/addresses/mangrove/blast.ts new file mode 100644 index 0000000..2080c8f --- /dev/null +++ b/src/addresses/mangrove/blast.ts @@ -0,0 +1,7 @@ +import type { MangroveActionsDefaultParams } from '../../types/index.js' + +export const blastMangrove = { + mgv: '0xb1a49C54192Ea59B233200eA38aB56650Dfb448C', + mgvOrder: '0x83251E7F36a51c5238C9aa0c6Bb7cc209b32d80e', + mgvReader: '0x26fD9643Baf1f8A44b752B28f0D90AEBd04AB3F8', +} as const satisfies MangroveActionsDefaultParams diff --git a/src/addresses/mangrove/index.ts b/src/addresses/mangrove/index.ts new file mode 100644 index 0000000..cba379f --- /dev/null +++ b/src/addresses/mangrove/index.ts @@ -0,0 +1 @@ +export { blastMangrove } from './blast.js' diff --git a/src/addresses/markets/blast.ts b/src/addresses/markets/blast.ts new file mode 100644 index 0000000..1c1a048 --- /dev/null +++ b/src/addresses/markets/blast.ts @@ -0,0 +1,25 @@ +import type { MarketParams } from '../../types/index.js' +import { + blastMetaStreetWETHPUNKS20, + blastMetaStreetWETHPUNKS40, + blastUSDB, + blastWETH, +} from '../tokens/blast.js' + +export const blastMarkets = [ + { + base: blastWETH, + quote: blastUSDB, + tickSpacing: 1n, + }, + { + base: blastMetaStreetWETHPUNKS20, + quote: blastWETH, + tickSpacing: 1n, + }, + { + base: blastMetaStreetWETHPUNKS40, + quote: blastWETH, + tickSpacing: 1n, + }, +] as const satisfies MarketParams[] diff --git a/src/addresses/markets/index.ts b/src/addresses/markets/index.ts new file mode 100644 index 0000000..4961ad3 --- /dev/null +++ b/src/addresses/markets/index.ts @@ -0,0 +1 @@ +export { blastMarkets } from './blast.js' diff --git a/src/addresses/tokens/blast.ts b/src/addresses/tokens/blast.ts new file mode 100644 index 0000000..5f9a090 --- /dev/null +++ b/src/addresses/tokens/blast.ts @@ -0,0 +1,23 @@ +import { buildToken } from './utils.js' + +export const blastWETH = buildToken({ + address: '0x4300000000000000000000000000000000000004', + symbol: 'WETH', +}) + +export const blastUSDB = buildToken({ + address: '0x4300000000000000000000000000000000000002', + symbol: 'USDB', + displayDecimals: 2, + priceDisplayDecimals: 2, +}) + +export const blastMetaStreetWETHPUNKS20 = buildToken({ + address: '0x9a50953716ba58e3d6719ea5c437452ac578705f', + symbol: 'mwstETH-WPUNKS:20', +}) + +export const blastMetaStreetWETHPUNKS40 = buildToken({ + address: '0x999f220296b5843b2909cc5f8b4204aaca5341d8', + symbol: 'mwstETH-WPUNKS:40', +}) diff --git a/src/addresses/tokens/index.ts b/src/addresses/tokens/index.ts new file mode 100644 index 0000000..b4c4ce6 --- /dev/null +++ b/src/addresses/tokens/index.ts @@ -0,0 +1,13 @@ +export { + blastWETH, + blastUSDB, + blastMetaStreetWETHPUNKS20, + blastMetaStreetWETHPUNKS40, +} from './blast.js' + +export type { + Token, + BuildTokenParms, +} from './utils.js' + +export { buildToken } from './utils.js' diff --git a/src/addresses/tokens/utils.ts b/src/addresses/tokens/utils.ts new file mode 100644 index 0000000..8626515 --- /dev/null +++ b/src/addresses/tokens/utils.ts @@ -0,0 +1,81 @@ +import type { Address } from 'viem' + +export const DEFAULT_DISPLAY_DECIMALS = 3 as const +export const DEFAULT_PRICE_DISPLAY_DECIMALS = 6 as const +export const DEFAULT_DECIMALS = 18 as const + +export type Token< + TAddress extends Address = Address, + TSymbol extends string = string, + TDecimals extends number = number, + TDisplayDecimals extends number = number, + TPriceDisplayDecimals extends number = number, +> = { + address: TAddress + symbol: TSymbol + decimals: TDecimals + displayDecimals: TDisplayDecimals + priceDisplayDecimals: TPriceDisplayDecimals +} + +export type BuildTokenParms< + TAddress extends Address = Address, + TSymbol extends string = string, + TDecimals extends number | undefined = number | undefined, + TDisplayDecimals extends number | undefined = number | undefined, + TPriceDisplayDecimals extends number | undefined = number | undefined, +> = { + address: TAddress + symbol: TSymbol + decimals?: TDecimals + displayDecimals?: TDisplayDecimals + priceDisplayDecimals?: TPriceDisplayDecimals +} + +export function buildToken< + TAddress extends Address = Address, + TSymbol extends string = string, + TDecimals extends number | undefined = undefined, + TDisplayDecimals extends number | undefined = undefined, + TPriceDisplayDecimals extends number | undefined = undefined, +>({ + address, + symbol, + decimals = DEFAULT_DECIMALS, + displayDecimals = DEFAULT_DISPLAY_DECIMALS, + priceDisplayDecimals = DEFAULT_PRICE_DISPLAY_DECIMALS, +}: BuildTokenParms< + TAddress, + TSymbol, + TDecimals, + TDisplayDecimals, + TPriceDisplayDecimals +>): Token< + TAddress, + TSymbol, + TDecimals extends number ? TDecimals : typeof DEFAULT_DECIMALS, + TDisplayDecimals extends number + ? TDisplayDecimals + : typeof DEFAULT_DISPLAY_DECIMALS, + TPriceDisplayDecimals extends number + ? TPriceDisplayDecimals + : typeof DEFAULT_PRICE_DISPLAY_DECIMALS +> { + return { + address, + symbol, + decimals, + displayDecimals, + priceDisplayDecimals, + } as Token< + TAddress, + TSymbol, + TDecimals extends number ? TDecimals : typeof DEFAULT_DECIMALS, + TDisplayDecimals extends number + ? TDisplayDecimals + : typeof DEFAULT_DISPLAY_DECIMALS, + TPriceDisplayDecimals extends number + ? TPriceDisplayDecimals + : typeof DEFAULT_PRICE_DISPLAY_DECIMALS + > +} diff --git a/src/index.ts b/src/index.ts index 0627d98..6410a51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,7 +35,6 @@ export { export type { MangroveActionsDefaultParams, - Token, MarketParams, BuiltArgs, BuiltArgsWithValue, @@ -63,3 +62,10 @@ export type { // --- bundles --- export { publicMarketActions } from './bundle/index.js' + +// --- addresses --- + +export type { + Token, + BuildTokenParms, +} from './addresses/index.js' diff --git a/src/package.json b/src/package.json index 8c98ddb..e2c6227 100644 --- a/src/package.json +++ b/src/package.json @@ -31,6 +31,11 @@ "import": "./_esm/actions/index.js", "default": "./_cjs/actions/index.js" }, + "./addresses": { + "types": "./_types/addresses/index.d.ts", + "import": "./_esm/addresses/index.js", + "default": "./_cjs/addresses/index.js" + }, "./builder": { "types": "./_types/builder/index.d.ts", "import": "./_esm/builder/index.js", diff --git a/src/types/actions/index.ts b/src/types/actions/index.ts index b0396a8..06dc5b4 100644 --- a/src/types/actions/index.ts +++ b/src/types/actions/index.ts @@ -1,4 +1,5 @@ import type { Address } from 'viem' +import type { Token } from '../../addresses/tokens/utils.js' /** * The parameters for the Mangrove actions. @@ -12,16 +13,6 @@ export type MangroveActionsDefaultParams = { mgvOrder: Address } -/** - * The parameters for a token. - * @param address The address of the token. - * @param decimals The number of decimals of the token. - */ -export type Token = { - address: Address - decimals: number -} - /** * * The parameters for a given market market diff --git a/src/types/index.ts b/src/types/index.ts index 482f19a..fbc18de 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,6 +1,5 @@ export type { MangroveActionsDefaultParams, - Token, MarketParams, BuiltArgs, BuiltArgsWithValue,