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
Python library for the eWarehousing Solutions API.

eWarehousing Solutions Python Library This library provides convenient access to the eWarehousing Solutions API from applications written in the Pytho

eWarehousing Solutions 2 Nov 09, 2022
Telegram Remote Administration Tool

Telegram Remote Administration Tool DISCLAIMER | Telegram Remote Administration Tool can only be used at your PC. Do not be evil! Читайте на Русском |

13 Nov 12, 2022
SkyzoMusicBot - Bot Music Telegram By Skyzo

SKYZO MUSIC BOT Telegram Music Bot And Stream Feature New Version Ready to use m

Skyzo 19 Apr 08, 2022
A Telegram bot for Minecraft names

MCTelegramBot About this project This bot allows you to see data about minecraft names in Telegram, it has a few commands such as: /names - Show dropp

Kami 5 May 14, 2022
🐙 Share your Github stats for 2020 on Twitter

Year on Github 🐙 Share your Github stats for 2020 on Twitter. This project contains a small web app that let's you share stats about your Github acti

Johannes Rieke 129 Dec 25, 2022
A Phyton script working for stream twits from twitter by tweepy to mongoDB

twitter-to-mongo A python script that uses the Tweepy library to pull Tweets with specific keywords from Twitter's Streaming API, and then stores the

3 Feb 03, 2022
Multi Account Generator Minecraft/NordVPN/Hulu/Origin And ...

Multi Account Generator Minecraft/NordVPN/Hulu/Origin And ...

76 Jan 01, 2023
SSH-Restricted deploys an SSH compliance rule (AWS Config) with auto-remediation via AWS Lambda if SSH access is public.

SSH-Restricted SSH-Restricted deploys an SSH compliance rule with auto-remediation via AWS Lambda if SSH access is public. SSH-Auto-Restricted checks

Adrian Hornsby 30 Nov 08, 2022
A simple object model for the Notion SDK.

A simplified object model for the Notion SDK. This is loosely modeled after concepts found in SQLAlchemy.

Jason Heddings 54 Jan 02, 2023
An API which returns random AOT quote everytime it's invoked

An API which returns random AOT quote everytime it's invoked

Nishant Sapkota 1 Feb 07, 2022
ALIEN: idA Local varIables rEcogNizer

ALIEN: idA Local varIables rEcogNizer ALIEN is an IDA Pro plugin that allows the user to get more information about ida local variables with the help

16 Nov 26, 2022
A telegram bot for generate fake details. Written in python using telethon

FakeDataGenerator A telegram bot for generate fake details. Written in python using telethon. Mandatory variables API_HASH Get it from my telegram.org

Oxidised-Man 6 Dec 19, 2021
The python SDK for Eto, the AI focused data platform for teams bringing AI models to production

Eto Labs Python SDK This is the python SDK for Eto, the AI focused data platform for teams bringing AI models to production. The python SDK makes it e

5 Apr 21, 2022
Repositório para meu Discord Bot pessoal

BassetinhoBot Escrevi o código usando o Python 3.8.3 e até agora não tive problemas rodando nas versões mais recentes. Repositório para o Discord Bot

Vinícius Bassete 1 Jan 04, 2022
Techie Sneh 19 Dec 03, 2021
A collection of scripts to steal BTC from Lightning Network enabled custodial services. Only for educational purpose! Share your findings only when design flaws are fixed.

Lightning Network Fee Siphoning Attack LN-fee-siphoning is a collection of scripts to subtract BTC from Lightning Network enabled custodial services b

Reckless_Satoshi 14 Oct 15, 2022
TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX)

TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX)

Crypto Trader 1 Jan 06, 2022
THERE IS AN IMPOSTER AMONG US. VOTE HIM OUT BEFORE HE [ R E D A C T E D ].

🛡️ Guardian There is an impostor among us. Can you help us find out who it is? ⚙️ Installation and Usage Make sure to install Tesseract-OCR before ru

Catus Magnus 1 Jan 06, 2022
Upbit(업비트) Cryptocurrency Exchange OPEN API Client for Python

Base Repository Python Upbit Client Repository Upbit OPEN API Client @Author: uJhin @GitHub: https://github.com/uJhin/upbit-client/ @Officia

Yu Jhin 37 Nov 06, 2022
OKEX数字货币自动交易python语言SDK

okex-py OKEx数字货币自动交易python语言SDK (非官方) OKEx Cryptocurrency Exchange python SDK (Unofficial) 本项目基于V5 API 使用例子 Example import okex.v5.account_api as acco

43 Dec 01, 2022