diff --git a/README.md b/README.md index cc1d3df2..5db88682 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,8 @@ getLpUrl: { ## Bills/Bonds +More information about bills can be found in [README-bills.md](./src/constants/bills/README-bills.md). + This is the current interface for Bills ```js diff --git a/package.json b/package.json index 2a9d60b4..c3027ba3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ape.swap/apeswap-lists", - "version": "1.5.1", + "version": "1.6.0-alpha.1", "main": "dist/index.js", "typings": "dist/index.d.ts", "publishConfig": { diff --git a/src/constants/bills/README-bills.md b/src/constants/bills/README-bills.md new file mode 100644 index 00000000..39d4f099 --- /dev/null +++ b/src/constants/bills/README-bills.md @@ -0,0 +1,25 @@ +# Bills/Bonds Configuration + +## Types + +In [./types.ts](./types.ts) you can find the types for the bills configuration. There are three different configuration interfaces which can be used to enforce configuration differences for each type based on the `billType` flag. + +Currently there are three types of bills/bonds: + +1. `liquidity` +2. `reserve` +3. `launch` + +```ts +// Using a "discriminated union" to have type safety for the different bill types +// https://github.com/basarat/typescript-book/blob/master/docs/types/discriminated-unions.md#discriminated-union +export type BillsConfig = BillsLiquidityConfig | BillsLaunchConfig | BillsReserveConfig +``` + +## Config + +The config for bills can be found in [./config.ts](./config.ts). It is an array of `BillsConfig` objects. The types will be enforced based on the `billType` flag. + +### `BillArtCollection` + +The `BillArtCollection` is a flag which depicts which art collection is used for the bill. This art collection and flag will need to be added to the backend api or else it will default to `ApeSwap_Collection1`. diff --git a/src/constants/bills.ts b/src/constants/bills/bills.ts similarity index 99% rename from src/constants/bills.ts rename to src/constants/bills/bills.ts index aa2b7f17..9e4c7b05 100644 --- a/src/constants/bills.ts +++ b/src/constants/bills/bills.ts @@ -1,13 +1,13 @@ import { ChainId } from '@ape.swap/sdk' -import tokens from './tokens' -import { BillsConfig, BillVersion } from '../types' +import tokens from '../tokens' +import { BillsConfig, BillVersion } from './types' // BNB Largest ID: 82 // Polygon Largest ID: 109 // Telos Largest ID: 215 // Arbitrum Largest ID: 2003 -const bills: BillsConfig[] = [ +export const bills: BillsConfig[] = [ { index: 62, contractAddress: { @@ -2366,5 +2366,3 @@ const bills: BillsConfig[] = [ soldOut: true, }, ] - -export default bills diff --git a/src/constants/bills/index.ts b/src/constants/bills/index.ts new file mode 100644 index 00000000..684022bc --- /dev/null +++ b/src/constants/bills/index.ts @@ -0,0 +1,2 @@ +export * from './bills' +export * from './types' diff --git a/src/constants/bills/types.ts b/src/constants/bills/types.ts new file mode 100644 index 00000000..f5549893 --- /dev/null +++ b/src/constants/bills/types.ts @@ -0,0 +1,72 @@ +import { ChainId } from '@ape.swap/sdk' +import { Token } from '/types' + +export enum BillVersion { + V1 = 'V1', + V2 = 'V2', +} + +/** + * This enum defines the art collection used to generate the art for a bill (bond). + * + * NOTE: Collections start at 1. The collection number provides a method to make new releases around + * the same theme or project. + */ +export enum BillArtCollection { + ApeSwap_Collection1 = 'ApeSwap_Collection1', + Quickswap_Collection1 = 'Quickswap_Collection1', +} + +export const defaultBillArtCollection = BillArtCollection.ApeSwap_Collection1 + +/** + * Liquidity Bills/Bonds Config + */ +export interface BillsLiquidityConfig { + index: number + contractAddress: Partial> + billVersion: BillVersion + billType: 'liquidity' + token: Token + quoteToken: Token + lpToken: Token + earnToken: Token + billNnftAddress: Partial> + inactive?: boolean + projectLink?: string + twitter?: string + initTime?: Partial> + initPrice?: Partial> + audit?: string + soldOut?: boolean + billArt?: { + collection: BillArtCollection // i.e. BillArtCollection.ApeSwap_Collection1 + } + showcaseToken?: Token +} + +/** + * Reserve Bills/Bonds Config + * + * NOTE: Extends Liquidity Bills/Bonds + */ +export interface BillsReserveConfig extends Omit { + billType: 'reserve' +} + +/** + * Launch Bills/Bonds Config + * + * NOTE: Extends Liquidity Bills/Bonds + */ +export interface BillsLaunchConfig extends Omit { + billType: 'launch' + // UTC Time in format: 2023-01-01T12:00:00.000Z' + launchTimeISOString: string + projectSummary: string + projectDescription: string +} + +// Using a "discriminated union" to have type safety for the different bill types +// https://github.com/basarat/typescript-book/blob/master/docs/types/discriminated-unions.md#discriminated-union +export type BillsConfig = BillsLiquidityConfig | BillsLaunchConfig | BillsReserveConfig diff --git a/src/constants/index.ts b/src/constants/index.ts index 09fcbe09..2bbbe0df 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -1,4 +1,4 @@ -export { default as bills } from './bills' +export * from './bills/' export { default as farms } from './farms' export { default as jungleFarms } from './jungleFarms' export { default as tokens } from './tokens' diff --git a/src/types/index.ts b/src/types/index.ts index 797f807a..8a4250a8 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,5 @@ import { ChainId } from '@ape.swap/sdk' +export * from '../constants/bills/types' export enum QuoteToken { 'BNB' = 'BNB', @@ -75,48 +76,6 @@ export interface MasterChef { rewardToken: Token } -export enum BillVersion { - V1 = 'V1', - V2 = 'V2', -} - -/** - * This enum defines the art collection used to generate the art for a bill (bond). - * - * NOTE: Collections start at 1. The collection number provides a method to make new releases around - * the same theme or project. - */ -export enum BillArtCollection { - ApeSwap_Collection1 = 'ApeSwap_Collection1', - Quickswap_Collection1 = 'Quickswap_Collection1', -} - -export const defaultBillArtCollection = BillArtCollection.ApeSwap_Collection1 - -// Start of list types -export interface BillsConfig { - index: number - contractAddress: Partial> - billVersion: BillVersion - billType: 'liquidity' | 'reserve' | 'launch' - token: Token - quoteToken: Token - lpToken: Token - earnToken: Token - billNnftAddress: Partial> - inactive?: boolean - projectLink?: string - twitter?: string - initTime?: Partial> - initPrice?: Partial> - audit?: string - soldOut?: boolean - billArt?: { - collection: BillArtCollection // i.e. BillArtCollection.ApeSwap_Collection1 - } - showcaseToken?: Token -} - export enum VaultVersion { V1 = 'V1', V2 = 'V2',