Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-release: ASI upgrade #392

Merged
merged 7 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ hashlib
mainnet
chain_id
dorado
eridanus
ibc
tendermint
tx
Expand All @@ -64,6 +65,7 @@ pb
cosmoshub
validator
atestfet
atestasi
denom
wasm
blockapsis
Expand All @@ -81,6 +83,7 @@ Validators
delegator
validators
afet
aasi
ibcprotocol
natively
CosmWasm
Expand Down Expand Up @@ -256,6 +259,8 @@ december
mykeyname
xxd
fetchvaloper
asivaloper
asi
PyCQA
blueviolet
lightgrey
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ You require [Docker](https://docs.docker.com/get-docker/) for your platform.
export PASSWORD="12345678"
export CHAIN_ID=testing
export DENOM_1=stake
export DENOM_2=atestfet
export DENOM_2=atestasi
export MONIKER=some-moniker


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ from cosmpy.aerial.client import LedgerClient, NetworkConfig
# connect to Fetch.ai network using default parameters
ledger_client = LedgerClient(NetworkConfig.fetchai_mainnet())

alice: str = 'fetch12q5gw9l9d0yyq2th77x6pjsesczpsly8h5089x'
alice: str = 'asi12q5gw9l9d0yyq2th77x6pjsesczpsly8vk5n89'
balances = ledger_client.query_bank_all_balances(alice)

# show all coin balances
Expand Down
27 changes: 21 additions & 6 deletions cosmpy/aerial/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def fetchai_dorado_testnet(cls) -> "NetworkConfig":
faucet_url="https://faucet-dorado.fetch.ai",
)

@classmethod
def asi_eridanus_testnet(cls) -> "NetworkConfig":
"""ASI Eridanus testnet.

:return: Network configuration
"""
return NetworkConfig(
chain_id="eridanus-1",
url="grpc+https://grpc-eridanus-1.fetch.ai",
fee_minimum_gas_price=5000000000,
fee_denomination="atestasi",
staking_denomination="atestasi",
faucet_url="https://faucet-eridanus-1.fetch.ai",
)

@classmethod
def fetchai_alpha_testnet(cls):
"""Get the fetchai alpha testnet.
Expand All @@ -113,7 +128,7 @@ def fetchai_stable_testnet(cls):

:return: fetchai stable testnet. For now dorado is fetchai stable testnet.
"""
return cls.fetchai_dorado_testnet()
return cls.asi_eridanus_testnet()

@classmethod
def fetchai_mainnet(cls) -> "NetworkConfig":
Expand All @@ -122,11 +137,11 @@ def fetchai_mainnet(cls) -> "NetworkConfig":
:return: fetch mainnet configuration
"""
return NetworkConfig(
chain_id="fetchhub-4",
url="grpc+https://grpc-fetchhub.fetch.ai",
chain_id="asi-1",
url="grpc+https://grpc-asi.fetch.ai",
fee_minimum_gas_price=0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We have been considering setting this default minimum gas price here to non-zero value (the same value as for testnet). Even though this is not enforceable, practically speaking, this is what we want - if nothing else, then at least defaulting to non-zero Tx gas price value will make it less straightforward for users to use zero Tx fee.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now (for ASI umgrade release), please ignore my comment above. We will touch on thsese kind of things in later releases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: In this sense (= not now), we shall also extend the NetworkConfig class with address prefix data member.

fee_denomination="afet",
staking_denomination="afet",
fee_denomination="aasi",
staking_denomination="aasi",
faucet_url=None,
)

Expand All @@ -152,4 +167,4 @@ def latest_stable_testnet(cls) -> "NetworkConfig":
"latest_stable_testnet is deprecated, use fetchai_stable_testnet instead",
DeprecationWarning,
)
return cls.fetchai_stable_testnet()
return cls.asi_eridanus_testnet()
2 changes: 1 addition & 1 deletion cosmpy/crypto/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from cosmpy.crypto.keypairs import PublicKey


DEFAULT_PREFIX = "fetch"
DEFAULT_PREFIX = "asi"


def _to_bech32(prefix: str, data: bytes) -> str:
Expand Down
15 changes: 15 additions & 0 deletions docs/api/aerial/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ Fetchai dorado testnet.

Network configuration

<a id="cosmpy.aerial.config.NetworkConfig.asi_eridanus_testnet"></a>

#### asi`_`eridanus`_`testnet

```python
@classmethod
def asi_eridanus_testnet(cls) -> "NetworkConfig"
```

ASI Eridanus testnet.

**Returns**:

Network configuration

<a id="cosmpy.aerial.config.NetworkConfig.fetchai_alpha_testnet"></a>

#### fetchai`_`alpha`_`testnet
Expand Down
24 changes: 12 additions & 12 deletions docs/liquidity-pool.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Swap Tokens

You can interact with a liquidity pool by swapping atestfet for CW20 tokens or vice versa.
You can interact with a liquidity pool by swapping atestasi for CW20 tokens or vice versa.
First, perform all the necessary imports:

```python
Expand Down Expand Up @@ -28,13 +28,13 @@ Define the CW20, pair, and liquidity token contracts with the following addresse
```python
# Define cw20, pair and liquidity token contracts
token_contract_address = (
"fetch1qr8ysysnfxmqzu7cu7cq7dsq5g2r0kvkg5e2wl2fnlkqss60hcjsxtljxl"
"asi1qr8ysysnfxmqzu7cu7cq7dsq5g2r0kvkg5e2wl2fnlkqss60hcjshnau6q"
)
pair_contract_address = (
"fetch1vgnx2d46uvyxrg9pc5mktkcvkp4uflyp3j86v68pq4jxdc8j4y0s6ulf2a"
"asi1vgnx2d46uvyxrg9pc5mktkcvkp4uflyp3j86v68pq4jxdc8j4y0stya8kz"
)
liq_token_contract_address = (
"fetch1alzhf9yhghud3qhucdjs895f3aek2egfq44qm0mfvahkv4jukx4qd0ltxx"
"asi1alzhf9yhghud3qhucdjs895f3aek2egfq44qm0mfvahkv4jukx4quha96e"
)

token_contract = LedgerContract(
Expand All @@ -48,12 +48,12 @@ liq_token_contract = LedgerContract(
)
```

Swap the defined `swap_amount`of atestfet for CW20 tokens
Swap the defined `swap_amount`of atestasi for CW20 tokens

```python
# Swap atestfet for CW20 tokens
# Swap atestasi for CW20 tokens
swap_amount = "10000"
native_denom = "atestfet"
native_denom = "atestasi"

tx = pair_contract.execute(
{
Expand All @@ -76,7 +76,7 @@ You can query your CW20 balance using the following code:
token_contract.query({"balance": {"address": str(wallet.address())}})
```

To trade 10 CW20 tokens for atestfet you can use the following:
To trade 10 CW20 tokens for atestasi you can use the following:

```python
tx = token_contract.execute({
Expand All @@ -91,7 +91,7 @@ tx.wait_to_complete()
```
## Add and Remove Liquidity

You need to increase your wallet's allowance to provide CW20 tokens to the liquidity pool. You don't need to increase the allowance to provide atestfet
You need to increase your wallet's allowance to provide CW20 tokens to the liquidity pool. You don't need to increase the allowance to provide atestasi

```python
# Set the amount of CW20 tokens to be added to liquidity pool
Expand All @@ -111,17 +111,17 @@ tx = token_contract.execute(

tx.wait_to_complete()
```
To set the amount of atestfet to be added to the liquidity pool and not influence the existing token prices, we need to choose an amount that matches the atestfet:CW20 token ratio already existing in the pool. For this reason, we will query the `pair_contract` pool to observe the atestfet:CW20 token ratio
To set the amount of atestasi to be added to the liquidity pool and not influence the existing token prices, we need to choose an amount that matches the atestasi:CW20 token ratio already existing in the pool. For this reason, we will query the `pair_contract` pool to observe the atestasi:CW20 token ratio

```python
# Query Liquidity Pool
pair_contract.query({"pool": {}})
```

At the moment the code was run, the ratio was close to 247:10 atestfet:CW20, and since we defined above the amount of CW20 tokens to provide to the liquidity pool as 100, we will match the LP pool ratio by setting the atestfet amount as 2470. It will be difficult to exactly match the current ratio of the pool, but when adding liquidity to the pool, there is a slippage_tolerance parameter that allows a certain percentage change in the price.
At the moment the code was run, the ratio was close to 247:10 atestasi:CW20, and since we defined above the amount of CW20 tokens to provide to the liquidity pool as 100, we will match the LP pool ratio by setting the atestasi amount as 2470. It will be difficult to exactly match the current ratio of the pool, but when adding liquidity to the pool, there is a slippage_tolerance parameter that allows a certain percentage change in the price.

```python
# Set the amount of atestfet tokens to be added to liquidity pool
# Set the amount of atestasi tokens to be added to liquidity pool
native_liquidity_amount = "2470"

# Provide Liquidity
Expand Down
2 changes: 1 addition & 1 deletion docs/low-level-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ tx.wait_to_complete()
Before running the above, the necessary `authz` grant must first be put in place. For Ledger Nano users (other hardware wallets are also available) that might mean an excursion to the command line. For the Fetchai network using [FetchD](https://docs.fetch.ai/ledger_v2/):

```bash
fetchd tx authz grant $(fetchd keys show grantee --output json | jq -r .address) generic --msg-type "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission" --from=$(fetchd keys show grantor --output json | jq -r .address) --gas auto --gas-adjustment 1.5 --gas-prices 5000000000atestfet
fetchd tx authz grant $(fetchd keys show grantee --output json | jq -r .address) generic --msg-type "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission" --from=$(fetchd keys show grantor --output json | jq -r .address) --gas auto --gas-adjustment 1.5 --gas-prices 5000000000atestasi
```

By default, the above provides one year's worth of authorization to withdraw validator commission using accounts already present in the keyring.
Expand Down
4 changes: 2 additions & 2 deletions docs/oracles.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract = LedgerContract("oracle.wasm", ledger)
To deploy the oracle contract, add the fee amount to the instantiation message and call the `deploy` function:
```python
instantiation_message = {"fee": "100"}
contract.deploy(instantiation_message, wallet, funds="1atestfet")
contract.deploy(instantiation_message, wallet, funds="1atestasi")
print(f"Oracle contract deployed at: {contract.address}")
```

Expand Down Expand Up @@ -107,7 +107,7 @@ REQUEST_INTERVAL_SECONDS = 10
while True:
request_message = {"query_oracle_value": {}}
contract.execute(
request_message, wallet, funds="100atestfet"
request_message, wallet, funds="100atestasi"
).wait_to_complete()
result = contract.query({"oracle_value": {}})
print(f"Oracle value successfully retrieved: {result}")
Expand Down
6 changes: 3 additions & 3 deletions docs/query-balance.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
A [`LedgerClient`](connect-to-network.md) object can be used to query the balances associated with a particular address:

```python
address: str = 'fetch12q5gw9l9d0yyq2th77x6pjsesczpsly8h5089x'
address: str = 'asi12q5gw9l9d0yyq2th77x6pjsesczpsly8vk5n89'
balances = ledger_client.query_bank_all_balances(address)
```

This will return a `List` of `Coin` objects that contain `amount` and `denom` variables that correspond to all the funds held at the address and their denominations. This list includes all natively defined coins along with any tokens transferred using the inter-blockchain communication ([IBC](https://ibcprotocol.dev/)) protocol.

```python
>>> balances
[Coin(amount='29263221445595384075', denom='afet')]
[Coin(amount='29263221445595384075', denom='aasi')]
```

It's also possible to query the funds associated with a particular denomination by calling

```python
balance = ledger_client.query_bank_balance(address, denom='afet')
balance = ledger_client.query_bank_balance(address, denom='aasi')
```

which will return the value of the (integer) funds held by the address with the specified denomination. If the `denom` argument is omitted the function will return the fee denomination specified in the `NetworkConfig` object used to initialise the `LedgerClient`.
6 changes: 3 additions & 3 deletions docs/send-tokens.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Once you have your [`wallet`](wallets-and-keys.md) configured, you can send transactions to the network. The `LedgerClient` object provides useful utilities to do common operations. The following example shows how to send `10` `atestfet` to another address:
Once you have your [`wallet`](wallets-and-keys.md) configured, you can send transactions to the network. The `LedgerClient` object provides useful utilities to do common operations. The following example shows how to send `10` `atestasi` to another address:

```python
destination_address = 'fetch1h2l3cnu7e23whmd5yrfeunacez9tv0plv5rxqy'
destination_address = 'asi1h2l3cnu7e23whmd5yrfeunacez9tv0plhkcjz8'

tx = ledger_client.send_tokens(destination_address, 10, "atestfet", wallet)
tx = ledger_client.send_tokens(destination_address, 10, "atestasi", wallet)

# block until the transaction has been successful or failed
tx.wait_to_complete()
Expand Down
4 changes: 2 additions & 2 deletions docs/stake-optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ alice_address = Address(key)._display
tx = Transaction()

# Add delegate msg
tx.add_message(create_delegate_msg(alice_address,validator.address,initial_stake,"atestfet"))
tx.add_message(create_delegate_msg(alice_address,validator.address,initial_stake,"atestasi"))

# Add claim reward msg
tx.add_message(create_withdraw_delegator_reward(alice_address, validator.address))
Expand All @@ -103,7 +103,7 @@ _, str_tx_fee = ledger.estimate_gas_and_fee_for_tx(tx)
Since the output of this function is a string, we will convert it to an int and round it up to get a more conservative estimate for the `fee`

```python
denom = "atestfet"
denom = "atestasi"
tx_fee = str_tx_fee[:-len(denom)]

# Add a 20% to the fee estimation to get a more conservative estimate
Expand Down
2 changes: 1 addition & 1 deletion docs/staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tx.wait_to_complete()
At any point you can query the stake information of any particular address. This can be done using the `LedgerClient` as shown in the example below:

```python
address = 'fetch1h2l3cnu7e23whmd5yrfeunacez9tv0plv5rxqy'
address = 'asi1h2l3cnu7e23whmd5yrfeunacez9tv0plhkcjz8'

s = ledger_client.query_staking_summary(address)
print(f"Summary: Staked: {s.total_staked} Unbonding: {s.total_unbonding} Rewards: {s.total_rewards}")
Expand Down
Loading
Loading