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

Docs for Core & Hooks SDKs #246

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions packages/core/src/factory/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,64 @@ export type FactoryConfig = {
export abstract class FactoryInterface {
public abstract config: FactoryConfig

/**
* Get a memecoin. Returns the results of both `getBaseMemecoin` and `getMemecoinLaunchData`.
* @param address Memecoin address
*/
public abstract getMemecoin(address: string): Promise<Memecoin | undefined>

/**
* Get a memecoin's base details. This includes the memecoin's name, symbol, owner, decimals, and total supply.
* @param address Memecoin address
*/
public abstract getBaseMemecoin(address: string): Promise<BaseMemecoin | undefined>

/**
* Get a memecoin's launch details. This includes the memecoin's quote token, team allocations, and liquidity.
* @param address Memecoin address
*/
public abstract getMemecoinLaunchData(address: string): Promise<LaunchedMemecoin>

/**
* Get the collectable ekubo fees of a memecoin.
* @param memecoin Result of `getMemecoin`
*/
public abstract getEkuboFees(memecoin: Memecoin): Promise<Fraction | undefined>

/**
* Get the calldata to collect ekubo fees of a memecoin.
* @param memecoin Result of `getMemecoin`
*/
public abstract getCollectEkuboFeesCalldata(memecoin: Memecoin): { calls: CallDetails[] } | undefined

/**
* Get the calldata to extend the liquidity lock of a memecoin.
* @param memecoin Result of `getMemecoin`
* @param seconds Amount of time to extend the liquidity lock in seconds
*/
public abstract getExtendLiquidityLockCalldata(
memecoin: Memecoin,
seconds: number,
): { calls: CallDetails[] } | undefined

/**
* Get the calldata to deploy a memecoin.
* @param data Data to deploy a memecoin
*/
public abstract getDeployCalldata(data: DeployData): { tokenAddress: string; calls: CallDetails[] }

/**
* Get the calldata to launch a deployed memecoin on Ekubo.
* @param memecoin Result of `getMemecoin`
* @param data Data to launch a memecoin
*/
public abstract getEkuboLaunchCalldata(memecoin: Memecoin, data: EkuboLaunchData): Promise<{ calls: CallDetails[] }>

/**
* Get the calldata to launch a deployed memecoin on a standard AMM.
* @param memecoin Result of `getMemecoin`
* @param data Data to launch a memecoin
*/
public abstract getStandardAMMLaunchCalldata(
memecoin: Memecoin,
data: StandardAMMLaunchData,
Expand Down
29 changes: 20 additions & 9 deletions packages/core/src/types/memecoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,51 @@ export type LaunchedMemecoin =
export type Memecoin = BaseMemecoin & LaunchedMemecoin

export type DeployData = {
/** The name of the memecoin. */
name: string

/** The symbol of the memecoin. */
symbol: string

/** Owner address of the memecoin. */
owner: string

/** The initial supply of the memecoin. Must **not be** multiplied by 10^decimals. */
initialSupply: string | string
}

type MemecoinBaseLaunchData = {
/** The AMM to launch the memecoin on. */
amm: AMM

/** The team allocations. */
teamAllocations: {
/** The address of the allocation. */
address: string

/** The allocation of the team member. Must **not be** multiplied by 10^decimals. */
amount: number | string
}[]

/** The hold limit as Percent object. */
holdLimit: Percent

/**
* Anti bot period in *seconds*
*/
/** The anti-bot feature period in seconds. For example, 1 hour is 3600 etc. */
antiBotPeriod: number

/**
* Quote token
*/
/** The quote token to use. Must be a `Token` object and must be supported. See `QUOTE_TOKENS` constant. */
quoteToken: Token

/**
* Starting market cap in USDC
*/
/** The starting market cap in USDC. */
startingMarketCap: number | string
}

export type EkuboLaunchData = MemecoinBaseLaunchData & {
/** The ekubo fees. */
fees: Percent
}

export type StandardAMMLaunchData = MemecoinBaseLaunchData & {
/** The liquidity lock period in seconds. */
liquidityLockPeriod: number
}
8 changes: 8 additions & 0 deletions packages/core/src/utils/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import { Entrypoint } from '../constants'
import { USDCPair } from '../types/tokens'
import { decimalsScale } from './helpers'

/**
* Get the Jediswap pair price for a given pair.
* If the pair is not provided, returns 1.
* @param provider Starknet provider
* @param pair Pair to get the price for
* @param blockNumber Block number to get the price at
* @returns Pair price as a Fraction
*/
export async function getPairPrice(
provider: ProviderInterface,
pair?: USDCPair,
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/sdk/core/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Core SDK",
"position": 4,
"position": 1,
"collapsed": true
}
5 changes: 5 additions & 0 deletions packages/docs/docs/sdk/core/methods/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Methods",
"position": 2,
"collapsed": true
}
30 changes: 30 additions & 0 deletions packages/docs/docs/sdk/core/methods/getBaseMemecoin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: getBaseMemecoin
sidebar_position: 2
title: getBaseMemecoin
---

# getBaseMemecoin

`getBaseMemecoin` method is used to get the base details of the memecoin. The base details include the name, symbol, decimals, owner, and total supply of the memecoin.

## Parameters

- address: `string` - The address of the memecoin.

## Returns

`BaseMemecoin` object with the following properties:

- address: `string` - The address of the memecoin.
- name: `string` - The name of the memecoin.
- symbol: `string` - The symbol of the memecoin.
- owner: `string` - The owner of the memecoin.
- decimals: `number` - The number of decimals for the memecoin.
- totalSupply: `string` - The total supply of the memecoin.

## Usage

```ts
const baseMemecoin = await coreSdk.getBaseMemecoin(memecoinAddress)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
id: getCollectEkuboFeesCalldata
sidebar_position: 6
title: getCollectEkuboFeesCalldata
---

# getCollectEkuboFeesCalldata

`getCollectEkuboFeesCalldata` method is used to get the calldata for collecting fees for a memecoin launched on Ekubo.

## Parameters

- memecoin: `Memecoin` - The memecoin to collect fees for.

## Returns

`undefined` if the memecoin is not launched on Ekubo or an object with the following properties:

- calls: `Call[]` - The calls to execute to collect fees for the memecoin.

## Usage

```ts
const memecoin = await coreSdk.getMemecoin(memecoinAddress)
const calldata = await coreSdk.getCollectEkuboFeesCalldata(memecoin)

if (!calldata) {
// Memecoin is not launched on Ekubo
}

const { calls } = calldata
```

`calls` can now be used to execute the transaction to collect fees for the memecoin.
32 changes: 32 additions & 0 deletions packages/docs/docs/sdk/core/methods/getDeployCalldata.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
id: getDeployCalldata
sidebar_position: 8
title: getDeployCalldata
---

# getDeployCalldata

`getDeployCalldata` method is used to get the calldata for deploying a new unruggable memecoin.

## Parameters

- data: `DeployData` - The data required to deploy the memecoin.
- name: `string` - The name of the memecoin.
- symbol: `string` - The symbol of the memecoin.
- decimals: `number` - The number of decimals for the memecoin.
- initialSupply: `string` - The initial supply of the memecoin. Note: Initial supply **should not** be multiplied by 10^decimals.

## Returns

An object with the following properties:

- calls: `Call[]` - The calls to execute to deploy the memecoin.
- tokenAddress: `string` - The calculated address of the memecoin.

## Usage

```ts
const { tokenAddress, calls } = coreSdk.getDeployCalldata(data)
```

`calls` can now be used to execute the transaction to deploy the memecoin.
24 changes: 24 additions & 0 deletions packages/docs/docs/sdk/core/methods/getEkuboFees.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
id: getEkuboFees
sidebar_position: 5
title: getEkuboFees
---

# getEkuboFees

`getEkuboFees` method is used to get the collectable fees for a memecoin launched on Ekubo.

## Parameters

- memecoin: `Memecoin` - The memecoin to get the fees for.

## Returns

An instance of `Fraction` or `undefined` if the memecoin is not launched on Ekubo or the quote token is not supported.

## Usage

```ts
const memecoin = await coreSdk.getMemecoin(memecoinAddress)
const fees = await coreSdk.getEkuboFees(memecoin)
```
37 changes: 37 additions & 0 deletions packages/docs/docs/sdk/core/methods/getEkuboLaunchCalldata.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: getEkuboLaunchCalldata
sidebar_position: 9
title: getEkuboLaunchCalldata
---

# getEkuboLaunchCalldata

`getEkuboLaunchCalldata` method is used to get the calldata for launching a deployed unruggable memecoin on Ekubo.

## Parameters

- memecoin: `Memecoin` - The memecoin to launch.
- data: `EkuboLaunchData` - The data required to launch the memecoin on Ekubo.
- amm: `AMM` - The AMM to use for the memecoin. Not used but required for future compatibility.
- teamAllocations: `TeamAllocation[]` - The team allocations for the memecoin. An array of objects with the following properties:
- address: `string` - The address of the team member.
- amount: `string | number` - The allocation of the team member. Must **not be** multiplied by 10^decimals.
- holdLimit: `number` - The hold limit for the memecoin multiplied by 100. For example, 1% is 100, 10% is 1000, etc.
- antiBotPeriod: `number` - The anti-bot feature period for the memecoin in seconds. For example, 1 hour is 3600, 1 day is 86400, etc.
- quoteToken: `Token` - The quote token to use for the memecoin. Must be a `Token` object and must be supported. See `QUOTE_TOKENS` constant.
- startingMarketCap: `string | number` - The starting market cap of the memecoin in USDC.
- fees: `Percent` - The ekubo fees. Must be a `Percent` object.

## Returns

An object with the following properties:

- calls: `Call[]` - The calls to execute to launch the memecoin on Ekubo.

## Usage

```ts
const { calls } = await coreSdk.getEkuboLaunchCalldata(data)
```

`calls` can now be used to execute the transaction to launch the memecoin on Ekubo.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
id: getExtendLiquidityLockCalldata
sidebar_position: 7
title: getExtendLiquidityLockCalldata
---

# getExtendLiquidityLockCalldata

`getExtendLiquidityLockCalldata` method is used to get the calldata for extending the liquidity lock of a memecoin launched on Jediswap or StarkDeFi.

## Parameters

- memecoin: `Memecoin` - The memecoin to extend the liquidity lock for.
- seconds: `number` - The number of seconds to extend the lock for.

## Returns

`undefined` if the memecoin is not launched on Jediswap or StarkDeFi or an object with the following properties:

- calls: `Call[]` - The calls to execute to extend the liquidity lock for the memecoin.

## Usage

```ts
const memecoin = await coreSdk.getMemecoin(memecoinAddress)
const calldata = await coreSdk.getExtendLiquidityLockCalldata(memecoin, seconds)

if (!calldata) {
// Memecoin is not launched on Jediswap or StarkDeFi
}

const { calls } = calldata
```

`calls` can now be used to execute the transaction to extend the liquidity lock for the memecoin.
30 changes: 30 additions & 0 deletions packages/docs/docs/sdk/core/methods/getMemecoin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: getMemecoin
sidebar_position: 1
title: getMemecoin
---

# getMemecoin

`getMemecoin` method is used to get both the [base details](./getBaseMemecoin) and the [launch data](./getMemecoinLaunchData) of the memecoin.

## Parameters

- address: `string` - The address of the memecoin.

## Returns

`Memecoin` object which is a combination of the [BaseMemecoin](./getBaseMemecoin) and [LaunchedMemecoin](./getMemecoinLaunchData) objects.

<iframe
frameborder="0"
style={{ width: '100%', height: '352px' }}
allow="clipboard-write"
src="https://emgithub.com/iframe.html?target=https%3A%2F%2Fgithub.com%2Fkeep-starknet-strange%2Funruggable.meme%2Fblob%2Fdf4daac8f4a91f8ed5279f7a39ab9b40125265c7%2Fpackages%2Fcore%2Fsrc%2Ftypes%2Fmemecoin.ts%23L49-L72&style=github-dark-dimmed&type=code&showBorder=on&showLineNumbers=on&showFileMeta=on&showFullPath=on&showCopy=on"
></iframe>

## Usage

```ts
const memecoin = await coreSdk.getMemecoin(memecoinAddress)
```
Loading
Loading