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
Gets instagram public username and returns usefull informations like profilepic(b64), video_urls etc.

InstaSucker Gets instagram public username and returns usefull informations like profilepic(b64), video_urls etc. Information this project contains a

Armin Amiri 5 Apr 30, 2022
🎥 Stream your favorite movie from the terminal!

Stream-Cli stream-cli is a Python scrapping CLI that combine scrapy and webtorrent in one command for streaming movies from your terminal. Installatio

R E D O N E 379 Dec 24, 2022
DadBot 2.0 is an interactive bot that reflects the personality of a typical dad

DadBot 2.0 is an interactive bot that reflects the personality of a typical dad! You can start by running main while all directories are maintained as they are on this GitHub.

1 Dec 04, 2021
Scuttlecrab.py - Python Version of Scuttle Crab Bot

____ _ _ _ ____ _ / ___| ___ _ _| |_|

Fabrizo 4 Jul 08, 2022
Built for streamlining development of Google Assistant Actions

Apprentice Apprentice is a framework built for developing Google Actions via Dialogflow and Google Cloud (serverless) Functions. Includes: plug-and-pl

Andrew Graham-Yooll 9 May 16, 2019
Best DDoS Attack Script Python3, Cyber Attack With 40 Methods

MXDDoS - DDoS Attack Script With 40 Methods (Code Lang - Python 3) Please Don't Attack '.gov' and '.ir' Websites :) Features And Methods 💣 Layer7 GET

7 Mar 07, 2022
Charged's cogs for Red!

Light-Cogs Charged's cogs for Red! Read below for more information. Features and Cogs TechInfo Lots of commands helping you and your devices! Extended

Charged 2 Jan 07, 2022
Telegram group manager moderen and simple.

Upin Robot A Advanced Powerful, Smart And Intelligent Group Management Bot With New And Powerful Features ... Written with Pyrogram and Telethon... If

Muhammad Nawawi 3 Dec 23, 2021
Microservice to extract structured information on EVM smart contracts.

Contract Serializer Microservice to extract structured information on EVM smart contract. Why? Modern NFT contracts may have different names for getPr

WeBill.io 8 Dec 19, 2022
🚀 A fast, flexible and lightweight Discord API wrapper for Python.

Krema A fast, flexible and lightweight Discord API wrapper for Python. Installation Unikorn unikorn add kremayard krema -no-confirmation Pip pip insta

Krema 20 Sep 04, 2022
A bot for Large Fry Larrys

GroupMe Bot Driver This driver is written entirely in Python, and with easy configuration in mind. Using this driver, you'll be able to monitor multip

1 Oct 25, 2021
Slack->DynamDB->Some applications

slack-event-subscriptions About The Project Do you want to get simple attendance checks? If you are using Slack, participants can just react on a spec

UpstageAI 26 May 28, 2022
A muti pairs martingle trading bot for Binance exchange.

multi_pairs_martingle_bot English Documentation A muti pairs martingle trading bot for Binance exchange. Configuration { "platform": "binance_futur

51bitquant 62 Nov 16, 2022
Python script to delete old / embarrassing tweets.

Delete Tweets Do you have hundreds of embarrassing tweets on your Twitter profile, that you tweeted over a decade ago as an innocent high schooler, th

Linda Zheng 9 Nov 26, 2022
This is a script to forward forward large number of documents to another telegram channel.

ChannelForward 😇 This is a Script to Forward Large Number of Documents to Another Telegram Channel. If You Try to Forward Very Large Number of Files

Anjana Madushanka 10 Jun 08, 2021
A telegram mirror bot with an integrated RSS feed reader.

About What is this repo? This is a slightly modified fork which includes some extra features & memes added to my liking. How's this different from the

11 May 15, 2022
Media Replay Engine (MRE) is a framework to build automated video clipping and replay (highlight) generation pipelines for live and video-on-demand content.

Media Replay Engine (MRE) is a framework for building automated video clipping and replay (highlight) generation pipelines using AWS services for live

Amazon Web Services - Labs 30 Nov 29, 2022
Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir.

RUST USERBOT 🇦🇿 Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir. Qurulum Heroku Serverə qurulum git clone https://github.com/rustres

1 Oct 25, 2021
Dumps to CSV all the resources in an organization's member accounts

AWS Org Inventory Dumps to CSV all the resources in an organization's member accounts. Set your environment's AWS_PROFILE and AWS_DEFAULT_REGION varia

Iain Samuel McLean Elder 2 Dec 24, 2021
API RestFull web de pontos turisticos de certa região

##RESTful Web API para exposição de pontos turísticos de uma região## Propor um novo ponto turístico Moderação dos pontos turísticos cadastrados Lista

Lucas Silva 2 Jan 28, 2022