Tired of non-stop worrying whether you will get liquidated when the market moves? You want to get the maximum out of your Degen Delta Neutral Strategy on Mirror? You want to minimize the risk of your rewards token (SPEC, MIR) losing in value, and rather want to sell them? You want to maintain a healthy LTV on your Anchor Borrow and deposit the borrowed UST into Anchor Earn?
Then, this bot is for you!
Automatically manage all your ANC, MIR, SPEC token rewards, Mirror Delta Neutral Short Positions, UST claims after lockup, Anchor Borrow and Earn for Terra.
If this bot is helpful to you and helps maximize your gainz, feel free to donate a bit to terra1xl0ww4tykjmm4vnzck0qz5luu6rxl97wuwmgfg
. This will also keep the development going and the bot up-to-date. Thank you! :)
Special thanks to unl1k3ly as his bot taught me what I needed to know. Thanks Terra, Mirror, Spectrum, Anchor team and the Terra Community!
I found there are many calculations out there. But most are just wrong. They do not consider volatility or the most important factor hodl time.
So I made 2x overly detailed calculation that I base my decisions on. I consider this valuable for you, even if you do not run the Terra-One-Stop-Bot.
Delta Neutral Simulation & Playground: https://docs.google.com/spreadsheets/d/19WyuPtGz1SGJsCKZGskD7JAGAT9THUFy9b2GtbMR7JI
- '3. Conclusion' shows you which mAssets current would return what APY. You can change what top mAssets you want to consider. The sheet calculates those rankings once per hour new.
- If you want to play a little bit around look at the sheet '0. Calc', and change the yellow filled cells.
- The amount you want to put in is not relevant, as all is calculated based on a percentage basis, as transaction costs are not considered.
Decision Help Min Values: https://docs.google.com/spreadsheets/d/1U9jd5rarvWwbeuGLzkuG7Hyx4B71Pkdrmoj894SGr3M
- Gives you a basis to make your decision what minimum deposits, withdraws, sell quantities, etc. to set for the Terra-One-Stop-Bot.
- Claims and sells your unclaimed MIR, SPEC, ANC tokens
- Claims unlocked UST on Mirror
- Repays debt at Anchor if your LTV requires it
- Borrows more UST from Anchor if you LTV allows it
- Deposits UST (from sale of MIR, SPEC, ANC and Borrow) in Anchor Earn to get more aUST
- Checks each of your shorted positions whether they are below or above your defined limits.
- If above: It will withdraw aUST to return to your defined ratio
- If below: It will deposit more aUST to return to your defined ratio
- Sends you an update via Slack, Telegram or Email
- Runs the bot at your defined intervals
- Runs in debug mode
- Logs information for you
- Other stuff
Due to the order of which the functions are executed, the priority is on a repayment of debt to Anchor rather than depositing more aUST into your shorts on Mirror, as crypto is more volatile than the legacy stock market.
Almost everything can be configured in the B_config.py
.
- Sells your unclaimed MIR, SPEC tokens
XXX_claim_and_sell_token
True/False sale of SPEC, MIR, ANC (SPEC gets claimed from all your farms Mirror, Anchor, Pylon and Spectrum)XXX_min_price
Define a minimum price for SPEC, MIR, ANCXXX_min_total_value
Define a minimum sales value (= price of token * amount to sell) for SPEC, MIR, ANC
- Claims unlocked UST on Mirror
Mirror_claim_unlocked_UST
True/False claim of unlocked USTMirror_min_amount_UST_to_claim
Define a minimum of unlocked UST to be claimed
- Repays debt at Anchor if your LTV requires it
Anchor_enable_auto_repay_of_debt
True/False auto repayment of debtAnchor_enable_withdraw_of_deposited_UST
True/False allowance to withdraw UST from Anchor Earn to repay debtAnchor_enable_partially_repay_if_not_enough_UST_in_wallet
True/False of partial debt repayment (withdraw all deposited UST on Anchor Earn + all UST available in wallet)Anchor_lower_distance
Define lower_distance from maximal ltv ratio below a repayment will be executedAnchor_target_distance
Define target_distance from maximal ltv ratio that is restored when repay debt/borrow more USTAnchor_min_repay_limit
Define minimum debt repayment limit
- Borrows more UST from Anchor if you LTV allows it
Anchor_enable_deposit_borrowed_UST
True/False auto borrow of more USTAnchor_upper_distance
Define upper_distance from maximal ltv ratio above more UST will be borrowedAnchor_min_borrow_limit
Define minimum borrow limit
- Deposits UST (from sale of MIR, SPEC, ANC and Borrow) in Anchor Earn to get more aUST
Anchor_enable_deposit_borrowed_UST
True/False enable deposit of freshly gained UST (from the sale of SPEC, MIR & Mirror claim) into Anchor EarnAnchor_min_deposit_amount
Define minimum UST amount to deposit
- Checks each of your shorted positions
Mirror_enable_deposit_collateral
True/False deposit of collateral (Luna, UST, aUST supported)Mirror_lower_distance
Define lower_distance from minimal ratio below collateral will be depositedMirror_target_distance
Define target_distance from minimal ratio that is restored when depoit/withdraw collateralMirror_min_deposit_limit_in_UST
Define minimum deposit limit in USTMirror_enable_withdraw_collateral
True/False withdraw of collateralMirror_upper_distance
Define upper_distance from minimal ratio above collateral will be withdrawnAnchor_borrow_cooldown
Define cooldown period in days for the auto borrow functionMirror_min_withdraw_limit_in_UST
Define minimum withdraw limit in USTMirror_withdraw_cooldown
Define cooldown period in days for the auto withdraw function
- Sends you a report on Telegram, Slack and/or Email if something has been done. Also writes logs into ./logs and sends you a status update if you want.
Send_me_a_report
True/False prepares a summary of what has happened, if something has happened. Always includes WARNINGs and ERRORs.Notify_Slack
True/False notifications to be received on SlackNotify_Telegram
True/False notifications to be received on TelegramNotify_Gmail
True/False notifications to be send through Gmail to any emailSend_me_a_status_update
True/False if you want to receive a status update anyway depending on yourStatus_update_frequency
Status_update_frequency
Define in what intervals (hours) you want to receive a status updateStatus_update_time
Define at what time you want to receive the status update
- Runs the bot at your defined intervals
Run_interval_for_Scheduler
Define the frequency how often the scheduler should run the bot
- Debug
Debug_mode
True/False debug mode for default.logDisable_all_transaction_defs
True/False disables all transaction functions, by returning a fake transaction hashReturn_failed_tx
True/False if you want that transaction to be a failed transaction hash
- Logging
Logging_detail
Define what level of detail each log shall show
- Other stuff
Safety_multiple_on_transaction_fees
Safety multiple on transaction fees- I also added an Excel sheet for you, to help you decide what minimum values you want to set for your claim & sell strategy as well as for the (not yet implemented) deposit SPEC, MIR, ANC into pools strategy.
- Withdraws any UST from Anchor Borrow to deposit that new UST collateral on Mirror.
- Deposits any UST to Anchor Earn to deposit that new aUST as collateral on Mirror.
- Sells, buys, swaps any Luna to deposit it as collateral on Mirror.
- Uses withdrawn aUST or UST from Mirror to repay your Anchor Borrow debt (if you run the One-Stop-Bot often enough of course it will loop and eventually repay that debt).
- If you withdraw pool rewards, sell them, claim UST etc. and it is still not enough UST to exceed the
config.Anchor_min_deposit_amount
that UST will just remain in your wallet. They will NOT be "remembered" for the next run of the One-Stop-Bot. - The bot currently only supports UST, aUST and Luna as collateral on Mirror (you really should only use aUST anyway).
- This bot is quite heavy, so do not run it too short intervals. It currently has a runtime of around 1 min. Depending on your internet connection.
- Use this bot at your own risk. I have done my best to check it, but program bugs & human bugs happen and I am not financial advisor.
- This bot can be used with the Testnet. I strongly recommend playing on the Testnet or with
Disable_all_transaction_defs
set to True first, before letting it manage your funds for real. Here you can get free UST, LUNA etc: https://faucet.terra.money/. - Since the LTV/min ratios on Mirror and Anchor are defined exactly opposite each other, it may gets confusing to set the
lower_distance
,target_distance
,upper_distance
. I wrote some explanations, but make sure you take time to understand it. - For your own safety all functions are set to False by default. Enable them one by one.
- It's recommended to run this code in a contained environment at maximum security.
- Deposits / withdrawals of collateral as well as repayments / borrowing of debt are limited by an amount. So if your collateral loses lots of value in one day, there will be multiple deposits / repayments per day to keep your funds safe.
- If however, your collateral gains in value and you withdraw aUST from Mirror or borrow more UST from Anchor a time cooldown (which you can define) will act as a limit. If you set the cooldown to 3, only once every 3 days collateral will be withdrawn from Mirror / more UST will be borrowed from Anchor. This decreases the risk / transaction fees when one day your collateral value spikes, just to crash the next day.
- 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 B_Config.py file, make sure you declare it as a system variable.
- Everything will be logged into the
./logs
folder. Make sure you check those from time to time!
git clone
this repository.- Rename
B_Config.py.sample
toB_Config.py
. - Change
B_Config.py
as you desire and feed your seed (a dedicated wallet is recommended). - Run
pip3 install -r A_Requirements.txt
. - Run the One-Stop-Bot with a crontab directly or with
python D_Scheduler.py
. - Make yourself familiar with the bot by using the TESTNET first (Get free UST/LUNA here: https://faucet.terra.money/) by enabling features step-by-step.
- Then use your real wallet on the MAINNET but with
Disable_all_transaction_defs
set to True. - If you feel comfortable set
Disable_all_transaction_defs
to False and let the bot work for you.
If you use more Slack, it might be simpler to be notified there using Slack Webhooks.
- Create a Slack APP.
- Add the APP to a channel and get a webhook URL to feed the
B_Config.py
. More information can be found via this link https://api.slack.com/incoming-webhooks.
If you want to be notified via Telegram, you'd need to get TELEGRAM_TOKEN
and your TELEGRAM_CHAT_ID
from your Telegram bot.
- On Telegram, find
@BotFather
and open a DM. - Use
/newbot
to create a new bot for yourself. - Then, name the bot as you wish, ie:
MyCoolBot
. - Now, choose whatever username you desire for your bot, ie:
MyCool_bot
. - Done! You should see a "Congratulations" message from BotFather.
- Add
MyCool_bot
to a group. - To get your own
chat_id
, simply send a message in the group with your bot and run the following command below:curl -s https://api.telegram.org/botACCESSTOKEN/getUpdates
(replaceACCESSTOKEN
with an actual token you just got from item #5). - With
access_token
andchat_id
just feed theB_Config.py
file.
To send emails from your Google account you need to get a GMAIL_APP_PASSWORD
.
- Go to manage my Google account (https://myaccount.google.com/security).
- Under "Signing in to Google" confirm that "2-Step Verification" is "On" for the account.
- Under "Signing in to Google" select "App passwords".
- Select the app as "Mail" and the device as "Other (Custom name)" and name it (for example: One-Stop-Bot-Terra).
- Copy the app password, it will be in a yellow box and looks like: "cjut fanq prdo diby".
- Deposit in SPEC-UST and MIR-UST Pool instead of selling until min price of SPEC, MIR, ANC is reached and then sell it (I think it gets to complicated...).
- HTML Status Report (function is there, just not formatted properly).
- Run Mirror withdrawals before repay of Anchor Borrow to make use of that available aUST
- Build a front end.