Skip to content

Commit

Permalink
Merge pull request #97 from mercurial-finance/update-readme
Browse files Browse the repository at this point in the history
update readme copy
  • Loading branch information
00xSam authored Aug 2, 2023
2 parents 58fe179 + a65ff5e commit 31cd828
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions ts-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Discord: https://discord.com/channels/841152225564950528/864859354335412224
1. Install deps

```
npm i @mercurial-finance/mercurial-dynamic-amm-sdk @project-serum/anchor @solana/web3.js @solana/spl-token @solana/spl-token-registry
npm i @mercurial-finance/dynamic-amm-sdk @project-serum/anchor @solana/web3.js @solana/spl-token @solana/spl-token-registry
```

2. Initialize AmmImpl instance

```ts
import AmmImpl, { MAINNET_POOL } from '@mercurial-finance/mercurial-dynamic-amm-sdk';
import AmmImpl, { MAINNET_POOL } from '@mercurial-finance/dynamic-amm-sdk';
import { PublicKey } from '@solana/web3.js';
import { Wallet, AnchorProvider } from '@project-serum/anchor';

Expand All @@ -40,8 +40,28 @@ const provider = new AnchorProvider(mainnetConnection, mockWallet, {
});
// Alternatively, to use Solana Wallet Adapter

const constantProductPool = await AmmImpl.create(connection, MAINNET_POOL.USDC_SOL);
const stablePool = await AmmImpl.create(connection, MAINNET_POOL.USDT_USDC);
// https://station.jup.ag/blog/jupiter-token-list-api#endpoints
const tokenList = await fetch('https://token.jup.ag/all').then(res => res.json());
const USDC = tokenList.find(token => token.address === <USDC_ADDRESS>);
const USDT = tokenList.find(token => token.address === <USDT_ADDRESS>);
const SOL = tokenList.find(token => token.address === <SOL_ADDRESS>);
const constantProductPool = await AmmImpl.create(connection, MAINNET_POOL.USDC_SOL, USDC, SOL);
const stablePool = await AmmImpl.create(connection, MAINNET_POOL.USDT_USDC, USDT, USDC);

// If you need to create multiple, can consider using `createMultiple`
const pools = [
{
pool: MAINNET_POOL.USDC_SOL,
tokenInfoA: USDC,
tokenInfoB: SOL
},
{
pool: MAINNET_POOL.USDT_USDC,
tokenInfoA: USDT,
tokenInfoB: USDC
}
]
const [constantProductPool, stablePool] = await AmmImpl.createMultiple(connection, pools)
```

3. To interact with the AmmImpl
Expand Down
2 changes: 1 addition & 1 deletion ts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mercurial-finance/dynamic-amm-sdk",
"version": "0.4.7",
"version": "0.4.8",
"description": "Mercurial Vaults SDK is a typescript library that allows you to interact with Mercurial v2's AMM.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit 31cd828

Please sign in to comment.