♊️ Automatically Withdrawal Bitcoin from Gemini [Updated]
When I originally uploaded the Gemini API buy and withdrawal tutorial to YouTube in April of 2021 Gemini was by far the best place to buy and sell cryptocurrency because of the low transaction fees (0.1%) and the 100% free withdrawals (even on ETH and ERC-20 which was mind blowing value)
Then everything changed
when the fire nation attacked in June of 2022
Below you can find the updated transfer fee schedule which shows the static withdrawal fees of various non-Ethereum based cryptos (Bitcoin for example has a static 0.0001 BTC withdrawal fee or around $2 at the time of writing)
When these withdrawal fees were introduced, it broke the automatic withdrawal script because we weren't accounting for a withdrawal fee.
Below is code that is updated to take these static fees into account. Note that out of the box, the code has been written for BTC and that you will need to update the code for some other static withdrawal fee if you're withdrawing another token
A more sophisticated implementation might use something like BeautifulSoup4 to scrape the transfer fee schedule page for your chosen token withdrawal - but simplicity is king, and the script above should suffice any static withdrawals going forward (even if Gemini ends up changing static fees in the future).
As for ETH and ERC-20 tokens, a more sophisticated implementation of Gemini withdrawals would likely include a call to the gas fee estimation endpoint of the Gemini API (something that I'm hoping to get included in the gemini-python implementation that we've been using on the channel up until this point - if my pull request gets merged you'll need a new layer.zip to use this function in your AWS)
That gas fee estimation function could be used in place of the static fee variable that is included in the gist above
A simple alternative would be instead multiplying the amount_to_withdrawal variable by a factor (maybe 0.8) - this would withdraw 80% of your ETH on some regular basis that you define in AWS
You're not getting the same functionality as before but a factor of .8 should make it so that your ETH withdrawal usually goes through (you'll obviously be left with around 20% of your ETH on Gemini, but over the long term if your goal is HODLing this might not be that big of a deal for you - and you could always increase the factor to .9 / .95 / .99 etc if you're using larger amounts and want to minimize your exposure to exchanges)
Hopefully this has been helpful, check out the original video for a full implementation tutorial
Or if you're fed up with Gemini for changing their fee structure, check out Kraken which as of this writing is the lowest fee exchange available in the US