-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): add typescript SDK for memecoin creation (#285)
This PR introduces a new TypeScript SDK package that enables programmatic interaction with the Unruggable Meme on-chain factory on Starknet. The SDK is designed to simplify memecoin creation. NPM Package: https://www.npmjs.com/package/unruggable-sdk Related Issue: #278
- Loading branch information
Showing
16 changed files
with
559 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ACCOUNT_ADDRESS= | ||
ACCOUNT_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Unruggable SDK | ||
|
||
A TypeScript SDK for creating and managing Unruggable Memecoins on Starknet. This SDK provides a simple interface for deploying memecoin tokens and launching them on various AMMs. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install unruggable-sdk | ||
# or | ||
yarn add unruggable-sdk | ||
``` | ||
|
||
## Features | ||
|
||
- Create new memecoin tokens | ||
- Launch tokens on Ekubo AMM | ||
- Launch tokens on Standard AMM (JediSwap) | ||
- Collect Ekubo fees | ||
- Built-in address validation and amount normalization | ||
- TypeScript support with comprehensive type definitions | ||
|
||
## Quick start | ||
|
||
```typescript | ||
import { createMemecoin, launchOnEkubo } from 'unruggable-sdk'; | ||
import { constants } from "starknet"; | ||
|
||
// Configure the SDK | ||
const config = { | ||
starknetProvider: yourProvider, | ||
starknetChainId: constants.StarknetChainId.SN_MAIN, | ||
}; | ||
|
||
// Create a new memecoin | ||
const createResult = await createMemecoin(config, { | ||
name: 'My Memecoin', | ||
symbol: 'MMC', | ||
initialSupply: '1000000000', | ||
owner: ownerAddress, | ||
starknetAccount: account, | ||
}); | ||
|
||
// Launch on Ekubo | ||
const launchResult = await launchOnEkubo(config, { | ||
memecoinAddress: createResult.tokenAddress, | ||
currencyAddress: ethAddress, | ||
startingMarketCap: '1000000', | ||
fees: '3.5', | ||
holdLimit: '2.5', | ||
antiBotPeriodInSecs: 300, | ||
starknetAccount: account, | ||
}); | ||
``` | ||
|
||
## API Reference | ||
|
||
### Configuration | ||
|
||
The SDK requires a configuration object with the following properties: | ||
|
||
```typescript | ||
interface Config { | ||
starknetProvider: any; // Your Starknet provider | ||
starknetChainId: string; // Starknet chain ID | ||
} | ||
``` | ||
|
||
### Functions | ||
#### createMemecoin | ||
Creates a new memecoin token on Starknet. | ||
|
||
```typescript | ||
async function createMemecoin( | ||
config: Config, | ||
parameters: { | ||
name: string; | ||
symbol: string; | ||
initialSupply: string; | ||
owner: string; | ||
starknetAccount: any; | ||
} | ||
): Promise<{ | ||
transactionHash: string; | ||
tokenAddress: string; | ||
}>; | ||
``` | ||
|
||
#### launchOnEkubo | ||
Launches a memecoin on the Ekubo AMM. | ||
|
||
```typescript | ||
async function launchOnEkubo( | ||
config: Config, | ||
parameters: { | ||
memecoinAddress: string; | ||
currencyAddress: string; | ||
startingMarketCap: string; | ||
fees: string; | ||
holdLimit: string; | ||
antiBotPeriodInSecs: number; | ||
starknetAccount: any; | ||
} | ||
): Promise<{ | ||
transactionHash: string; | ||
}>; | ||
``` | ||
|
||
#### launchOnStandardAMM | ||
Launches a memecoin on JediSwap or StarkDefi | ||
|
||
```typescript | ||
async function launchOnStandardAMM( | ||
config: Config, | ||
parameters: { | ||
memecoinAddress: string; | ||
currencyAddress: string; | ||
startingMarketCap: string; | ||
holdLimit: string; | ||
antiBotPeriodInSecs: number; | ||
liquidityLockPeriod: number; | ||
starknetAccount: any; | ||
} | ||
): Promise<{ | ||
transactionHash: string; | ||
}>; | ||
``` | ||
|
||
#### collectEkuboFees | ||
Collects accumulated fees from Ekubo pool. | ||
|
||
```typescript | ||
async function collectEkuboFees( | ||
config: Config, | ||
parameters: { | ||
memecoinAddress: string; | ||
starknetAccount: any; | ||
} | ||
): Promise<{ | ||
transactionHash: string; | ||
} | null>; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ['../../.eslintrc.js', '@uniswap/eslint-config/node'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { createMemecoin, Config, launchOnEkubo } from '../src' | ||
import { RpcProvider, Account, constants } from 'starknet' | ||
import { ETH_ADDRESSES } from 'core/constants' | ||
;(async () => { | ||
const starknetProvider = new RpcProvider({ nodeUrl: 'https://starknet-mainnet.public.blastapi.io' }) | ||
|
||
const starknetChainId = constants.StarknetChainId.SN_MAIN | ||
|
||
const config: Config = { | ||
starknetProvider, | ||
starknetChainId, | ||
} | ||
|
||
const starknetAccount = new Account( | ||
starknetProvider, | ||
process.env.ACCOUNT_ADDRESS || '', | ||
process.env.ACCOUNT_PRIVATE_KEY || '', | ||
) | ||
|
||
const result = await createMemecoin(config, { | ||
initialSupply: '1', | ||
name: 'R5MI', | ||
owner: '0x0416ba0f3d21eda5a87d05d0acc827075792132697e9ed973f4390808790a11a', | ||
starknetAccount, | ||
symbol: 'R5MI', | ||
}) | ||
|
||
if (result) { | ||
const { tokenAddress, transactionHash } = result | ||
console.log(`Creating memecoin... Transaction hash: ${transactionHash} - Token Address: ${tokenAddress}`) | ||
await starknetProvider.waitForTransaction(transactionHash) | ||
|
||
const launchResult = await launchOnEkubo(config, { | ||
memecoinAddress: tokenAddress, | ||
starknetAccount, | ||
antiBotPeriodInSecs: 0, | ||
fees: '0.3', | ||
holdLimit: '1', | ||
startingMarketCap: '100000', | ||
currencyAddress: ETH_ADDRESSES[starknetChainId], | ||
teamAllocations: [], | ||
}) | ||
|
||
if (launchResult) { | ||
console.log(`Launching on Ekubo... Transaction hash: ${launchResult.transactionHash}`) | ||
} | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "unruggable-sdk", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.mjs", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/keep-starknet-strange/unruggable.meme.git" | ||
}, | ||
"homepage": "https://www.unruggable.meme/", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js", | ||
"browser": "./dist/index.global.js", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"example": "yarn with-env tsx ./examples/create.ts", | ||
"with-env": "dotenv -e .env --", | ||
"start": "tsup --watch", | ||
"build": "tsup --clean true", | ||
"test": "vitest run", | ||
"test:watch": "vitest watch", | ||
"lint": "eslint . --max-warnings=0 --ignore-path ../../.eslintignore", | ||
"lint:fix": "eslint src --fix", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"dependencies": { | ||
"@uniswap/sdk-core": "^4.2.0", | ||
"core": "*", | ||
"moment": "^2.30.1", | ||
"starknet": "6.11.0" | ||
}, | ||
"peerDependencies": { | ||
"starknet": ">=5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@uniswap/eslint-config": "^1.2.0", | ||
"dotenv-cli": "^7.4.3", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"prettier": "^3.2.5", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const PERCENTAGE_INPUT_PRECISION = 2 | ||
|
||
export const STARKNET_MAX_BLOCK_TIME = 3600 * 2 // 2h |
Oops, something went wrong.