Skip to content

Commit

Permalink
add example (#159)
Browse files Browse the repository at this point in the history
* add example

* fix example
  • Loading branch information
andrewsource147 authored Nov 20, 2024
1 parent 6e83c5d commit 0d2e641
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ts-client/src/examples/get_claimable_fee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import { Wallet, AnchorProvider } from '@coral-xyz/anchor';
import AmmImpl from '../amm';

const mainnetConnection = new Connection('https://api.mainnet-beta.solana.com');
const provider = new AnchorProvider(mainnetConnection, new Wallet(Keypair.generate()), {
commitment: 'confirmed',
});

async function getClaimableFee(poolAddress: PublicKey, owner: PublicKey) {
const pool = await AmmImpl.create(provider.connection, poolAddress);
let result = await pool.getUserLockEscrow(owner);
console.log('unClaimed: %s', result?.fee.unClaimed.lp?.toString());
console.log(result)
}

async function main() {
// mainnet-beta, SOL-USDC
const poolAddress = 'FRd5CJfLU2TDAUK2m3onvwqXs5md3y96Ad1RUMB5fyii';
const owner = '3CCocQighVbWdoav1Fhp6t2K6v7kWtUEd6Sp59UU77Vt';
await getClaimableFee(new PublicKey(poolAddress), new PublicKey(owner));
}

main();

0 comments on commit 0d2e641

Please sign in to comment.