-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpumpswap_trading.ts
More file actions
30 lines (26 loc) · 1000 Bytes
/
Copy pathpumpswap_trading.ts
File metadata and controls
30 lines (26 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { DexType } from 'sol-trade-sdk';
import {
RUN_LIVE,
createExampleClient,
describeDryRun,
exampleBuyParams,
exampleSellParams,
logResult,
} from './_shared';
async function main() {
const client = createExampleClient();
const buyParams = exampleBuyParams(DexType.PumpSwap);
const sellParams = exampleSellParams(DexType.PumpSwap);
describeDryRun('PumpSwap trading example with cashback-aware params');
console.log('Wallet:', client.getPayer().toBase58());
console.log('Buy params:', { dexType: buyParams.dexType, amount: buyParams.inputTokenAmount });
console.log('Sell params:', { dexType: sellParams.dexType, amount: sellParams.inputTokenAmount });
if (RUN_LIVE) {
const latest = await client.getLatestBlockhash();
buyParams.recentBlockhash = latest.blockhash;
sellParams.recentBlockhash = latest.blockhash;
logResult('buy', await client.buy(buyParams));
logResult('sell', await client.sell(sellParams));
}
}
main().catch(console.error);