> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powfi.alephium.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Contract artifacts & deployments

> Typed bindings for every Powfi contract and script, and the bundled deployment addresses.

export const VersionBanner = ({network = 'mainnet', products = [], lang = 'en'}) => {
  const SDK_VERSION = '1.0.2';
  const ADDRESSES = {
    mainnet: {
      cpmm: {
        Router: 'ze15rnAwTyVCPnDhN7J8An3SvNeWBsZHAVMeBx1ehXeP',
        TokenPairFactory: '24CXRLvj1QiDH6riwr1EPERG7BcduHKZtktygbq97MfYb'
      },
      clmm: {
        PoolFactory: '24gqd4DMQXVzjm5QDAGxUtYupx3WM2PSu3vZUseuBCV9h',
        PositionManager: 'vFyKSqnJHS9MicrojBcLgztyRFqhS4hB349Ci3LJCELw'
      },
      staking: {
        XAlphToken: '225WevmFp5ZgzPsyVJTvyp2v2uyKrvp329HfrVmzffnWj',
        RewardFeeCollector: '22CE7vG6u64zjjsLZLxeJqQuPDydjPvbP9iG1d861j2G7'
      }
    },
    testnet: {
      cpmm: {
        Router: 'xaueT8kPMvpnaFJEfHv6CJLgqsSPpoNmHjF1QgTxoF9R',
        TokenPairFactory: '29hdd9b9Gp7oXuamwHKfUqBaRXP487HoeTcutS3RhZJEj'
      },
      clmm: {
        PoolFactory: 'z2QFT7qBQrfm8UwAYG3VHWoHs7B56ZDFNdSCcDu5j53m',
        PositionManager: '21p6egW8d6FEyVVuH17WqvHCARsCsD61GcBmeCr75XdGT'
      },
      staking: {
        XAlphToken: '23psDicimC5VdpM56wrgqgCzQzcyXWGCkQGSYWbtZAPRq',
        RewardFeeCollector: '29qQ1LPJ5uqawRviXLVDMeo19JUygRrNNTQy5RUBh817D'
      }
    }
  };
  const EXPLORERS = {
    mainnet: 'https://explorer.alephium.org/addresses/',
    testnet: 'https://testnet.alephium.org/addresses/'
  };
  const LABELS = {
    en: {
      sdk: 'SDK',
      network: 'Network',
      contracts: 'Contracts',
      all: 'All addresses',
      allNetworks: 'mainnet · testnet · devnet',
      devnet: 'Local deployment (addresses vary per devnet)'
    },
    zh: {
      sdk: 'SDK 版本',
      network: '网络',
      contracts: '合约',
      all: '全部地址',
      allNetworks: 'mainnet · testnet · devnet',
      devnet: '本地部署（每个 devnet 的地址不同）'
    },
    fr: {
      sdk: 'SDK',
      network: 'Réseau',
      contracts: 'Contrats',
      all: 'Toutes les adresses',
      allNetworks: 'mainnet · testnet · devnet',
      devnet: 'Déploiement local (adresses propres à chaque devnet)'
    }
  };
  const t = LABELS[lang] ?? LABELS.en;
  const contractsPage = lang === 'en' ? '/reference/contracts' : `/${lang}/reference/contracts`;
  const short = a => `${a.slice(0, 6)}…${a.slice(-4)}`;
  const entries = [];
  const addrs = ADDRESSES[network];
  if (addrs) {
    for (const p of products) {
      for (const [name, address] of Object.entries(addrs[p] ?? ({}))) entries.push({
        name,
        address
      });
    }
  }
  let contractsCell;
  if (network === 'devnet' && products.length > 0) {
    contractsCell = <span>{t.devnet}</span>;
  } else if (entries.length > 0) {
    contractsCell = entries.map(({name, address}, i) => <span key={name}>
        {i > 0 && <span className="mx-1 opacity-50">·</span>}
        {name}{' '}
        <a href={EXPLORERS[network] + address} target="_blank" rel="noreferrer" title={address}>
          <code>{short(address)}</code>
        </a>
      </span>);
  }
  const row = (label, value) => <div className="flex flex-wrap gap-x-2">
      <span className="font-semibold min-w-[5.5rem]">{label}</span>
      <span className="flex-1 min-w-0 break-words">{value}</span>
    </div>;
  return <div className="not-prose mb-6 rounded-xl border border-zinc-950/10 dark:border-white/10 bg-zinc-50 dark:bg-white/5 px-4 py-3 text-sm leading-6 text-zinc-700 dark:text-zinc-300">
      {row(t.sdk, <code>@alephium/powfi-sdk@{SDK_VERSION}</code>)}
      {row(t.network, network === 'all' ? t.allNetworks : network)}
      {contractsCell && row(t.contracts, <span>
            {contractsCell}
            <span className="mx-1 opacity-50">·</span>
            <a href={contractsPage}>{t.all} →</a>
          </span>)}
    </div>;
};

<VersionBanner network="all" products={[]} lang="en" />

The SDK bundles the generated `@alephium/web3` bindings for all Powfi contracts. Use them when a module doesn't wrap the method you need.

## Namespaces

```ts theme={null}
import {
  CpmmContracts,     // TokenPair, TokenPairFactory, Router, ...
  CpmmScripts,       // SwapMinOut, SwapMaxIn, AddLiquidity, RemoveLiquidity, CreatePair, ...
  ClmmContracts,     // Pool, PoolFactory, PoolConfig, Position, PositionManager, DexAccount, DexAccountRoot, ...
  ClmmScripts,       // SwapWithoutAccount, SwapWithoutAccountWithFee, CreateLiquidPool, ...
  StakingContracts,  // XAlphToken, AlphUnstakeVault, RewardFeeCollector, DistributorVault, ...
  loadCpmmDeployments,
  loadClmmDeployments,
  loadStakingDeployments
} from '@alephium/powfi-sdk'
```

<Tip>
  Generated bindings use the **global** `@alephium/web3` node provider. `Powfi.load` registers it for you. If you run several SDK instances, call `powfi.setCurrentProviders()` on the one you want the bindings to use.
</Tip>

## Example: read a contract directly

```ts theme={null}
import { addressFromContractId } from '@alephium/web3'

const poolId = powfi.clmm.getPoolId(tokenA, tokenB, 0n)
const pool = ClmmContracts.Pool.at(addressFromContractId(poolId))

const state = await pool.fetchState()
state.fields.slot0.sqrtPriceX96
state.fields.protocolFees

const { returns } = await pool.view.simulateSwap({
  args: { amountSpecified: 10n ** 18n, zeroForOne: true, data: '', maxSteps: 500n }
})
```

## Deployments

`load*Deployments(networkId)` returns the deployment record for a network, with `contracts.<Name>.contractInstance` holding `contractId`, `address`, and `groupIndex`.

```ts theme={null}
const d = loadClmmDeployments('mainnet')
d.contracts.PoolFactory.contractInstance.contractId
```

Contracts included in `1.0.2` (same set on mainnet, testnet, and devnet):

| Package | Deployed contracts |
| - | - |
| CPMM | `Router`, `TokenPair` (template), `TokenPairFactory` |
| CLMM | `PoolFactory`, `PositionManager`, `DexAccountRoot`, plus templates `Pool`, `PoolConfig`, `Position`, `Tick`, `BitmapWord`, `DexAccount` |
| Staking | `XAlphToken`, `AlphUnstakeVault` (template), `RewardFeeCollector`, `DistributorVault` (template), `ALPHLock` |

## Addresses

The entry-point contracts in the deployments bundled with `1.0.2`. Templates are omitted: pools, positions and vaults are created from them at their own addresses. Devnet addresses depend on your local deployment.

| Package | Contract | Mainnet | Testnet |
| - | - | - | - |
| CPMM | `Router` | [`ze15rnAwTyVCPnDhN7J8An3SvNeWBsZHAVMeBx1ehXeP`](https://explorer.alephium.org/addresses/ze15rnAwTyVCPnDhN7J8An3SvNeWBsZHAVMeBx1ehXeP) | [`xaueT8kPMvpnaFJEfHv6CJLgqsSPpoNmHjF1QgTxoF9R`](https://testnet.alephium.org/addresses/xaueT8kPMvpnaFJEfHv6CJLgqsSPpoNmHjF1QgTxoF9R) |
| CPMM | `TokenPairFactory` | [`24CXRLvj1QiDH6riwr1EPERG7BcduHKZtktygbq97MfYb`](https://explorer.alephium.org/addresses/24CXRLvj1QiDH6riwr1EPERG7BcduHKZtktygbq97MfYb) | [`29hdd9b9Gp7oXuamwHKfUqBaRXP487HoeTcutS3RhZJEj`](https://testnet.alephium.org/addresses/29hdd9b9Gp7oXuamwHKfUqBaRXP487HoeTcutS3RhZJEj) |
| CLMM | `PoolFactory` | [`24gqd4DMQXVzjm5QDAGxUtYupx3WM2PSu3vZUseuBCV9h`](https://explorer.alephium.org/addresses/24gqd4DMQXVzjm5QDAGxUtYupx3WM2PSu3vZUseuBCV9h) | [`z2QFT7qBQrfm8UwAYG3VHWoHs7B56ZDFNdSCcDu5j53m`](https://testnet.alephium.org/addresses/z2QFT7qBQrfm8UwAYG3VHWoHs7B56ZDFNdSCcDu5j53m) |
| CLMM | `PositionManager` | [`vFyKSqnJHS9MicrojBcLgztyRFqhS4hB349Ci3LJCELw`](https://explorer.alephium.org/addresses/vFyKSqnJHS9MicrojBcLgztyRFqhS4hB349Ci3LJCELw) | [`21p6egW8d6FEyVVuH17WqvHCARsCsD61GcBmeCr75XdGT`](https://testnet.alephium.org/addresses/21p6egW8d6FEyVVuH17WqvHCARsCsD61GcBmeCr75XdGT) |
| CLMM | `DexAccountRoot` | [`25YKjwhsFm6cfeQpz5o7oPPTdzpXNavu2cPqaVw79hscB`](https://explorer.alephium.org/addresses/25YKjwhsFm6cfeQpz5o7oPPTdzpXNavu2cPqaVw79hscB) | [`xsqjEZE9wcmuAxyQuPL6vYV7gnufEwfr1Rk2Rxjx2h4T`](https://testnet.alephium.org/addresses/xsqjEZE9wcmuAxyQuPL6vYV7gnufEwfr1Rk2Rxjx2h4T) |
| Staking | `XAlphToken` | [`225WevmFp5ZgzPsyVJTvyp2v2uyKrvp329HfrVmzffnWj`](https://explorer.alephium.org/addresses/225WevmFp5ZgzPsyVJTvyp2v2uyKrvp329HfrVmzffnWj) | [`23psDicimC5VdpM56wrgqgCzQzcyXWGCkQGSYWbtZAPRq`](https://testnet.alephium.org/addresses/23psDicimC5VdpM56wrgqgCzQzcyXWGCkQGSYWbtZAPRq) |
| Staking | `RewardFeeCollector` | [`22CE7vG6u64zjjsLZLxeJqQuPDydjPvbP9iG1d861j2G7`](https://explorer.alephium.org/addresses/22CE7vG6u64zjjsLZLxeJqQuPDydjPvbP9iG1d861j2G7) | [`29qQ1LPJ5uqawRviXLVDMeo19JUygRrNNTQy5RUBh817D`](https://testnet.alephium.org/addresses/29qQ1LPJ5uqawRviXLVDMeo19JUygRrNNTQy5RUBh817D) |
| Staking | `ALPHLock` | [`yQ1HY2S8kRwv1AwfqvbmXNJuPFczvjvsNMsf4YZ8A5iF`](https://explorer.alephium.org/addresses/yQ1HY2S8kRwv1AwfqvbmXNJuPFczvjvsNMsf4YZ8A5iF) | [`26w4Vn3wUeiDrBc7DCm2bnzWCj7LMEY4HQZZLFEp5SJDV`](https://testnet.alephium.org/addresses/26w4Vn3wUeiDrBc7DCm2bnzWCj7LMEY4HQZZLFEp5SJDV) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.