theeldermillenial / minswap-py Goto Github PK
View Code? Open in Web Editor NEWA Python client for interacting with Minswap DEX on Cardano
License: MIT License
A Python client for interacting with Minswap DEX on Cardano
License: MIT License
The wallet class is limited to mnemonic seed imports/Extended Signing/Staking keys only.
Being able to import/provide a path to pycardano or CLI payment signing keys and or stake keys (i.e enterprise address support) would be useful for integrating minswap-py with pycardano projects.
It would also be useful to be able to craft pool transactions without dependence on the minswap-py wallet class.
Currently, pool addresses are hard coded into minswap.addr
. As Minswap grows, or as new contracts are implemented, the pool addresses may grow or change.
A better solution is to track the addresses containing the Minswap DEX NFT. Blockfrost has an endpoint showing all addresses containing at least one of a specific asset. This endpoint should be used in place of the current hard coded values.
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1%7Basset%7D~1addresses/get
from minswap import assets, pools
pool_ids = ["63f2cbfa5bf8b68828839a2575c8c70f14a32f50ebbfa7c654043269793be896", # SNEK - OK
"8fde43a3f0b9f0e6f63bec7335e0b855c6b62a4dc51f1b762ccb6dfbbafcfe47", # iUSD - OK
"d8c9db5805c51ff35642da3a54c29e573f747461d91d010125683494537debf8", # HUNT - Bad
"f9d754bbb359e164ac964df47e84726b33117c59eb57e90f835ac6027af0f3f2", # JPG - Bad
"4705d99a4cf6bce9181e60fdbbf961edf6acad7141ed69186c8a8883600e59c5", # GENS - Bad
"178d9b1934c022ded69fe43a30fdb05e1b7dbccbd6dc359708da68dfa6b4a4c3", # SMOKES - Bad
"93f16d92eb096ffa4b604d8f61fce105987dd04148c2ce563f9c3f2017f0c4f2",]# CSWAP - Bad
for pool_id in pool_ids:
try:
info = pools.get_pool_by_id(pool_id)
print(info)
print(info.asset_b_name + "\n")
except Exception as e:
print("Error: " + str(e) + "\n")
I tried to get pool info for top 100 coins, but the function failed for 5 of them. This function prints out asset name for pools, and raises exception if it fails. Exception is found for 5/7 of them, and can be either (Workaround can be found using "pool.unit_b" attribute):
Error: 'utf-8' codec can't decode byte 0xdf in position 2: invalid continuation byte
or (No workaround):
Error: 'NoneType' object has no attribute 'asset_b_name'
Moreover, pools.get_pools() function does NOT return all pools, and does not return same pools that failed previously. This could be a clue to where the bug happens.
Additional info:
from minswap import assets, pools
from blockfrost import BlockFrostApi, ApiError, ApiUrls
blockfrost_api = BlockFrostApi(project_id='API_KEY',base_url=ApiUrls.mainnet.value)
asset_name = "133fac9e153194428eb0919be39837b42b9e977fc7298f3ff1b76ef95055444759"
info = assets.get_asset_info(pool.unit_b)
print(info)
info2 = blockfrost_api.asset(pool.unit_b)
print(info2)
This function prints out two different values for "decimals". minswap returns "0" (Wrong), while blockfrost returns "6" (Correct).
Additional info:
While implementing workaround using Blockfrost, I noticed that for some assets "metadata" can be Null value, which defaults "decimals" to 0. Furthermore, even if "metadata" value is not Null, "metadata.decimals" could be Null, which also defaults "decimals" value to 0.
Not exactly relevant for this issue, as expected value is 6, but could be related to this as error while handling metadata returns 0.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.