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: replace unruggable-core with unruggable-sdk #450

Merged
merged 10 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions packages/plugin-starknet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"@ai16z/plugin-trustdb": "workspace:*",
"@avnu/avnu-sdk": "^2.1.1",
"@uniswap/sdk-core": "^6.0.0",
"@unruggable_starknet/core": "^0.1.0",
"starknet": "^6.17.0",
"unruggable-sdk": "^1.4.0",
"starknet": "^6.18.0",
"tsup": "^8.3.5",
"vitest": "^2.1.4"
},
Expand Down
122 changes: 56 additions & 66 deletions packages/plugin-starknet/src/actions/unruggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@ import {
State,
type Action,
} from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateObject } from "@ai16z/eliza";
import { Percent } from "@uniswap/sdk-core";
import { composeContext, generateObject } from "@ai16z/eliza";
import { createMemecoin, launchOnEkubo } from "unruggable-sdk";
import { constants } from "starknet";

import {
getStarknetAccount,
getStarknetProvider,
parseFormatedAmount,
parseFormatedPercentage,
validateSettings,
} from "../utils/index.ts";
import { DeployData, Factory } from "@unruggable_starknet/core";
import {
AMM,
EKUBO_TICK_SPACING,
LiquidityType,
QUOTE_TOKEN_SYMBOL,
RECOMMENDED_EKUBO_FEES,
} from "@unruggable_starknet/core/constants";
import { ACCOUNTS, TOKENS } from "../utils/constants.ts";
import { Percent } from "@uniswap/sdk-core";

interface SwapContent {
sellTokenAddress: string;
buyTokenAddress: string;
sellAmount: string;
}

export function isDeployTokenContent(
content: DeployData
): content is DeployData {
interface DeployTokenContent {
name: string;
symbol: string;
owner: string;
initialSupply: string;
}

export function isDeployTokenContent(content: DeployTokenContent) {
// Validate types
const validTypes =
typeof content.name === "string" &&
Expand Down Expand Up @@ -127,77 +132,62 @@ export const deployToken: Action = {
const provider = getStarknetProvider(runtime);
const account = getStarknetAccount(runtime);

const factory = new Factory({
provider,
chainId: await provider.getChainId(),
});
const chainId = await provider.getChainId();
const config = {
starknetChainId: chainId,
starknetProvider: provider,
};

const { tokenAddress, calls: deployCalls } =
factory.getDeployCalldata({
name: response.name,
symbol: response.symbol,
owner: response.owner,
initialSupply: response.initialSupply,
});

const data = await factory.getMemecoinLaunchData(tokenAddress);

const { calls: launchCalls } = await factory.getEkuboLaunchCalldata(
const { tokenAddress, transactionHash } = await createMemecoin(
config,
{
address: tokenAddress,
name: response.name,
symbol: response.symbol,
owner: response.owner,
totalSupply: response.initialSupply,
decimals: 18,
...data,
},
{
fees: parseFormatedPercentage("3"),
amm: AMM.EKUBO,
teamAllocations: [
{
address: ACCOUNTS.ELIZA,
amount: new Percent(
2.5,
response.initialSupply
).toFixed(0),
},
{
address: ACCOUNTS.BLOBERT,
amount: new Percent(
2.5,
response.initialSupply
).toFixed(0),
},
],
holdLimit: parseFormatedPercentage("2"),
antiBotPeriod: 3600,
quoteToken: {
address: TOKENS.LORDS,
symbol: "LORDS" as QUOTE_TOKEN_SYMBOL,
name: "Lords",
decimals: 18,
camelCased: false,
},
startingMarketCap: parseFormatedAmount("5000"),
initialSupply: response.initialSupply,
starknetAccount: account,
}
);

elizaLogger.log(
"Deployment has been initiated for coin: " +
"Token deployment initiated for: " +
response.name +
" at address: " +
tokenAddress
);
const tx = await account.execute([...deployCalls, ...launchCalls]);

await launchOnEkubo(config, {
antiBotPeriodInSecs: 3600,
currencyAddress: TOKENS.LORDS,
fees: "3",
holdLimit: "2",
memecoinAddress: tokenAddress,
starknetAccount: account,
startingMarketCap: "5000",
odilitime marked this conversation as resolved.
Show resolved Hide resolved
teamAllocations: [
{
address: ACCOUNTS.ELIZA,
amount: new Percent(
2.5,
response.initialSupply
).toFixed(0),
},
{
address: ACCOUNTS.BLOBERT,
amount: new Percent(
2.5,
response.initialSupply
).toFixed(0),
},
],
odilitime marked this conversation as resolved.
Show resolved Hide resolved
});

callback?.({
text:
"Token Deployment completed successfully!" +
response.symbol +
" deployed in tx: " +
tx.transaction_hash,
transactionHash,
});

return true;
Expand Down
45 changes: 29 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading