Tinyman Python SDK

Overview

tinyman-py-sdk

Tinyman Python SDK

Design Goal

This SDK is designed for automated interaction with the Tinyman AMM. It will be most useful for developers who wish to create automated trading programs/bots. It may also be useful to create an alternative UI but that is not a design goal of this library. It is designed to be reasonably low level so that pieces can be used in isolation.

Status

This SDK is currently under active early development and should not be considered stable.

Installation

tinyman-py-sdk is not yet released on PYPI. It can be installed directly from this repository with pip:

pip install git+https://github.com/tinymanorg/tinyman-py-sdk.git

Sneak Preview

from tinyman.v1.client import TinymanTestnetClient

client = TinymanTestnetClient()

# Fetch our two assets of interest
TINYUSDC = client.fetch_asset(21582668)
ALGO = client.fetch_asset(0)

# Fetch the pool we will work with
pool = client.fetch_pool(TINYUSDC, ALGO)

# Get a quote for a swap of 1 ALGO to TINYUSDC with 1% slippage tolerance
quote = pool.fetch_fixed_input_swap_quote(ALGO(1_000_000), slippage=0.01)
print(quote)
print(f'TINYUSDC per ALGO: {quote.price}')
print(f'TINYUSDC per ALGO (worst case): {quote.price_with_slippage}')

# See the examples for the rest...

Examples

Basic Swapping

swapping1.py This example demonstrates basic functionality including:

  • retrieving Pool details
  • getting a swap quote
  • preparing swap transactions
  • signing transactions
  • submitting transactions
  • checking excess amounts
  • preparing redeem transactions

swapping1_less_convenience.py This example has exactly the same functionality as swapping1.py but is purposely more verbose, using less convenience functions.

Basic Pooling

pooling1.py This example demonstrates retrieving the current pool position/share for an address.

Basic Add Liquidity (Minting)

add_liquidity1.py This example demonstrates add liquidity to an existing pool.

Basic Burning

TODO

Conventions

  • Methods starting with fetch_ all make network requests to fetch current balances/state.
  • Methods of the form prepare_X_transactions all return TransactionGroup objects (see below).
  • All asset amounts are returned as AssetAmount objects which contain an Asset and amount (int).
  • All asset amount inputs are expected as micro units e.g. 1 Algo = 1_000_000 micro units.

Signing & Submission

The SDk separates transaction preparation from signing and submission to leave the developer in full control of how transactions are signed and submitted to the network.

Preparation

The prepare_X_transactions methods all return a TransactionGroup object. This is a container object containing a list of transaction objects (.transactions) and a list for signed transactions (.signed_transactions).

transaction_group = client.prepare_app_optin_transactions(account['address'])

Signing

In most cases some of the transactions have a corresponding entry in .signed_transactions because they have been signed by the Pool LogicSig. The remaining transactions should be signed by the 'user'.

The TransactionGroup includes a method to do this when signing with a private key:

transaction_group.sign_with_private_key(account['address'], account['private_key'])

This helper method is equivalent to the following:

for i, txn in enumerate(transaction_group.transactions):
    if txn.sender == account['address']:
        transaction_group.signed_transactions[i] = txn.sign(account['private_key'])

Any alternative method of signing can be used here following the same pattern. For example using KMD:

kmd = algosdk.kmd.KMDClient(KMD_TOKEN, KMD_ADDRESS)
handle = kmd.init_wallet_handle(KMD_WALLET_ID, KMD_WALLET_PASSWORD)
for i, txn in enumerate(transaction_group.transactions):
    if txn.sender == account['address']:
        transaction_group.signed_transactions[i] = kmd.sign_transaction(handle, KMD_WALLET_PASSWORD, txn)

A User account LogicSig can also be used in a similar way or using the sign_with_logicisg convenience method:

transaction_group.sign_with_logicisg(logicsig)

Submission

A TransactionGroup containing fully signed transactions can be submitted to the network in either of two ways:

Using an Algod client:

algod = AlgodClient(TOKEN, ADDRESS, headers={'User-Agent': 'algosdk'})
txid = algod.send_transactions(transaction_group.signed_transactions)

Or, using the convenience method of the TinymanClient:

result = client.submit(transaction_group, wait=True)

This method submits the signed transactions and optionally waits for confirmation.

License

tinyman-py-sdk is licensed under a MIT license except for the exceptions listed below. See the LICENSE file for details.

Exceptions

tinyman/v1/asc.json is currently unlicensed. It may be used by this SDK but may not be used in any other way or be distributed separately without the express permission of Tinyman.

Owner
Tinyman
Tinyman
Change Discord HypeSquad in few seconds!

a simple python script that change your hypesquad to what house you choose

Ho3ein 5 Nov 16, 2022
Whatsapp-APi Wrapper From rzawapi.my.id

Whatsapp-APi Wrapper From rzawapi.my.id

Rezza Priatna 2 Apr 19, 2022
Python wrapper library for World Weather Online API

pywwo Python wrapper library for World Weather Online API using lxml.objectify How to use from pywwo import * setKey('your_key', 'free') w=LocalWeat

World Weather Online 20 Dec 19, 2022
Fortnite Dumper for anyone's Save the World profiles.

Anyone's Fortnite Save the World Profile Dumper This program allows you to dump anyone's Fortnite Save the World Profiles. How to use it? After starti

PRO100KatYT 6 Apr 13, 2022
Just a simple discord bot a create for try

WAIFU MATERIAL DISCORD BOT! French ver. here HOW TO LAUNCH First, clone this rep

1 Jan 08, 2022
A Really Simple and Advanced Google Colab NoteBook to Setup and start using Rclone on Google Colab easily.

Rclone on Google Colab (Advanced!) 🔥 1.Setup and Start using Rclone on Google Colab and Create/Edit/View and delete your Rclone config file and keep

Dr.Caduceus 14 May 24, 2022
Eva Maria Bot With Python

Eva Maria Bot Features Auto Filter Manual Filter IMDB Admin Commands Broadcast Index IMDB search Inline Search Random pics ids and User info Stats, Us

Aadhi 3 Jan 06, 2022
Telegram Bot for updating ongoing matches of Fotmob.com in channel by @AbirHasan2005

Fotmob-Bot A very simple Telegram Bot which will update ongoing matches of Fotmob in a channel. Demo Channel Configs API_ID - Get this from @TeleORG_B

Abir Hasan 22 Oct 21, 2022
The world's first public V2ray manager Telegram bot

📌 DarkV2ray-Manager-Bot 0.1 UPDATE 11/11/2021 Telegram bot v2ray Test user expired date data limit paylode && sni usage user on/off heroku bot hostin

@Dk_king_offcial 1 Nov 11, 2021
This bot will automatically like and follow users that post under a specified hashtag

Instagram-bot This bot will automatically like and follow users that post under a specified hashtag Dependencies Java JDK Selenium Updated version of

Makana Edwards 1 Nov 04, 2021
A collection of scripts to steal BTC from Lightning Network enabled custodial services. Only for educational purpose! Share your findings only when design flaws are fixed.

Lightning Network Fee Siphoning Attack LN-fee-siphoning is a collection of scripts to subtract BTC from Lightning Network enabled custodial services b

Reckless_Satoshi 14 Oct 15, 2022
A ShareX alternative for Mac OS built in Python.

Clipboard Uploader A ShareX alternative for Mac OS built in Python. Install and setup Download the latest release and put it in your applications fold

Ben Tettmar 2 Jun 07, 2022
This package accesses nitrotype's official api along with its unofficial user api

NitrotypePy This package accesses nitrotype's official api along with its unofficial user api. Currently still in development. Install To install, run

The Moon That Rises 2 Sep 04, 2022
✨ 🐍 Python SDK for StarkNet.

✨ 🐍 starknet.py StarkNet SDK for Python 📘 Documentation Installation Quickstart Guide API Installation To install this package run pip install stark

Software Mansion 158 Jan 04, 2023
A Discord webhook spammer made in Python.

A Python made Discord webhook spammer usually used for token loggers to spam them/delete them original by cattyn I only made it so u can change the avatar to whatever u want instead of it being hardc

notperry1234567890 15 Dec 15, 2021
📦 Opensource Python wrapper for Hiven's REST and WebSocket API

hiven.py 📦 Opensource Python wrapper for Hiven's REST and WebSocket API Installation pip install -U hiven.py Usage hiven.py is currently under devel

Kevin Thomas 3 Sep 03, 2021
SOLSEA-NFT-EXPLORE - Using Streamlit to build a simple UI on top of the Solana API

SOLSEA NFT Explorer Using Streamlit to build a simple UI on top of the Solana AP

Devin Capriola 3 Mar 19, 2022
Set of classes and tools to communicate with a Noso wallet using NosoP

NosoPy Set of classes and tools to communicate with a Noso wallet using NosoP(Noso Protocol). The data that can be retrieved consist of: Node informat

Noso Project 1 Jan 10, 2022
KaydyPurge - Python Purge Script for Discord made by Kaydy Cain#0001

How to Install Open terminal Execute "git clone https://github.com/apolo1337/Kay

apolo 5 Jan 27, 2022
Public repo of the bot

wiki-reddit-bot Public repo of u/wikipedia_answer_bot Tools Language: Python Libraries: praw (Reddit API) mediawikiapi (Wikipedia API) tenacity How it

TheBugYouCantFix 51 Dec 03, 2022