Skip to content

Commit

Permalink
fixed config & copy-trade program
Browse files Browse the repository at this point in the history
  • Loading branch information
outsmartchad committed Jun 21, 2024
1 parent c77d3c6 commit d7c4221
Show file tree
Hide file tree
Showing 104 changed files with 32 additions and 25 deletions.
Empty file modified .DS_Store
100755 → 100644
Empty file.
Empty file modified .github/FUNDING.yml
100755 → 100644
Empty file.
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified CLI_Doc.txt
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified _config.yml
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions bought-tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\\Users\\User\\Desktop\\solana-memecoin-cli\\src\\Trading\\memecoin_trading_strategies\\copy_trading\\bought-tokens.json"
Empty file modified data/.DS_Store
100755 → 100644
Empty file.
Empty file modified data/Image_file/FTW.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified data/metadata_file/metadata.json
100755 → 100644
Empty file.
Empty file modified data/payer_keypair/.DS_Store
100755 → 100644
Empty file.
Empty file modified data/payer_keypair/devnet/.DS_Store
100755 → 100644
Empty file.
Empty file modified data/payer_keypair/mainnet/.DS_Store
100755 → 100644
Empty file.
Empty file modified data/payer_keypair/mainnet/test1_wallet.json
100755 → 100644
Empty file.
Empty file modified data/payer_keypair/mainnet/test_wallet.json
100755 → 100644
Empty file.
Empty file modified data/token_keypair/.DS_Store
100755 → 100644
Empty file.
Empty file modified data/token_keypair/devnet/.DS_Store
100755 → 100644
Empty file.
Empty file modified examples/add_liquidity/add_liq_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/add_liquidity/add_liq_help.txt
100755 → 100644
Empty file.
Empty file modified examples/add_liquidity/expected_output1.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/add_liquidity/expected_output1.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/add_liquidity/expected_output2.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/add_liquidity/expected_output2.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/burn_token/._expected_output1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/burn_token/burn_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/burn_token/burn_help.txt
100755 → 100644
Empty file.
Empty file modified examples/burn_token/expected_output1.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/burn_token/expected_output2.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/buy_token/buy_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/buy_token/buy_help.txt
100755 → 100644
Empty file.
Empty file modified examples/buy_token/expected_output1.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/buy_token/expected_output1.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/buy_token/expected_output2.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/buy_token/expected_output2.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/create_token/._expected_output1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/create_token/._expected_output2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/create_token/create_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/create_token/create_help.txt
100755 → 100644
Empty file.
Empty file modified examples/create_token/expected_output1.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/create_token/expected_output2.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/expected_output1.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/expected_output1.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/expected_output2.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/expected_output2.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/expected_output2.2.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/remove_liquidity/remove_liq_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/remove_liquidity/remove_liq_help.txt
100755 → 100644
Empty file.
Empty file modified examples/sell_token/expected_output1.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/sell_token/expected_output1.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/sell_token/expected_output2.0.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/sell_token/expected_output2.1.jpeg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/sell_token/sell_doc.txt
100755 → 100644
Empty file.
Empty file modified examples/sell_token/sell_help.txt
100755 → 100644
Empty file.
Empty file modified help.js
100755 → 100644
Empty file.
Empty file modified package-lock.json
100755 → 100644
Empty file.
Empty file modified package.json
100755 → 100644
Empty file.
Empty file modified src/.DS_Store
100755 → 100644
Empty file.
Empty file modified src/Pool/add_pool.js
100755 → 100644
Empty file.
Empty file modified src/Pool/check_pool.js
100755 → 100644
Empty file.
Empty file modified src/Pool/create_pool.js
100755 → 100644
Empty file.
Empty file modified src/Pool/formatAmmKeysById.js
100755 → 100644
Empty file.
Empty file modified src/Pool/query_pool.js
100755 → 100644
Empty file.
Empty file modified src/Pool/remove_pool.js
100755 → 100644
Empty file.
Empty file modified src/Pool/swap.js
100755 → 100644
Empty file.
Empty file modified src/Token/burn.js
100755 → 100644
Empty file.
Empty file modified src/Token/create.js
100755 → 100644
Empty file.
Empty file modified src/Token/query.js
100755 → 100644
Empty file.
Empty file modified src/Token/revoke_authority.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/Serum/index.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/dca.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/limit_order.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/swap.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/swap/buy-helper.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/swap/sell-helper.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/jupiter/swap/swap-helper.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/meteora/index.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/orca/index.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/raydium/buy.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/raydium/buy_helper.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/raydium/sell.js
100755 → 100644
Empty file.
Empty file modified src/Trading/dex/raydium/sell_helper.js
100755 → 100644
Empty file.
Empty file.
23 changes: 12 additions & 11 deletions src/Trading/memecoin_trading_strategies/copy_trading/copy-buy.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,28 @@ async function listenToWallets(address) {
console.log("We don't have enough SOL to swap");
throw new Error("We don't have enough SOL to swap");
}
const decreasedTokenPercentage = (current_trader_wallet_state["SOL"] - previous_trader_wallet_state["SOL"]) / previous_trader_wallet_state["SOL"];
const buy_percentage = Math.abs(decreasedTokenPercentage);
const buy_percentage = Math.abs((current_trader_wallet_state["SOL"] - previous_trader_wallet_state["SOL"]) / previous_trader_wallet_state["SOL"]);
const amountOut = current_our_wallet_state[wsol] * buy_percentage;
console.log("amountOut: ", amountOut);
await buy("buy", changedMint, amountOut, wallet)
await saveToJson(changedMint);
buy("buy", changedMint, amountOut, wallet)
saveToJson(changedMint);
previous_our_wallet_state = await retriveWalletState(wallet.publicKey.toBase58());
previous_trader_wallet_state = await retriveWalletState(address.toBase58());
return;
}
else if((!(changedMint in current_trader_wallet_state) || current_trader_wallet_state[changedMint] === 0) && current_trader_wallet_state["SOL"] > previous_trader_wallet_state["SOL"]){
else if((!(changedMint in current_trader_wallet_state) || current_trader_wallet_state[changedMint] <= previous_trader_wallet_state[changedMint] ) && current_trader_wallet_state["SOL"] > previous_trader_wallet_state["SOL"]){
console.log(`selling ${changedMint}...`)
if (!current_our_wallet_state[wsol]) {
console.log("We don't have enough SOL to swap");
throw new Error("We don't have enough SOL to swap");
}
const decreasedTokenPercentage = (current_trader_wallet_state[changedMint] - previous_trader_wallet_state[changedMint]) / previous_trader_wallet_state[changedMint];
const sell_percentage = Math.abs(decreasedTokenPercentage);
if(!changedMint in current_trader_wallet_state){
current_trader_wallet_state[changedMint] = 0;
}
const sell_percentage = Math.abs((current_trader_wallet_state[changedMint] - previous_trader_wallet_state[changedMint]) / previous_trader_wallet_state[changedMint]);
const amountOut = current_our_wallet_state[changedMint] * sell_percentage;
console.log("amountOut: ", amountOut);
await sell("sell", changedMint, amountOut*100, wallet);
sell("sell", changedMint, amountOut*100, wallet);
previous_our_wallet_state = await retriveWalletState(wallet.publicKey.toBase58());
previous_trader_wallet_state = await retriveWalletState(address.toBase58());
return;
Expand Down Expand Up @@ -136,15 +137,15 @@ async function listenToWallets(address) {
const amountOut =
current_our_wallet_state[decreasedToken] * buy_percentage;

await swap(decreasedToken, increasedToken, amountOut, 5);
swap(decreasedToken, increasedToken, amountOut, 5);

} else if (current_our_wallet_state[wsol]) {
// use sol to buy it if we don't have decreased token
const buy_percentage = Math.abs(decreasedTokenPercentage);
const amountOut = current_our_wallet_state[wsol] * buy_percentage;

await buy("buy", increasedToken, amountOut, wallet)
await saveToJson(increasedToken);
buy("buy", increasedToken, amountOut, wallet)
saveToJson(increasedToken);
}
} else {
// when the trader is swapping usdt to usdc, ignore it
Expand Down
2 changes: 1 addition & 1 deletion src/Trading/memecoin_trading_strategies/copy_trading/copy-sell.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function copy_sell(address){
console.log(`Selling ${token}...`);
soldTokens.push(token);
flag = true;
await sell("sell", token, 100, wallet);
sell("sell", token, 100, wallet);
}
}

Expand Down
Empty file.
Empty file modified src/Trading/memecoin_trading_strategies/copy_trading/index.js
100755 → 100644
Empty file.
Empty file modified src/Trading/memecoin_trading_strategies/stop-loss.js
100755 → 100644
Empty file.
Empty file modified src/Trading/memecoin_trading_strategies/take-profit.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/buy.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/constants.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/create.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/idl.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/sell.js
100755 → 100644
Empty file.
Empty file modified src/Trading/pump.fun/utils.js
100755 → 100644
Empty file.
Empty file modified src/Trading/volume/boost_volume.js
100755 → 100644
Empty file.
Empty file modified src/Transactions/bloXroute_tips_tx_executor.js
100755 → 100644
Empty file.
Empty file modified src/Transactions/jito_tips_tx_executor.js
100755 → 100644
Empty file.
Empty file modified src/Transactions/simple_tx_executor.js
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions src/helpers/.env.copy
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ SHYFT_API_KEY = YOUR_SHYFT_API_KEY
# recommend to use 0.00009
# specify the fee for jito if you want to land your transaction faster
JITO_FEE = "0.001"
TAKE_PROFIT = 0.1 # sell when price up 10%
STOP_LOST = 0.2 # sell when price down 20%
Empty file modified src/helpers/check_balance.js
100755 → 100644
Empty file.
29 changes: 16 additions & 13 deletions src/helpers/config.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ function loadKeypairFromFile(filename) {
const jito_fee = process.env.JITO_FEE; // 0.00009 SOL
const shyft_api_key = process.env.SHYFT_API_KEY; // your shyft api key
const wallet = Keypair.fromSecretKey(bs58.decode(process.env.PRIVATE_KEY)); // your wallet
const dev_endpoint = process.env.DEVNET_ENDPOINT; // devnet endpoint
const dev_endpoint = process.env.DEVNET_ENDPOINT; // devnet endpoint, if you use devnet
const main_endpoint = process.env.MAINNET_ENDPOINT; // mainnet endpoint
const second_main_endpoint = process.env.SECOND_MAINNET_ENDPOINT; // second mainnet endpoint
const RPC_Websocket_endpoint = process.env.WS_ENDPOINT;
const second_RPC_Websocket_endpoint = process.env.SECOND_WS_ENDPOINT;
const smart_money_wallet = process.env.SMART_MONEY_WALLET; // smart money wallet
const connection = new Connection(main_endpoint, {
wsEndpoint: RPC_Websocket_endpoint,
commitment: "confirmed",
});
const second_connection = new Connection(second_main_endpoint, {
wsEndpoint: second_RPC_Websocket_endpoint,
commitment: "confirmed",
});
// const second_main_endpoint = process.env.SECOND_MAINNET_ENDPOINT; // if you use copy trade program, second mainnet endpoint
// const RPC_Websocket_endpoint = process.env.WS_ENDPOINT;
// const second_RPC_Websocket_endpoint = process.env.SECOND_WS_ENDPOINT; // if you use copy trade program
// const stop_lost = process.env.STOP_LOST; // percentage of stop lost, if you use copy trade program
// const take_profit = process.env.TAKE_PROFIT; // percentage of take profit, if you use copy trade program
// const smart_money_wallet = process.env.SMART_MONEY_WALLET; // if you use copy trade program
const connection = new Connection(main_endpoint, "confirmed"); // mainnet connection
//const connection = new Connection(main_endpoint, { // if you use copy trade program
// wsEndpoint: RPC_Websocket_endpoint,
// commitment: "confirmed",
//});
//const second_connection = new Connection(second_main_endpoint, { // if you use copy trade program
// wsEndpoint: second_RPC_Websocket_endpoint,
// commitment: "confirmed",
//});
const dev_connection = new Connection(dev_endpoint, "confirmed"); // devnet connection

const PROGRAMIDS = MAINNET_PROGRAM_ID; // raydium mainnet program address
Expand Down
Empty file modified src/helpers/constant.js
100755 → 100644
Empty file.
Empty file modified src/helpers/util.js
100755 → 100644
Empty file.

0 comments on commit d7c4221

Please sign in to comment.