amm.py from examples not worked
See original GitHub issueDescribe the bug Requires asset (LP) issuer. In the LiquidityPool example, you didn’t have it. /py-stellar-base/example/amm.py
/py-stellar-base/examples#` python3 amm1.py
Liquidity Pool ID: 0aeafb6dda1a3ccc1693a81ffbd0271e8e128d77cc46698fdf1d589c2670e2bd
Traceback (most recent call last):
File "amm1.py", line 42, in <module>
.append_change_trust_op(liquidity_pool_asset)
TypeError: append_change_trust_op() missing 1 required positional argument: 'asset_issuer'
CODE
from stellar_sdk import (
Asset,
Keypair,
LiquidityPoolAsset,
LIQUIDITY_POOL_FEE_V18,
Network,
Server,
TransactionBuilder,
)
horizon_url = "https://horizon.stellar.org/"
#network_passphrase = Network.TESTNET_NETWORK_PASSPHRASE
network_passphrase = Network.PUBLIC_NETWORK_PASSPHRASE
server = Server(horizon_url=horizon_url)
source_keypair = Keypair.from_secret(
"S*************************************************"
)
# We assume that Hello asset already exists in the Stellar network,
# and you can learn how to issue assets through examples/issue_asset.py
# Here we define a Liquidity Pool Asset.
asset_a = Asset.native()
asset_b = Asset("MERA", "G**************************************7H2A")
fee = LIQUIDITY_POOL_FEE_V18 # tried it with and without
liquidity_pool_asset = LiquidityPoolAsset(asset_a=asset_a, asset_b=asset_b, fee=fee)
#print(liquidity_pool_asset)
liquidity_pool_id = liquidity_pool_asset.liquidity_pool_id
print(f"Liquidity Pool ID: {liquidity_pool_id}")
source_account = server.load_account(account_id=source_keypair.public_key)
# First we need to add a trust line for liquidity_pool_asset.
transaction1 = (
TransactionBuilder(
source_account=source_account,
network_passphrase=network_passphrase,
base_fee=100,
)
.append_change_trust_op(liquidity_pool_asset)
.set_timeout(30)
.build()
)
transaction1.sign(source_keypair)
response1 = server.submit_transaction(transaction1)
print(response1)
I tried a lot of things but didn’t work. One final thought: don’t use the append_change_trust_op () wrapper, but use ChangeTrust (). I don’t think that will help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Algofiorg/algofi-amm-py-sdk - GitHub
algofi-amm-py-sdk is the official Python SDK of the Algofi AMM protocol. The SDK supports swapping, stable swapping, and liquidity providing.
Read more >Invalid Syntax in Python: Common Reasons for SyntaxError
In this step-by-step tutorial, you'll see common examples of invalid syntax in Python and learn how to resolve the issue. If you've ever...
Read more >Why am I seeing "TypeError: string indices must be integers"?
When working with strings and slice notation (a common sequence operation), it can happen that a TypeError is raised, pointing out that the ......
Read more >How to Call a Function in Python (Example) - Guru99
The output of the function will be “I am learning Python function”. ... At least, one indent is enough to make your code...
Read more >What's New In Python 3.8 — Python 3.11.1 documentation
For example, the built-in divmod() function does not accept keyword arguments ... This works because regular dicts have guaranteed ordering since Python 3.7 ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And thank you very much for your help!
ps: now added these lines to the script: import stellar_sdk print (stellar_sdk .__ version__)
As you would expect, it featured version 5.0.0.
I think you are using 5.0.0 now, you can use
pip install stellar-sdk==6.0.0b3
to install 6.0.0b3