Skip to content
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
10 changes: 5 additions & 5 deletions sdk/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface LaunchTokenParams {
name: string; // Token name
symbol: string; // Token symbol
supply: string; // Total supply (in wei format)
wallet: Wallet; // Ethers.js Wallet instance
client: Client; // Viem Client
initialTick?: number; // Initial tick (price setting)
creator?: string; // Creator address (defaults to wallet address)
transactionOptions?: { // Optional gas parameters
Expand All @@ -109,7 +109,7 @@ interface LaunchTokenParams {

```typescript
interface LaunchTokenResponse {
transaction: TransactionResponse; // Ethers.js TransactionResponse
transaction: Transaction; // Viem Transaction
tokenUri: string; // Token URI
tokenAddress: string; // Deployed token contract address
}
Expand All @@ -122,7 +122,7 @@ const result = await TokenLauncher.launchToken({
name: 'My Token',
symbol: 'MTK',
supply: '1000000000000000000000000', // 1 million tokens (with 18 decimals)
wallet: wallet,
client: client,
initialTick: 0,
logoUrl: 'https://example.com/logo.png',
description: 'My awesome community token',
Expand Down Expand Up @@ -154,7 +154,7 @@ const result = await TokenLauncher.launchTokenAndBuy({
name: 'My Token',
symbol: 'MTK',
supply: '1000000000000000000000000',
wallet: wallet,
client: client,
initialTick: 0,
logoUrl: 'https://example.com/logo.png',
amountIn: '100000000000000000', // 0.1 ETH
Expand All @@ -177,7 +177,7 @@ Calculates the initial tick value based on the desired token price.
**Example:**

```typescript
import { parseEther } from 'ethers/lib/utils';
import { parseEther } from 'viem';

// For a token price of 0.0001 ETH
const tokenPrice = parseEther('0.0001');
Expand Down
31 changes: 18 additions & 13 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ TokenLauncher.configure({
// For development environment
API_URL_DEV: 'https://dev-api.example.com',
API_KEY_DEV: 'your-dev-api-key',

// For production environment
API_URL_PROD: 'https://api.example.com',
API_KEY_PROD: 'your-production-api-key',

// Set environment mode
MODE: 'production', // 'development' | 'production' | 'jest'
});
Expand All @@ -50,18 +50,23 @@ TokenLauncher.configure({

```typescript
import { TokenLauncher, LaunchTokenParams } from '@rainbow-me/token-launcher';
import { Wallet, JsonRpcProvider } from 'ethers';

// Create a wallet instance
const provider = new JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_KEY');
const wallet = new Wallet('YOUR_PRIVATE_KEY', provider);
import { createClient, privateKeyToAccount } from 'viem';
import { mainnet } from 'viem/chains';
import { http } from 'viem/transports';

// Create a Viem client
const client = createClient({
account: privateKeyToAccount('YOUR_PRIVATE_KEY'),
chain: mainnet,
transport: http(),
});

// Define token parameters
const launchParams: LaunchTokenParams = {
name: 'My Token',
symbol: 'MTK',
supply: '1000000000000000000000000', // 1 million tokens with 18 decimals
wallet: wallet,
client: client,
initialTick: 0, // Use getInitialTick for price-based ticks
logoUrl: 'https://example.com/logo.png',
description: 'My awesome token for my community',
Expand All @@ -88,20 +93,20 @@ try {

```typescript
import { TokenLauncher, LaunchTokenAndBuyParams } from '@rainbow-me/token-launcher';
import { parseEther } from 'ethers/lib/utils';
import { parseEther } from 'viem';

const launchAndBuyParams: LaunchTokenAndBuyParams = {
// Include all parameters from LaunchTokenParams
name: 'My Token',
symbol: 'MTK',
supply: '1000000000000000000000000', // 1 million tokens with 18 decimals
wallet: wallet,
client: client,
initialTick: 0,
logoUrl: 'https://example.com/logo.png',

// Add the amount of ETH to use for buying
amountIn: parseEther('0.1').toString(), // 0.1 ETH

// Optional gas parameters
transactionOptions: {
gasLimit: '3000000',
Expand All @@ -126,7 +131,7 @@ try {

```typescript
import { TokenLauncher } from '@rainbow-me/token-launcher';
import { parseEther } from 'ethers/lib/utils';
import { parseEther } from 'viem';

// Calculate the initial tick based on desired token price
const tokenPriceInETH = parseEther('0.0001'); // 0.0001 ETH per token
Expand Down
22 changes: 4 additions & 18 deletions sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,14 @@
"eslint-plugin-jest": "^27.9.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"typescript": "^4.4.4"
"typescript": "^5.8.2"
},
"dependencies": {
"@ethereumjs/util": "9.0.0",
"@ethersproject/abi": "5.7.0",
"@ethersproject/abstract-signer": "5.7.0",
"@ethersproject/bignumber": "5.7.0",
"@ethersproject/bytes": "5.7.0",
"@ethersproject/contracts": "5.7.0",
"@ethersproject/keccak256": "5.7.0",
"@ethersproject/providers": "5.7.0",
"@ethersproject/random": "5.7.0",
"@ethersproject/solidity": "5.7.0",
"@ethersproject/strings": "5.7.0",
"@ethersproject/transactions": "5.7.0",
"@ethersproject/units": "5.7.0",
"@ethersproject/wallet": "5.7.0",
"@metamask/eth-sig-util": "7.0.0",
"decimal.js": "^10.5.0",
"jsbi": "^4.3.0",
"tiny-invariant": "^1.3.3",
"eslint-config-rainbow": "4.3.0",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"viem": "^2"
},
"author": "Christopher Howard",
"files": [
Expand All @@ -60,6 +45,7 @@
"pretest": "grep -v '^IS_TESTING=' .env > .env.tmp 2>/dev/null || true; echo 'IS_TESTING=true' >> .env.tmp; mv .env.tmp .env",
"test": "./scripts/test.sh",
"lint": "eslint 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"types": "tsc --noEmit",
"format:check": "prettier --check '**/*.{js,ts,json,md}'",
"format:fix": "prettier --write '**/*.{js,ts,json,md}'",
"clean": "rm -rf dist"
Expand Down
8 changes: 3 additions & 5 deletions sdk/src/getInitialTick.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { parseUnits } from 'viem';
import { priceToInitialTick } from './utils/tickMath';
import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
import { parseUnits } from '@ethersproject/units';

const TICK_SPACING = 200;

Expand All @@ -10,8 +9,7 @@ const TICK_SPACING = 200;
* @param tokenPrice The token’s price in ETH (for example, "0.000035" or 1, 2, 0.5, etc.)
* @returns The nearest valid tick.
*/
export function getInitialTick(tokenPrice: BigNumberish): number {
const scaledPrice =
typeof tokenPrice === 'string' ? parseUnits(tokenPrice, 18) : BigNumber.from(tokenPrice);
export function getInitialTick(tokenPrice: string | bigint): number {
const scaledPrice = typeof tokenPrice === 'string' ? parseUnits(tokenPrice, 18) : tokenPrice;
return priceToInitialTick(scaledPrice, TICK_SPACING);
}
3 changes: 1 addition & 2 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from './types';
import { launchRainbowSuperToken, launchRainbowSuperTokenAndBuy } from './launchToken';
import { getAirdropSuggestions, getRainbowSuperTokenByUri, getRainbowSuperTokens } from './api';
import { BigNumber } from '@ethersproject/bignumber';
import { getInitialTick } from './getInitialTick';

class TokenLauncherSDK {
Expand All @@ -31,7 +30,7 @@ class TokenLauncherSDK {
return { ...this.config };
}

public getInitialTick(tokenPrice: BigNumber): number {
public getInitialTick(tokenPrice: bigint): number {
return getInitialTick(tokenPrice);
}

Expand Down
Loading