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

feat: Add Launch Bills/Bonds config #202

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
25 changes: 25 additions & 0 deletions src/constants/bills/README-bills.md
Original file line number Diff line number Diff line change
@@ -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`.
8 changes: 3 additions & 5 deletions src/constants/bills.ts → src/constants/bills/bills.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -2366,5 +2366,3 @@ const bills: BillsConfig[] = [
soldOut: true,
},
]

export default bills
2 changes: 2 additions & 0 deletions src/constants/bills/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './bills'
export * from './types'
72 changes: 72 additions & 0 deletions src/constants/bills/types.ts
Original file line number Diff line number Diff line change
@@ -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<Record<ChainId, string>>
billVersion: BillVersion
billType: 'liquidity'
token: Token
quoteToken: Token
lpToken: Token
earnToken: Token
billNnftAddress: Partial<Record<ChainId, string>>
inactive?: boolean
projectLink?: string
twitter?: string
initTime?: Partial<Record<ChainId, number>>
initPrice?: Partial<Record<ChainId, number>>
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<BillsLiquidityConfig, 'billType'> {
billType: 'reserve'
}

/**
* Launch Bills/Bonds Config
*
* NOTE: Extends Liquidity Bills/Bonds
*/
export interface BillsLaunchConfig extends Omit<BillsLiquidityConfig, 'billType'> {
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
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
43 changes: 1 addition & 42 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainId } from '@ape.swap/sdk'
export * from '../constants/bills/types'

export enum QuoteToken {
'BNB' = 'BNB',
Expand Down Expand Up @@ -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<Record<ChainId, string>>
billVersion: BillVersion
billType: 'liquidity' | 'reserve' | 'launch'
token: Token
quoteToken: Token
lpToken: Token
earnToken: Token
billNnftAddress: Partial<Record<ChainId, string>>
inactive?: boolean
projectLink?: string
twitter?: string
initTime?: Partial<Record<ChainId, number>>
initPrice?: Partial<Record<ChainId, number>>
audit?: string
soldOut?: boolean
billArt?: {
collection: BillArtCollection // i.e. BillArtCollection.ApeSwap_Collection1
}
showcaseToken?: Token
}

export enum VaultVersion {
V1 = 'V1',
V2 = 'V2',
Expand Down