diff --git a/packages/core/src/factory/interface.ts b/packages/core/src/factory/interface.ts index 31ae6d31..b3e44b54 100644 --- a/packages/core/src/factory/interface.ts +++ b/packages/core/src/factory/interface.ts @@ -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 + /** + * 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 + /** + * 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 + /** + * Get the collectable ekubo fees of a memecoin. + * @param memecoin Result of `getMemecoin` + */ public abstract getEkuboFees(memecoin: Memecoin): Promise + /** + * 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, diff --git a/packages/core/src/types/memecoin.ts b/packages/core/src/types/memecoin.ts index e5f63237..74f70081 100644 --- a/packages/core/src/types/memecoin.ts +++ b/packages/core/src/types/memecoin.ts @@ -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 } diff --git a/packages/core/src/utils/price.ts b/packages/core/src/utils/price.ts index 4ad9fd8d..7eba732c 100644 --- a/packages/core/src/utils/price.ts +++ b/packages/core/src/utils/price.ts @@ -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, diff --git a/packages/docs/docs/sdk/core/_category_.json b/packages/docs/docs/sdk/core/_category_.json index fed323cc..e9588a3e 100644 --- a/packages/docs/docs/sdk/core/_category_.json +++ b/packages/docs/docs/sdk/core/_category_.json @@ -1,5 +1,5 @@ { "label": "Core SDK", - "position": 4, + "position": 1, "collapsed": true } diff --git a/packages/docs/docs/sdk/core/methods/_category_.json b/packages/docs/docs/sdk/core/methods/_category_.json new file mode 100644 index 00000000..1d85f0aa --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Methods", + "position": 2, + "collapsed": true +} diff --git a/packages/docs/docs/sdk/core/methods/getBaseMemecoin.mdx b/packages/docs/docs/sdk/core/methods/getBaseMemecoin.mdx new file mode 100644 index 00000000..7479ea37 --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getBaseMemecoin.mdx @@ -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) +``` diff --git a/packages/docs/docs/sdk/core/methods/getCollectEkuboFeesCalldata.mdx b/packages/docs/docs/sdk/core/methods/getCollectEkuboFeesCalldata.mdx new file mode 100644 index 00000000..cafcb7cd --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getCollectEkuboFeesCalldata.mdx @@ -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. diff --git a/packages/docs/docs/sdk/core/methods/getDeployCalldata.mdx b/packages/docs/docs/sdk/core/methods/getDeployCalldata.mdx new file mode 100644 index 00000000..9f514f8e --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getDeployCalldata.mdx @@ -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. diff --git a/packages/docs/docs/sdk/core/methods/getEkuboFees.mdx b/packages/docs/docs/sdk/core/methods/getEkuboFees.mdx new file mode 100644 index 00000000..93a1807f --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getEkuboFees.mdx @@ -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) +``` diff --git a/packages/docs/docs/sdk/core/methods/getEkuboLaunchCalldata.mdx b/packages/docs/docs/sdk/core/methods/getEkuboLaunchCalldata.mdx new file mode 100644 index 00000000..de557b7c --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getEkuboLaunchCalldata.mdx @@ -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. diff --git a/packages/docs/docs/sdk/core/methods/getExtendLiquidityLockCalldata.mdx b/packages/docs/docs/sdk/core/methods/getExtendLiquidityLockCalldata.mdx new file mode 100644 index 00000000..0ba7ea89 --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getExtendLiquidityLockCalldata.mdx @@ -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. diff --git a/packages/docs/docs/sdk/core/methods/getMemecoin.mdx b/packages/docs/docs/sdk/core/methods/getMemecoin.mdx new file mode 100644 index 00000000..7bcc1668 --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getMemecoin.mdx @@ -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. + + + +## Usage + +```ts +const memecoin = await coreSdk.getMemecoin(memecoinAddress) +``` diff --git a/packages/docs/docs/sdk/core/methods/getMemecoinLaunchData.mdx b/packages/docs/docs/sdk/core/methods/getMemecoinLaunchData.mdx new file mode 100644 index 00000000..cb76f143 --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getMemecoinLaunchData.mdx @@ -0,0 +1,40 @@ +--- +id: getMemecoinLaunchData +sidebar_position: 3 +title: getMemecoinLaunchData +--- + +# getMemecoinLaunchData + +`getMemecoinLaunchData` method is used to get the launch details of the memecoin. The launch details include the team allocation, launch block number, quote token, and liquidity details of the memecoin. + +## Parameters + +- address: `string` - The address of the memecoin. + +## Returns + +`LaunchedMemecoin` object with the following properties: + +- isLaunched: `boolean` - Whether the memecoin is launched. + +If the memecoin is launched, the following properties are also returned: + +- quoteToken: `Token | undefined` - The quote token of the memecoin. +- launch - The launch details of the memecoin. + - teamAllocation: `string` - The team allocation of the memecoin. + - blockNumber: `number` - The block number at which the memecoin was launched. +- liquidity - The liquidity details of the memecoin. + + + +## Usage + +```ts +const memecoinLaunchData = await coreSdk.getMemecoinLaunchData(memecoinAddress) +``` diff --git a/packages/docs/docs/sdk/core/methods/getStandardAMMLaunchCalldata.mdx b/packages/docs/docs/sdk/core/methods/getStandardAMMLaunchCalldata.mdx new file mode 100644 index 00000000..c9a82220 --- /dev/null +++ b/packages/docs/docs/sdk/core/methods/getStandardAMMLaunchCalldata.mdx @@ -0,0 +1,37 @@ +--- +id: getStandardAMMLaunchCalldata +sidebar_position: 10 +title: getStandardAMMLaunchCalldata +--- + +# getStandardAMMLaunchCalldata + +`getStandardAMMLaunchCalldata` method is used to get the calldata for launching a deployed unruggable memecoin on Jediswap or StarkDeFi. + +## Parameters + +- memecoin: `Memecoin` - The memecoin to launch. +- data: `EkuboLaunchData` - The data required to launch the memecoin on Jediswap or StarkDeFi. + - amm: `AMM` - The AMM to use for the memecoin. + - 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. + - liquidityLockPeriod: `number` - The liquidity lock period for the memecoin in seconds. For example, 1 hour is 3600, 1 day is 86400, etc. + +## Returns + +An object with the following properties: + +- calls: `Call[]` - The calls to execute to launch the memecoin on Jediswap or StarkDeFi. + +## Usage + +```ts +const { calls } = coreSdk.getStandardAMMLaunchCalldata(data) +``` + +`calls` can now be used to execute the transaction to launch the memecoin on Jediswap or StarkDeFi. diff --git a/packages/docs/docs/sdk/core/overview.mdx b/packages/docs/docs/sdk/core/overview.mdx index d42a8655..b9233260 100644 --- a/packages/docs/docs/sdk/core/overview.mdx +++ b/packages/docs/docs/sdk/core/overview.mdx @@ -4,6 +4,54 @@ sidebar_position: 1 title: Overview --- +```mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +``` + # The Unruggable Core SDK -Lorem ipsum dolor sit amet... +The Unruggable Core SDK is a set of tools and methods that allow developers to build decentralized applications integrated with the Unruggable Meme framework. +The SDK provides a set of APIs that allow developers to interact with the tokens, retrieve token data, deploy new tokens and launch deployed tokens. + +## Getting Started + +### Installation + +To get started with the Unruggable Core SDK, you need to install the core sdk and necessary packages in your project. The SDK is available as an NPM package and can be installed using the following command: + +:::caution +Core SDK depends on starknet.js library. So you must also install starknet.js library. +::: + + + + ```bash + yarn add core starknet + ``` + + + + ```bash + npm install --save core starknet + ``` + + + +### Quick Start + +You can now create a new instance of the core sdk and start interacting with the Unruggable Meme framework. + +```js +import { Factory } from 'core' +import { constants, RpcProvider } from 'starknet' + +const provider = new RpcProvider({ + nodeUrl: 'your-node-url', +}) + +const coreSdk = new Factory({ provider, chainId: constants.StarknetChainId.SN_MAIN }) +``` + +The `coreSdk` instance can now be used to interact with the Unruggable Meme framework. +You can use the `coreSdk` instance to retrieve token data, get deployment calldata for deploying new tokens, get launch calldata for launching deployed tokens and many more. diff --git a/packages/docs/docs/sdk/core/utilities/_category_.json b/packages/docs/docs/sdk/core/utilities/_category_.json new file mode 100644 index 00000000..dd20dddf --- /dev/null +++ b/packages/docs/docs/sdk/core/utilities/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Utilities", + "position": 3, + "collapsed": true +} diff --git a/packages/docs/docs/sdk/core/utilities/getPairPrice.mdx b/packages/docs/docs/sdk/core/utilities/getPairPrice.mdx new file mode 100644 index 00000000..bb1a0bf5 --- /dev/null +++ b/packages/docs/docs/sdk/core/utilities/getPairPrice.mdx @@ -0,0 +1,35 @@ +--- +id: getPairPrice +sidebar_position: 1 +title: getPairPrice +--- + +# getPairPrice + +`getPairPrice` utility function is used to get Jediswap pair price for a given pair address and block number. + +## Parameters + +- provider: `ProviderInterface` - The provider to use for fetching the pair price. +- pair: `Pair` - An object with the following properties: + - address: `string` - The address of the pair. + - reversed: `boolean` - Whether the pair is reversed or not. +- blockNumber?: `number` - The block number to use for fetching the pair price. If not provided, the latest block number is used. + +## Returns + +`Fraction` representing the pair price at the given block number. + +## Usage + +```ts +const memecoin = await coreSdk.getMemecoin(memecoinAddress) + +const quoteTokenPriceAtLaunch = await getPairPrice( + coreSdk.config.provider, + memecoin.quoteToken.usdcPair, + memecoin.launch.blockNumber, +) +``` + +`quoteTokenPriceAtLaunch` is an instance of `Fraction` representing the pair price at the time of launch. diff --git a/packages/docs/docs/sdk/core/utilities/getStartingMarketCap.mdx b/packages/docs/docs/sdk/core/utilities/getStartingMarketCap.mdx new file mode 100644 index 00000000..9d0d176e --- /dev/null +++ b/packages/docs/docs/sdk/core/utilities/getStartingMarketCap.mdx @@ -0,0 +1,35 @@ +--- +id: getStartingMarketCap +sidebar_position: 2 +title: getStartingMarketCap +--- + +# getStartingMarketCap + +`getStartingMarketCap` utility function is used to calculate the starting market cap of a launched memecoin. + +Quote token's price at the time of launch can be fetched using the [getPairPrice](./getPairPrice) utility function. + +## Parameters + +- memecoin: `Memecoin` - The memecoin to calculate the starting market cap for. +- quoteTokenPriceAtLaunch: `Fraction` - The quote token's price at the time of launch. + +## Returns + +`Fraction` representing the starting market cap of the memecoin or `undefined` if the memecoin is not launched or the quote token is not supported. + +## Usage + +```ts +const memecoin = await coreSdk.getMemecoin(memecoinAddress) +const quoteTokenPriceAtLaunch = await getPairPrice( + coreSdk.config.provider, + memecoin.quoteToken.usdcPair, + memecoin.launch.blockNumber, +) + +const startingMarketCap = getStartingMarketCap(memecoin, quoteTokenPriceAtLaunch) +``` + +`startingMarketCap` is an instance of `Fraction` or `undefined` if the memecoin is not launched or the quote token is not supported. diff --git a/packages/docs/docs/sdk/hooks/_category_.json b/packages/docs/docs/sdk/hooks/_category_.json index 1490e89f..b5dc0508 100644 --- a/packages/docs/docs/sdk/hooks/_category_.json +++ b/packages/docs/docs/sdk/hooks/_category_.json @@ -1,5 +1,5 @@ { "label": "Hooks", - "position": 4, + "position": 2, "collapsed": true } diff --git a/packages/docs/docs/sdk/hooks/hooks/_category_.json b/packages/docs/docs/sdk/hooks/hooks/_category_.json new file mode 100644 index 00000000..0653a093 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Hooks", + "position": 3, + "collapsed": false +} diff --git a/packages/docs/docs/sdk/hooks/hooks/useBaseMemecoin.mdx b/packages/docs/docs/sdk/hooks/hooks/useBaseMemecoin.mdx new file mode 100644 index 00000000..dcb807b4 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useBaseMemecoin.mdx @@ -0,0 +1,36 @@ +--- +id: useBaseMemecoin +sidebar_position: 2 +title: useBaseMemecoin +--- + +# useBaseMemecoin + +`useBaseMemecoin` hook 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. + +## Options + +- address: `string` - The address of the memecoin. +- watch: `boolean` - If `true`, the query will automatically refetch data on every new block. Default is `false`. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +- data: `BaseMemecoin` - An 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. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + +## Usage + +```ts +import { useBaseMemecoin } from 'hooks' + +const { data: baseMemecoin } = useBaseMemecoin({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/useEkuboFees.mdx b/packages/docs/docs/sdk/hooks/hooks/useEkuboFees.mdx new file mode 100644 index 00000000..220fc5e8 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useEkuboFees.mdx @@ -0,0 +1,30 @@ +--- +id: useEkuboFees +sidebar_position: 4 +title: useEkuboFees +--- + +# useEkuboFees + +`useEkuboFees` hook is used to get the collectable fees for a memecoin launched on Ekubo. + +## Options + +- address: `string` - The address of the memecoin. +- watch: `boolean` - If `true`, the query will automatically refetch data on every new block. Default is `false`. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +- data: `Fraction | undefined` - An instance of `Fraction` or `undefined` if the memecoin is not launched on Ekubo or the quote token is not supported. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + +## Usage + +```ts +import { useEkuboFees } from 'hooks' + +const { data: ekuboFees } = useEkuboFees({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/useMemecoin.mdx b/packages/docs/docs/sdk/hooks/hooks/useMemecoin.mdx new file mode 100644 index 00000000..cbd46fd4 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useMemecoin.mdx @@ -0,0 +1,37 @@ +--- +id: useMemecoin +sidebar_position: 1 +title: useMemecoin +--- + +# useMemecoin + +`useMemecoin` hook is used to get both the [base details](./useBaseMemecoin) and the [launch data](./useMemecoinLaunch) of the memecoin. + +## Options + +- address: `string` - The address of the memecoin. +- watch: `boolean` - If `true`, the query will automatically refetch data on every new block. Default is `false`. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +- data: `Memecoin` - Memecoin object which is a combination of the [BaseMemecoin](./useBaseMemecoin) and [LaunchedMemecoin](./useMemecoinLaunch) objects. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + + + +## Usage + +```ts +import { useMemecoin } from 'hooks' + +const { data: memecoin } = useMemecoin({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/useMemecoinLaunch.mdx b/packages/docs/docs/sdk/hooks/hooks/useMemecoinLaunch.mdx new file mode 100644 index 00000000..503ebdab --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useMemecoinLaunch.mdx @@ -0,0 +1,47 @@ +--- +id: useMemecoinLaunch +sidebar_position: 3 +title: useMemecoinLaunch +--- + +# useMemecoinLaunch + +`useMemecoinLaunch` hook is used to get the launch details of the memecoin. The launch details include the team allocation, launch block number, quote token, and liquidity details of the memecoin. + +## Options + +- address: `string` - The address of the memecoin. +- watch: `boolean` - If `true`, the query will automatically refetch data on every new block. Default is `false`. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +- data: `LaunchedMemecoin` - An object with the following properties: + + - isLaunched: `boolean` - Whether the memecoin is launched. + + If the memecoin is launched, the following properties are also returned: + + - quoteToken: `Token | undefined` - The quote token of the memecoin. + - launch - The launch details of the memecoin. + - teamAllocation: `string` - The team allocation of the memecoin. + - blockNumber: `number` - The block number at which the memecoin was launched. + - liquidity - The liquidity details of the memecoin. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + + + +## Usage + +```ts +import { useMemecoinLaunch } from 'hooks' + +const { data: memecoinLaunch } = useMemecoinLaunch({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/usePairPrice.mdx b/packages/docs/docs/sdk/hooks/hooks/usePairPrice.mdx new file mode 100644 index 00000000..730c6990 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/usePairPrice.mdx @@ -0,0 +1,32 @@ +--- +id: usePairPrice +sidebar_position: 6 +title: usePairPrice +--- + +# usePairPrice + +`usePairPrice` hook is used to get Jediswap pair price for a given pair address and block number. + +## Options + +- pair: `Pair` - An object with the following properties: + - address: `string` - The address of the pair. + - reversed: `boolean` - Whether the pair is reversed or not. +- blockNumber?: `number` - The block number to use for fetching the pair price. If not provided, the latest block number is used. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +- data: `Fraction` - An instance of `Fraction`. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + +## Usage + +```ts +import { usePairPrice } from 'hooks' + +const { data: pairPrice } = usePairPrice({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/useQuoteToken.mdx b/packages/docs/docs/sdk/hooks/hooks/useQuoteToken.mdx new file mode 100644 index 00000000..b56cb0c3 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useQuoteToken.mdx @@ -0,0 +1,34 @@ +--- +id: useQuoteToken +sidebar_position: 5 +title: useQuoteToken +--- + +# useQuoteToken + +`useQuoteToken` hook is used to get Token object from the quote token address. + +## Parameters + +- address: `string` - The address of the quote token. + +## Returns + +`Token` object with the following properties: + +- address: `string` - The address of the quote token. +- symbol: `string` - The symbol of the quote token. +- name: `string` - The name of the quote token. +- decimals: `number` - The number of decimals of the quote token. +- camelCased: `boolean` - Whether the quote token contract uses camelCased function names or not. +- usdcPair?: `Pair` - The USDC Jediswap pair of the quote token. + - address: `string` - The address of the pair. + - reversed: `boolean` - Whether the pair is reversed or not. + +## Usage + +```ts +import { useQuoteToken } from 'hooks' + +const quoteToken = useQuoteToken(quoteTokenAddress) +``` diff --git a/packages/docs/docs/sdk/hooks/hooks/useQuoteTokenPrice.mdx b/packages/docs/docs/sdk/hooks/hooks/useQuoteTokenPrice.mdx new file mode 100644 index 00000000..783b2c30 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/hooks/useQuoteTokenPrice.mdx @@ -0,0 +1,30 @@ +--- +id: useQuoteTokenPrice +sidebar_position: 7 +title: useQuoteTokenPrice +--- + +# useQuoteTokenPrice + +`useQuoteTokenPrice` hook is used to get Jediswap pair price of a quote token. + +## Options + +- address: `string` - The address of the quote token. +- blockNumber?: `number` - The block number to use for fetching the pair price. If not provided, the latest block number is used. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the options. + +## Returns + +An instance of `Fraction` or `undefined` if the quote token is not supported. + +Please take a look at the [TanStack Query](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) documentation for more information on the return values. + +## Usage + +```ts +import { useQuoteTokenPrice } from 'hooks' + +const { data: quoteTokenPrice } = useQuoteTokenPrice({ address: memecoinAddress }) +``` diff --git a/packages/docs/docs/sdk/hooks/overview.mdx b/packages/docs/docs/sdk/hooks/overview.mdx index 2c398f46..83bde9f5 100644 --- a/packages/docs/docs/sdk/hooks/overview.mdx +++ b/packages/docs/docs/sdk/hooks/overview.mdx @@ -4,6 +4,60 @@ sidebar_position: 1 title: Overview --- +```mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +``` + # React Hooks -Lorem ipsum dolor sit amet... +React Hooks are built on top of the Unruggable Core SDK. It provides set of tools and hooks to allow developers to build decentralized applications integrated with the Unruggable Meme framework. + +## Getting Started + +### Installation + +To get started with the hooks, you need to install the hooks, core sdk and necessary packages in your project. The Hooks SDK is available as an NPM package and can be installed using the following command: + +:::caution +Hooks package depends on the core sdk, starknet.js and Starknet React libraries. So you must also install core, starknet.js and @starknet-react/core libraries. +::: + + + + ```bash + yarn add hooks core starknet @starknet-react/core + ``` + + + + ```bash + npm install --save hooks core starknet @starknet-react/core + ``` + + + +### Quick Start + +You can now wrap your application with the `Provider` and start interacting with the Unruggable Meme framework. + +:::caution +Hooks Provider must come after the Starknet React Provider. +::: + +```ts +import { StarknetConfig } from '@starknet-react/core' +import { Provider as HooksProvider } from 'hooks' + +const App = () => { + return ( + + + + + + ) +} +``` + +You can now start using the hooks in your application. diff --git a/packages/docs/docs/sdk/hooks/provider.mdx b/packages/docs/docs/sdk/hooks/provider.mdx new file mode 100644 index 00000000..a8a7d1e8 --- /dev/null +++ b/packages/docs/docs/sdk/hooks/provider.mdx @@ -0,0 +1,55 @@ +--- +id: provider +sidebar_position: 2 +title: Provider +--- + +# Provider + +The `Provider` is a React component that wraps your application and provides the necessary context to the hooks to interact with the Unruggable Meme framework. + +## Props + +If both `factory` and `provider` props are not provided, the hooks will use the default provider interface. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
factoryFactory + The core sdk Factory instance to use in the hooks. + If the factory client is provided, the `provider` prop will be ignored. + No
providerProviderInterface + Provider Interface to use if the `factory` prop is not provided. + No
queryClientQueryClient + React-query client to use. If not provided and there is no React Query instance, a new query client will be created. + No
diff --git a/packages/hooks/src/hooks/useBaseMemecoin.ts b/packages/hooks/src/hooks/useBaseMemecoin.ts index e9b7ccbf..e9ecaa2d 100644 --- a/packages/hooks/src/hooks/useBaseMemecoin.ts +++ b/packages/hooks/src/hooks/useBaseMemecoin.ts @@ -6,9 +6,13 @@ import { useQuery } from './internal/useQuery' import { useFactory } from './useFactory' export type UseBaseMemecoinProps = UseQueryProps & { + /** The address of the memecoin */ address?: string } +/** + * Get a memecoin's base details. This includes the memecoin's name, symbol, owner, decimals, and total supply. + */ export function useBaseMemecoin({ address, ...props diff --git a/packages/hooks/src/hooks/useEkuboFees.ts b/packages/hooks/src/hooks/useEkuboFees.ts index ebd241a0..9622137a 100644 --- a/packages/hooks/src/hooks/useEkuboFees.ts +++ b/packages/hooks/src/hooks/useEkuboFees.ts @@ -7,9 +7,13 @@ import { useFactory } from './useFactory' import { useMemecoin } from './useMemecoin' export interface UseEkuboFeesProps extends UseQueryProps { + /** The address of the memecoin */ address?: string } +/** + * Get the collectable ekubo fees for a memecoin. + */ export function useEkuboFees({ address, ...props diff --git a/packages/hooks/src/hooks/useMemecoin.ts b/packages/hooks/src/hooks/useMemecoin.ts index 8f95e4ae..2e45d401 100644 --- a/packages/hooks/src/hooks/useMemecoin.ts +++ b/packages/hooks/src/hooks/useMemecoin.ts @@ -6,9 +6,13 @@ import { useQuery } from './internal/useQuery' import { useFactory } from './useFactory' export type UseMemecoinProps = UseQueryProps & { + /** The address of the memecoin */ address?: string } +/** + * Get a memecoin. Returns the results of both `getBaseMemecoin` and `getMemecoinLaunchData`. + */ export function useMemecoin({ address, ...props diff --git a/packages/hooks/src/hooks/useMemecoinLaunch.ts b/packages/hooks/src/hooks/useMemecoinLaunch.ts index 43e3188d..4a32c16c 100644 --- a/packages/hooks/src/hooks/useMemecoinLaunch.ts +++ b/packages/hooks/src/hooks/useMemecoinLaunch.ts @@ -6,9 +6,13 @@ import { useQuery } from './internal/useQuery' import { useFactory } from './useFactory' export type UseMemecoinLaunchProps = UseQueryProps & { + /** The address of the memecoin */ address?: string } +/** + * Get a memecoin's launch details. This includes the memecoin's quote token, team allocations, and liquidity. + */ export function useMemecoinLaunch({ address, ...props