question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amm.py from examples not worked

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
minherccommented, Nov 8, 2021

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.

1reaction
overcatcommented, Nov 8, 2021

I think you are using 5.0.0 now, you can use pip install stellar-sdk==6.0.0b3 to install 6.0.0b3

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found