backwards compatible new version
v2.0 is fully backward compatible. Means you can take this version and update an existing maxi 1.x lambda to 2.0 without any further changes. But if you do not want to use the new single-mint functionality, there is no need to update 1.x as this part has not changed in 2.0.
Vault Maxi via Ocean API
This tool is made to optimize your defichain vault rewards by maximizing the amount of loans put into the liquidity mining of dTokens. You can define the thresholds for your collateralization ratio. if the collateral rises, the tool increases LM-exposure, if it falls it automatically decreases it.
If the parameter is set, it even reinvests the rewards into your vault for automatic compounding.
It is meant to be run as a lambda on AWS, using the ocean-api. Therefore it doesn't need a fullnode or any server maintenance (as opposed to the python version of this script).
main focus: single mint (aka "dusd-maxi")
Vault-Maxi 1.x worked in a simple, straight forward way: it didn't matter what collateral you used, it always minted both tokens for the Liquidity Pool (= "double mint"). This meant that you can only use pools where both tokens can be minted (aka not DUSD-DFI) and in case of DUSD in the collateral, you mint DUSD which you could take directly from the collateral (which is inefficient).
With the new functionality, you can define a "main collateral asset" (either DFI or DUSD) and based on that in combination with the LM-Pair, vault-maxi 2.0 decides itself if it mints both (in case of main = DFI and pool = dStock-DUSD) or if it takes part of the main-asset out of the collateral and mints only the other asset (single mint). Now DUSD-DFI is possible (with main collateral DFI) and also efficient DUSD-only vaults.
Of course it still keeps the vault within the given range. But don't be alarmed: the collateral of the vault will vary now as maxi moves part of the collateral into the LM and back.
Also keep in mind that you need to have enough of the main collateral in the vault, so that maxi can withdraw it and still take loans (so no vault with 50% DUSD and 50% BTC for example)
DUSD to USDC/T arbitrage
to support the DUSD peg and also give you some extra profits, we added automated arbitrage trading. If DUSD is more than 1% off peg, and you have the needed collateral in the vault (depending on the side of the depeg you need DUSD or USDT or USDC) it automatically takes the collateral (in batch sizes defined in the settings), swaps them to the other side and puts them back into the vault. so you make >1% instant win and the ecosystem thanks you for it.
Migration from v1.x to v2.0
If you already have a running version of vault-maxi v1.x and upgrade via the cloud-template, there is no action needed from your side beside double checking all the values in the template. There are new parameters which might need change from your side. Please make sure you fill them in correctly. Specially the LM-pair (instead of LM-token before). In the LM-pair you need to fill in the whole pair (e.g. "QQQ-DUSD") but now you can also fill in "DUSD-DFI". Also check the value of the auto-donation parameter.
If you are updating "manually" by just uploading a new zip, please be aware of the following steps to take:
- The role of your lambda function needs access to the new parameters. the list rule is already a wildcard for all defichain-maxi parameters but the section with
PutParameter
(which currently is just for .../defichain-maxi/state
) additionally needs the resource "Fn::Sub": "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/defichain-maxi/skip"
. compare the template file in the repository for more details
- add the parameter
/defichain-maxi/settings/lm-pair
(which replaces lm-token) and set it to the full pair you want to use (if you used "QQQ" before, set it to "QQQ-DUSD")
How to activate v2 features
single mint
With v2 it is now possible to take only one asset as loan and take the other asset for the LM pair from the collateral of the vault. This is possible for "DUSD-DFI" (minting DUSD, taking DFI from collateral) and all dToken-DUSD pairs (minting the dToken, taking DUSD from collateral).
To activate it, you put in the wanted LM-pair as always and set /defichain-maxi/settings/main-collateral-asset
to the according asset that should be taken from the collateral ("DFI" or "DUSD"). This also means that, if you use DUSD-DFI as pair, it only works with single mint (cause you can't mint DFI). with the other pairs, it depends on your main-collateral-asset if it uses single mint (when main-collateral-asset = DUSD) or mint both (when main-collateral-asset = DFI)
If you want to change from double-mint to single-mint, keep in mind that vault-maxi is not repaying automatically. You need to first remove the exposure with the double-mint setting (easiest by setting maxCollateral = -1) and then let it increase exposure with the single-mint settings.
stablecoin arbitrage
If you set /defichain-maxi/settings/stable-arb-batch-size
to a number greater than 0, vault-maxi will search for arbitrage opportunities in USDT-DUSD and USDC-DUSD (via composite swap over DFI). If it finds one ( min 1% off from parity+fees) and the according asset is in the collateral, it will take up to batchSize out of the vault, use the arbitrage (swap to the other asset with maxPrice 1) and deposit the result back.
The calculations include the commission and fee. So with a DEX-fee of 20% (f.e.) the DUSD->USDC/T arb would not kick in until its at 21% premium, but USDT/C->DUSD will happen right at 1.2% discount (1% buffer + 0.2% commission).
auto donation
Due to frequent requests from users who like our work but forget to donate, we added an auto-donation as percentage of reinvest. If you set /defichain-maxi/settings/auto-donation-percent-of-reinvest
to a value > 0, on every reinvest that the bot does it will take this percentage and donates it to df1qqtlz4uw9w5s4pupwgucv4shl6atqw7xlz2wn07 (thats kuegis address but its split with krysh on a regular basis). So if you choose to donate 5% of your reinvests (aka your rewards), put 5 into the parameter. On every reinvest, the telegram message will also tell you how much you donated for full transparency. We thank everyone for their donations to help fund our development and as a sign of appreciation of our work.
release hashes
windows / debian:
sha256 hash base64: wtVz6oo3/4ufllv0MYcyv/zpr7FpIgsljcVUQe1jbQs=
sha256 hash hex: c2d573ea8a37ff8b9f965bf4318732bffce9afb169220b258dc55441ed636d0b
macOS:
sha256 hash base64: E2S2t4MCOWv2SOITY9D9WyIdN91u0U8KFm6rryeQV1U=
sha256 hash hex: 1364b6b78302396bf648e21363d0fd5b221d37dd6ed14f0a166eabaf27905755
Changes
- added single-mint functionality
- fallback to main ocean on any error
- added skip-parameter (and ignoreSkip in overrides) to allow addon usage
- remove all exposure if dusd interest is greater than the pool APR
- added auto donation feature. (deactivated if no parameter is set, default setting via template is 5%). If activated, it auto donates a user-defined percentage of your reinvest to our donation address.
- added dusd to usdt/c arbitrage
Disclaimer
This is not financial advice and anyone using this tool is doing so at their own risk. Never invest more than you are ok to lose. We are using it ourselves but canât guarantee that itâs working flawlessly in every edge case. We are not responsible for any lost funds.
Donations
We are developing this thing in our free time. Noone is paying us for it. If you benefit from our work, it would be a nice gesture to give something back. Here are our DFI donation addresses:
@kuegi : df1qqtlz4uw9w5s4pupwgucv4shl6atqw7xlz2wn07
@Krysh90 : df1qw2yusvjqctn6p4esyfm5ajgsu5ek8zddvhv8jm
Guide
We wrote an extensive guide for the whole setup process in AWS. If you just want to run the bot, follow this guide and make sure to read the risk-warnings carefully. Vault-Maxi Guide
What's Changed
- Feature/single mint by @kuegi in https://github.com/kuegi/defichain_maxi/pull/38
- added skip feature by @kuegi in https://github.com/kuegi/defichain_maxi/pull/39
- Fixes by @kuegi in https://github.com/kuegi/defichain_maxi/pull/40
- [vault-maxi] added ignoreSkip to overrideParameters by @kuegi in https://github.com/kuegi/defichain_maxi/pull/41
- [vault-maxi] falling back to main ocean in case of any error. by @kuegi in https://github.com/kuegi/defichain_maxi/pull/42
- [rpc] added single-mint functionality by @kuegi in https://github.com/kuegi/defichain_maxi/pull/43
- [maxi] remove/prevent exposure if interest rate is above APR by @kuegi in https://github.com/kuegi/defichain_maxi/pull/48
- [vault maxi] added auto donation. deactivated on default by @kuegi in https://github.com/kuegi/defichain_maxi/pull/49
- [vault-maxi] first version of stable-arb part for DUSD maxi by @kuegi in https://github.com/kuegi/defichain_maxi/pull/45
- Fixes by @kuegi in https://github.com/kuegi/defichain_maxi/pull/50
- [maxi, stableArb] added possible stable-pools for arb by @kuegi in https://github.com/kuegi/defichain_maxi/pull/52
Full Changelog: https://github.com/kuegi/defichain_maxi/compare/v1.1...v2.0
Source code(tar.gz)
Source code(zip)
vault-maxi-2-0.zip(388.09 KB)