Skip to main content

⛽️ GasPump Python SDK

High-level overview of trading on GasPump

When a token is deployed, it immediately becomes tradable using a bonding curve. When it collects the hardcap (currently 1000 TON), liquidity is automatically deposited to DeDust.

There are 2 phases of the token lifecycle:

  1. Bonding Curve

    • During this phase, the token is tradable using the bonding curve formula.
    • Users can buy and sell tokens.
    • Users trade wrapped tokens ($gasXXX).
  2. DEX (DeDust)

    • Before trading on DeDust, users need to unwrap their $gasXXX and get $XXX tokens.
    • Unwrapping is performed 1:1.
    • Unwrapping is required so that nobody can create (and break) a liquidity pool before the hardcap is reached.

Features

  • SDK for GasPump smart contract interactions
  • (soon) SDK for GasPump API

Installation

pip install gaspump

Usage

Here's a quick buy and sell example of how to use the GasPump Python SDK:

import asyncio

from pytoniq import LiteBalancer, WalletV4R2
from pytoniq_core import Address

from gaspump import GaspumpJetton
from gaspump import JettonWallet
from gaspump import calc_buy_ton_amount, wait_until_contract_is_deployed, wait_until_wallet_seqno_changes


async def main():
    jetton_address = Address(input("Enter the jetton master of gaspump token: "))
    wallet_mnemonics = input("Enter the wallet mnemonic via whitespaces 'we, ate, spoon, ...': ")

    wallet_mnemonic_list = wallet_mnemonics.split(" ")

    async with LiteBalancer.from_mainnet_config(trust_level=2, timeout=15) as client:
        wallet = await WalletV4R2.from_mnemonic(client, wallet_mnemonic_list)

        # setup contracts
        gaspump_jetton = GaspumpJetton(jetton_address)

        jetton_wallet_address = await gaspump_jetton.get_jetton_wallet_address(client, wallet.address)
        jetton_wallet = JettonWallet(jetton_wallet_address)

        # buy some jettons
        ton_amount = 300000000  # 0.3 TON
        buy_ton_amount = calc_buy_ton_amount(ton_amount)

        estimated_jetton_amount = await gaspump_jetton.get_estimate_buy_jetton_amount(client, buy_ton_amount)

        print(f"Buying for 0.3 TON...")
        seqno = await wallet.get_seqno()
        await gaspump_jetton.send_buy(wallet, buy_ton_amount, do_check_trade_state=True)
        await wait_until_wallet_seqno_changes(wallet, seqno)

        # check the balance
        await wait_until_contract_is_deployed(jetton_wallet.address, client)

        balance = await jetton_wallet.get_balance(client)
        print(f"✅ Successfully bought {balance / 1e9} jettons (estimated: {estimated_jetton_amount / 1e9})")

        # sell all the jettons
        print(f"Selling all {balance / 1e9} jettons...")

        seqno = await wallet.get_seqno()
        await gaspump_jetton.send_sell(wallet, balance, jetton_wallet, do_check_trade_state=True)
        await wait_until_wallet_seqno_changes(wallet, seqno)

        print(f"✅ Successfully sold {balance / 1e9} jettons")


if __name__ == "__main__":
    asyncio.run(main())

Metadata

Release files for gaspump 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gaspump 1.0.0
File Size Uploaded
gaspump-1.0.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gaspump 1.0.0
File Interpreter ABI Platform
gaspump-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / gaspump-1.0.0.tar.gz

Download URL gaspump-1.0.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe80e94fe57a688fc7229edbc6e897b8371918553a90ce7aa630fd360d58d11a
BLAKE2b-256 checksum
How to use checksums
673c92febc67a3675344e92e45e3b3ef30e8939d7f8d899cc3d0a06df9389891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.11 Windows/10

Release files / gaspump-1.0.0-py3-none-any.whl

Download URL gaspump-1.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ca73ad9dfbba547a997d63fd46bdfb844bbcfe74c0f117e65430946881b9ce2
BLAKE2b-256 checksum
How to use checksums
ebd65be0d9409f7709d94880e663a849a390ccb1a17f6fd71d6340b566cb975e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.11 Windows/10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page