CryptoGnome / LimitSwap

LimitSwap is fully functional DeFi Trading Bot. No fees. You just need to hold LIMIT Utility token in your wallet to use.
https://www.limitswap.com/
278 stars 150 forks source link

Please add "BUY EXACTTOKENS" function #415

Open bobby4star opened 2 years ago

bobby4star commented 2 years ago

Hi Devs,

It would be awesome if you could update the limitswap bot to buy the exact amount of tokens specified, provided that the price/total amount in base is within a specified limit. This will be a great feature where a launch has a max buy limit of say 30,000 tokens, and would allow the bot to buy all 30,000 providing the account has sufficient funds. At the moment, with current bot, it is a guessing game on how much in BNB to buy with, and transactions can fail if sending too much, or can result in only a fraction of tokens being bought vs the maximum permitted amount.

Here I give a suggestion on how the tokens.json file could work:-

[ {

"ENABLED": "true",

"SYMBOL": "CAKE",
"ADDRESS": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",

"BUYAMOUNTINBASE": "0.00005",
"BUYPRICEINBASE":  "0",
"SELLPRICEINBASE": "11111",
"SLIPPAGE": "5",

"MAXTOKENS": "1",
"MOONBAG": "0",

"EXACT_TOKENS": "true",  (over-rides BUYAMOUNTINBASE and instead buys the EXACT_TOKENS at whatever the price is) 
"EXACT_TOKENS_BUY_AMOUNT": "enter exact number of tokens to purchase"
"EXACT_TOKENS_BUY_LIMIT_IN_BASE": "enter max buy amount limit in BNB/basepair, bot does not buy if total price of maxtokens is above this wallet funding limit"   (or omit this step and just let the tx fail if the wallet has insufficient funds)

"RUGDOC_CHECK": "true",
"BUYAFTER_XXX_SECONDS": "0",    
"MAX_FAILED_TRANSACTIONS_IN_A_ROW": "2",    

"LIQUIDITYCHECK": "false",
"LIQUIDITYAMOUNT": "100",
"LIQUIDITYINNATIVETOKEN": "true",
"USECUSTOMBASEPAIR": "false",
"BASESYMBOL": "BUSD",
"BASEADDRESS": "0xe9e7cea3dedca5984780bafc599bd69add087d56",

"SELLAMOUNTINTOKENS": "ALL",
"HASFEES": "false",
"GAS": "8",
"BOOSTPERCENT": "30",
"GASLIMIT": "1000000"

} ]

johnl1824 commented 2 years ago

I think an issue with this is that some mempool and other bots can push the price up and your wallet may not have enough money to buy the amount of tokens you want. I think a possible work around could be something like this (exact # of tokens you want, amount of ETH/BNB you are willing to spend) and if the amount of ETH/BNB that we are willing to spent exceeds the cost of tokens at the time, then it will only buy with the amount of ETH/BNB needed to purchase the max buy. On the otherhand, if the price moves faster and the max # of tokens surpassed the amount of ETH/BNB you are willing to spend, then the bot will just purchase the max amount of ETH/BNB.

Ex. Max buy is 1,000,000 and costs 0.1 ETH at launch We can assign it as (Exact # of tokens: 1,000,000) and Max ETH/BNB willing to spend (1 ETH) If we are able to get max tokens (1,000,000) at 0.25 ETH, then the bot will submit 0.25 ETH in the TX, and the extra 0.75 will not be spent. On the other hand, if the 1,000,000 tokens cost 2 ETH at the time that the buy will be submitted, the bot will spend the Max ETH/BNB that we assigned (1 ETH)