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
A module to get data about anime characters, news, info, lyrics and more.

Animec A module to get data about anime characters, news, info, lyrics and more. The module scrapes myanimelist to parse requested data. If you wish t

DriftAsimov 31 Aug 31, 2022
Github repository started notify 💕

Github repository started notify 💕

4 Aug 06, 2022
Connects to a local SenseCap M1 Helium Hotspot and pulls API Data.

sensecap_api_checker_HELIUM Connects to a local SenseCap M1 Helium Hotspot and pulls API Data.

Lorentz Factr 1 Nov 03, 2021
A Powerful, Smart And Simple Userbot In Pyrogram.

Eagle-USERBOT 🇮🇳 A Powerful, Smart And Simple Userbot In Pyrogram. Support 🚑 Inspiration & Credits Userge-X Userge Pokurt Pyrogram Code Owners Mast

Masterolic 1 Nov 28, 2021
Telegram vc userbot

Telegram Vc Userbot Available Commands /ping :- To check whether userbot is up or not /joinvc :- To join vc /leavevc :- To leave vc /join_group :- To

NandyDark 7 Nov 18, 2022
This is an implementation example of a bot that periodically sends predictions to the alphasea-agent.

alphasea-example-model alphasea-example-modelは、 alphasea-agent に対して毎ラウンド、予測を投稿するプログラムです。 Numeraiのexample modelに相当します。 準備 alphasea-example-modelの動作には、

AlphaSea 11 Jul 28, 2022
Unfollows Users You're Following

Github-Unfollow-Bot Info It unfollows users you're following, it runs in the background so you can still do what you do without it bothering you. It's

ExT 4 Sep 03, 2022
A Python Library to interface with Flickr REST API, OAuth & JSON Responses

Python-Flickr Python-Flickr is A Python library to interface with Flickr REST API & OAuth Features Photo Uploading Retrieve user information Common Fl

Mike Helmick 40 Sep 25, 2021
Analytics platform for Telegram Channels

Tele-Report Analytics platform for Telegram Channels 🚧 👷 Getting Started 1- Install redis and postgreSQL (it would be more generic in future, like u

2 Oct 11, 2022
A Python wrapper for the Yelp API v2

python-yelp-v2 A Python wrapper for the Yelp API v2. The structure for this was inspired by the python-twitter library, and some internal methods are

Matthew Conlen 12 Oct 24, 2017
ML-Test-Client

ML-Test-Client Introduction What is this? This Test Client App is to be used to crowd-test machine learning models with the goal of finding the best c

11 Jul 15, 2022
📦 Opensource Python wrapper for Hiven's REST and WebSocket API

hiven.py 📦 Opensource Python wrapper for Hiven's REST and WebSocket API Installation pip install -U hiven.py Usage hiven.py is currently under devel

Kevin Thomas 3 Sep 03, 2021
Github action for automatically determine the version for next release by using repository tags

This action will automatically determine the version for next release by using repository tags

Igor Gov 7 Oct 25, 2022
TG-Url-Uploader-Bot - Telegram RoBot to Upload Links

MW-URL-Uploader Bot Telegram RoBot to Upload Links. Features: 👉 Only Auth Users

Aadhi 3 Jun 27, 2022
Weather_besac is a French twitter bot that tweet the weather of the city of Besançon in Franche-Comté in France every day at 8am and 4pm.

Weather Bot Besac Weather_besac is a French twitter bot that tweet the weather of the city of Besançon in Franche-Comté in France every day at 8am and

Rgld_ 1 Nov 15, 2021
SEMID - OSINT module with lots of discord functions

SEMID Framework About Semid is a framework with different Discord functions and

Hima 20 Sep 23, 2022
Python script to download WAX transactions

WAXtax Python script to download WAX transactions WAXtax uses the CoinGecko API and the WAX Blockchain History API to download csvs for each account y

SixPM Software 11 Oct 09, 2022
Stinky ID - A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon

Ultroid - UserBot A stable pluggable Telegram userbot + Voice & Video Call music

Riyan.rz 1 Jan 03, 2022
An unofficial wrapper for Engineer Man's Piston API

Pistonpy Pistonpy is an API wrapper for the Piston code execution engine by Engineer Man. Key Features Simple modern and efficient Pythonic API using

AalbatrossGuy 4 Jan 03, 2022
Texting service to receive current air quality conditions and maps, powered by AirNow, Twilio, and AWS

The Air Quality Bot is generally available by texting a zip code (and optionally the word "map") to (415) 212-4229. The bot will respond with the late

Alex Laird 8 Oct 16, 2022