Anchor Protocol Script that can save you from being liquidated!

Overview

Why

My day job requires a fairly good amount of automation from time to time. Besides, I do like computers to work on what I cannot while I'm sleeping!

AnchorHoDL is an implementation that auto-pay/auto-borrow based on whatever config you desire.

I've started this app due my own needs and to learn more about Terra's ecosystem.

How it works

  1. It will query Anchor smart contracts checking LTV (Loan-to-Value);
  2. If the LTV is grater than trigger_at_percent it will trigger a repay action.
  3. If the amount required to repay (target_percent) is in the wallet, it will be used and loan will repay back to target_percent mark.
  4. If not, it will withdraw from aUST (Anchor deposit).
  5. The script will NOT sell any asset to pay loan.
  6. If enabled_auto_borrow is enabled (by default) and current LTV is smaller than auto_borrow_at_percent, an auto borrow will be trigger moving LTV to target_percent.

How to use it

  1. git clone this repository.
  2. Rename config.py.sample to config.py.
  3. Change config.py as you desire and feed your seed (a dedicated wallet is recommended).
  4. Run pip3 install -r requirements.txt
  5. Run python3 webview.py and simply browsing to http://localhost:5000 for an auto-pay/borrow running every 30 seconds. OR Run python3 anchor_loan_repay.py once or use a while loop to run evey 30 seconds while true; do python3 anchor_loan_repay.py; sleep 30; done

installing

Persistence mode

  1. Install gunicorn: pip3 install gunicorn
  2. Run gunicorn -b 127.0.0.1:5000 webview:app --daemon

Done! gunicorn is running as daemon!

Docker mode

  1. If you don't have Docker installed, grab if from https://docs.docker.com/get-docker/.
  2. Once installed, clone this repository by git clone https://github.com/unl1k3ly/AnchorHODL
  3. Rename config.py.sample to config.py and provide details.
  4. Build the image with docker build -t AnchorHODL .
  5. Run the image with docker run -p 5000:5000 AnchorHODL:latest or add -d if you want to run it as a daemon.
  6. Check if its working by http://localhost:5000

Screenshots

  • You can run the script in your terminal in a tmux/screen session as per figure below: Webview

  • Or (recommended) you can spin a web service that does everything for you after you ran python3 webview.py Webview

Slack Notification

If you use more Slack on daily bases like me, it might be simpler to be notified in there using Slack Webhooks.

  1. Create a Slack APP.
  2. Add the APP to a channel and get a webhook URL to feed the config.py.

More information can be found via this link https://api.slack.com/incoming-webhooks

Telegram Notification

If you want to be notified via Telegram, you'd need to get access_token and your chat_id from your Telegram bot. If you are not familiarized creating a Telegram bot, please follow steps below:

  1. On Telegram, find @BotFather and open a DM.
  2. Use /newbot to create a new bot for yourself.
  3. Then, name the bot as you wish, ie: MyCoolBot
  4. Now, choose whatever username you desire for your bot, ie: MyCool_bot
  5. Done! You should see a "Congratulations" message from BotFather.
  6. To get your own chat_id, simply open a DM with your bot, send something up and run the following command below: curl -s https://api.telegram.org/ACCESSTOKEN/getUpdates (replace ACCESSTOKEN with an actual token you just got from item #5).
  7. With access_token and chat_id just feed the config.py file.

If these instructions are unclear, just Google "How to create a Telegram Bot and get your own chat_id"!

Considerations

  • It's recommended to run this code in a contained environment at maximum security. Dockerfile is also provided if you want to deploy it seamless somewhere.
  • If you are using the webview, ensure the access is restricted and not exposed to the entire Internet. You can use "CloudFare Argo Tunnel" for that.
  • Since a wallet seed is required, ensure you protect it and know what you're doing while using this automation ...
  • If you don't want to pass secrets into the config.py file, make sure you declare as a system variable.
  • Everything will be logged into the ./logs folder. Make sure you check those from time to time!

Conclusion

  • I have no intentions to actively develop new features or take issue requests. As mentioned, this automation was to address a self issue I had and consequently avoid liquidation! It works for my own needs.
  • I'm happy to fix bugs or take merge requests.
  • If you intend to modify the code yourself, please do a fork and start from it !

Similar projects

Support!

  • If you feel this project is the right one for you, please, donate to terra1uwkfuh6crvlttqsj2rv0tjpl8v0dy3d4swayg7 if you feel like doing so.

Thanks Terra and Anchor team!

Cheers all!

Owner
how do i do bio
🛰️ Scripts démontrant l'utilisation de l'imagerie RADARSAT-1 à partir d'un seau AWS | 🛰️ Scripts demonstrating the use of RADARSAT-1 imagery from an AWS bucket

🛰️ Scripts démontrant l'utilisation de l'imagerie RADARSAT-1 à partir d'un seau AWS | 🛰️ Scripts demonstrating the use of RADARSAT-1 imagery from an AWS bucket

Agence spatiale canadienne - Canadian Space Agency 4 May 18, 2022
A python package to easy the integration with Direct Online Pay (Mpesa, TigoPesa, AirtelMoney, Card Payments)

python-dpo A python package to easy the integration with Direct Online Pay (DPO) which easily allow you easily integrate with payment options once wit

NEUROTECH 15 Oct 08, 2022
The Simple Google Colab Notebook to Download Files from Direct Link to Google Drive with custom name and bulk link support.

Direct Link to Google Drive (Advanced! 🔥 ) The Most Advanced yet Simple Google Colab Notebook to Download Files from Direct Link to Google Drive. 🆕

Dr.Caduceus 14 Jul 26, 2022
Mushahid Ali 1 Dec 31, 2021
Fully Dockerized cryptocurrencies Trading Bot, based on Freqtrade engine. Multi instances.

Cryptocurrencies Trading Bot - Freqtrade Manager This automated Trading Bot is based on the amazing Freqtrade one. It allows you to manage many Freqtr

Cédric Dugat 47 Dec 06, 2022
Bot for automated buying boxes on Binance

V 1.0 Bot for automated buying boxes on Binance В settings.py выставляем свои COOKIE и свой CSRFTOKEN В settings.py для headers выставляем свои параме

Matvey 3 Jan 18, 2022
python based bot Sends notification to your telegram whenever a new video is released on a youtube channel!

YTnotifier python based bot Sends notification to your telegram whenever a new video is released on a youtube channel! REQUIREMENTS telethon python-de

Mohamed Rizad 6 Jul 23, 2022
Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects

Gnosis-py Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects: EthereumClient, a wrapper over Web3.py Web3 client includin

Gnosis 93 Dec 23, 2022
Discord Bot for server hosts, devs, and admins. Analyzes timings reports & uploads text files to hastebin. Developed by https://birdflop.com.

"Botflop" Click here to invite Botflop to your server. Current abilities Analyze timings reports Paste a timings report to review an in-depth descript

Purpur 76 Dec 31, 2022
Trabalho N1 para a materia Tecnicas de Progamação da Anhembi Morumbi

Projeto da Anhembi Morumbi - Tecnicas de Programação. RPG de Console (CMD) Trabalho proposto pelo professor André Santana, na materia Tecnicas de Prog

Leonardo Silva M de Barros 3 Sep 12, 2021
This Is Advanced Version Of Old Radio Player, An Telegram Bot to Play Radio/Music in Channel or Group Voice Chats.

Telegram Radio Player V2 An Telegram Bot to Play Radio/Music in Channel or Group Voice Chats. This is also the source code of the bot which is being u

SAF ONE 81 Dec 03, 2022
A small python script which runs a speedtest using speedtest.net and inserts it into a Google Docs Spreadsheet.

speedtest-google-sheets This is a small python script which runs a speedtest using speedtest.net and inserts it into a Google Docs Spreadsheet. Setup

marie 2 Feb 10, 2022
TikTok channel bulk ripper based on TikTok-Api and Youtube-dl. Some assembly may be required.

RipTok Script provided as is. Absolutely no guarantee. A TikTok ripper based on TikTokApi and YouTube-dl. Some assembly may be required. positional ar

32 Dec 24, 2022
A fork of discord.py meant to replace it

Texus A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async and

Texus 1 Nov 18, 2021
Telegram bot implementing Lex Arcana using python-telegram-bot library.

Lex Arcana Telegram Bot 🤖 Telegram bot implementing Lex Arcana using python-telegram-bot library. This bot was evaluated for the course "Computer Eng

Nicolò Sonnino 6 Jun 22, 2022
AK-LEECH-BOT - AK LEECH BOT For python

Benefits :- ✓ Google Drive link cloning using gclone.(wip) ✓ Telegram File mirro

5 Mar 24, 2022
A simple, multipurpose Discord bot.

EpicBot 🏅 A simple, multipurpose Discord bot. • Info EpicBot is a multipurpose Discord bot that was designed to make your Discord life easier and coo

Nirlep_5252_ 130 Dec 29, 2022
Watches your earnings on EarnApp and notifies you when you earned balance or received an payout.

EarnApp-Earning-Monitor Watches your earnings on EarnApp and notifies you when you earned balance or received an payout. Installation Install Python3

Yariya 21 Oct 17, 2022
Find Roblox Groups & Send To Discord

Roblox-Group-Finder A tool to help you find ownerless roblox groups :) It's really easy, all you need is a discord webhook :) It will not send locked

1 Dec 13, 2021
❤️ Hi There Im EzilaX ❤️ A next gen powerful telegram group manager bot 😱 for manage your groups and have fun with other cool modules Made By Sadew Jayasekara 🔥

❤️ EzilaX v1 ❤️ Unmaintained. The new repo of @EzilaXBot is Public. (It is no longer based on this source code. The completely rewritten bot available

Sadew Jayasekara 18 Nov 24, 2021