Skip to content

Commit

Permalink
[update] fa
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmark authored and gregnazario committed Oct 9, 2024
1 parent cf511c3 commit e0c2511
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion apps/nextra/pages/en/build/guides/system-integrators-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,17 @@ For any `FungibleStore`
s, [`fungible_asset::transfer`](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-framework/sources/fungible_asset.move#L347)
would be invoked with `FungibleStore` object addresses.

It is noted in the migration phase from coin to FA, withdraw/deposit/transfer FA paired from coin should
call `0x1::coin::deposit/withdraw/transfer`(coin module API) to transfer the asset because the account may have the asset in both
form but fungible asset API can only move FA part but not the coin part. In contrast, coin API could move both parts. For other FA,
since it does not have a paired coin type, only fungible asset API can be used to move assets.
To know which API to call, please refer to [`concurrent_fungible_asset_balance`](../../../indexer/fungible-asset-balances.mdx) table `standard` field, where "v1" means using coin API and "v2" means using fungible asset API.

### Current balance for Fungible Asset

The current balance for an APT FA of FungibleStore is available at the account resources URL: `https://{rest_api_server}/accounts/{fungible_store_object_address}/resource/0x1::fungible_asset::FungibleStore`. The balance is stored as `balance`. The resource also contains a metadata object of the FA type and the frozen status. The address of the primary fungible store can be calculated as `sha3_256(32-byte account address | 32-byte metadata object address | 0xFC)`. The metadata object address of APT FA is `0xA`.
Indexer users can just query [`concurrent_fungible_asset_balance`](../../indexer/fungible-asset-balances.mdx) to get the balance.

For node API, the current balance for an APT FA of FungibleStore is available at the account resources URL: `https://{rest_api_server}/accounts/{fungible_store_object_address}/resource/0x1::fungible_asset::FungibleStore`. The balance is stored as `balance`. The resource also contains a metadata object of the FA type and the frozen status. The address of the primary fungible store can be calculated as `sha3_256(32-byte account address | 32-byte metadata object address | 0xFC)`. The metadata object address of APT FA is `0xA`.

Aptos users have the option to upgrade to concurrent fungible balance to allow parallelization of balance updates, improving the performance of a single account. When a user has upgraded a fungible store balance to support concurrent update, the fungible store object will have another resource `ConcurrentFungibleBalance` that contains the balance of the store, and the `balance` field of FungibleStore will be set to 0. The current balance for an APT FA of `ConcurrentFungibleBalance` (if exists) is available at the account resources URL: `https://{rest_api_server}/accounts/{fungible_store_object_address}/resource/0x1::fungible_asset::ConcurrentFungibleBalance`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ There are two changes needed for off-chain services:

Since a user may possess **both** a `coin` balance and a paired FA balance, off-chain applications should be updated to reflect the **sum** of both the `coin` balance and its paired FA balance.

- For Aptos Indexer users, you may utilize a new table called `current_unified_fungible_asset_balances` to obtain the latest sum of coin balance and FA balance representing the same asset type.
- For Aptos Indexer users, you may utilize the table called `current_fungible_asset_balances` to obtain the latest sum of coin balance and FA balance representing the same asset type. If the FA has a paired coin type, the asset type would be set to the coin type, such as `0x1::aptos_coin::AptosCoin`. Otherwise, for FA not paired from a coin, the asset type would be the metadata address. Users could filter by this field to get the FA balance of their interest.
- For users employing Node API or other customized indexing, they should add the balance of the paired FA in users' `FungibleStore` and `ConcurrentFungibleBalance` if any of them exist to the coin balance.

To retrieve the balance of the `PrimaryFungibleStore` for a paired FA to an existing `coin` of type `CoinType`:
Expand Down

0 comments on commit e0c2511

Please sign in to comment.