Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wen-moon-ser/moonshot-sdk-evm

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wen-moon-ser/moonshot-sdk-evm

Moonshot SDK for EVM helps calculate moonshot token prices at any point in the bonding curve. The package also allows the users to generate buy and sell transactions, provide the slippage amount and fix it to a trading side.

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@wen-moon-ser/moonshot-sdk-evm

Moonshot SDK for EVM helps calculate moonshot token prices at any point in the bonding curve. The package also allows the users to generate buy and sell transactions, provide the slippage amount and fix it to a trading side.

By Following the example you can create your high-performance trading bot within minutes.

npm link

Installation

Install the package using yarn or npm

npm i @wen-moon-ser/moonshot-sdk-evm
# or
yarn add @wen-moon-ser/moonshot-sdk-evm

Buy example

import { Wallet } from 'ethers';
import { JsonRpcProvider } from 'ethers';
import { Moonshot, Token, FixedSide, Environment } from '@wen-moon-ser/moonshot-sdk-evm';

export const buyTx = async (): Promise<void> => {
  console.log('--- Buying token example ---');

  const rpcUrl = 'https://base-sepolia.gateway.tenderly.co';

  const provider = new JsonRpcProvider(rpcUrl);
  const signer = new Wallet('private key', provider);

  const moonshot = new Moonshot({
      signer: signer,
      env: Environment.TESTNET,
  });

  const token = await Token.create({
    tokenAddress: '0x1234567890123456789012345678901234567890',
    moonshot,
  });

  const tokenAmount = 10000n * 10n ** 18n; // Buy 10k tokens
  const collateralAmount = await token.getCollateralAmountByTokens({
    tokenAmount,
    tradeDirection: 'BUY',
  });

  const tx = await token.prepareTx({
    slippageBps: 500,
    tokenAmount,
    collateralAmount,
    tradeDirection: 'BUY',
    fixedSide: FixedSide.OUT,
  });
  tx.from = await signer.getAddress();

  const gas = await provider.estimateGas(tx);
  const feeData = await provider.getFeeData();

  tx.gasLimit = gas;
  tx.gasPrice = feeData.gasPrice!;

  const txHash = await signer.sendTransaction(tx);
  console.log('Transaction hash:', txHash);
};

Sell example

import { Wallet } from 'ethers';
import { JsonRpcProvider } from 'ethers';
import { Moonshot, Token, FixedSide } from '@wen-moon-ser/moonshot-sdk-evm';

export const buyTx = async (): Promise<void> => {
  console.log('--- Buying token example ---');

  const rpcUrl = 'https://base-sepolia.gateway.tenderly.co'

  const provider = new JsonRpcProvider(rpcUrl);
  const signer = new Wallet('private key', provider);

  const moonshot = new Moonshot({
      signer: signer,
      env: Environment.TESTNET,
  });

  const token = await Token.create({
    tokenAddress: '0x1234567890123456789012345678901234567890',
    moonshot,
  });

  const tokenAmount = 10000n * 10n ** 18n; // Buy 10k tokens
  const collateralAmount = await token.getCollateralAmountByTokens({
    tokenAmount,
    tradeDirection: 'SELL',
  });

  const tx = await token.prepareTx({
    slippageBps: 500,
    tokenAmount,
    collateralAmount,
    tradeDirection: 'SELL',
    fixedSide: FixedSide.OUT,
  });

  tx.from = await signer.getAddress();

  const gas = await provider.estimateGas(tx);
  const feeData = await provider.getFeeData();

  tx.gasLimit = gas;
  tx.gasPrice = feeData.gasPrice!;

  const txHash = await signer.sendTransaction(tx);
  console.log('Transaction hash:', txHash);
};

FAQs

Package last updated on 08 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc