Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalreleasechanges #109

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions ocean-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ saved as a SecureString:
```
/defichain-maxi/wallet/seed
```

optional parameters for extra settings:
```
/defichain-maxi/settings/heartbeat-url (if defined, a GET request is send to this url on every invocation)
/defichain-maxi/settings/log-id (added to every telegram message for unique identification)
/defichain-maxi/settings/keep-wallet-clean (default true: means vaultMaxi uses dust and commission to payback loans etc.)
/defichain-maxi/settings/ocean-urls (comma separated list of alternative ocean-urls that you want to use)
```
optional parameters (if you want telegram notifications)
```
/defichain-maxi/telegram/notifications/chat-id
Expand All @@ -65,23 +73,30 @@ optional parameters (if you want telegram notifications)

### Reinvest pattern

in the reinvest pattern, you can define how the DFI should be used in the reinvest. You can define a space seperated list of targets. each target has the pattern `token:percent:targetAddress` if there is no targetAddress given, the tokens stay in the wallet. collateral tokens that stay in the wallet get deposited to the vault automatically.
in the reinvest pattern, you can define how the DFI should be used in the reinvest. You can define a space or comma seperated list of targets. each target has the pattern `token:percent:targetAddressVault` if there is no targetAddress/Vault given, collateral tokens get deposited to the vault while normal tokens (including LM-Token) stay in your wallet.
the given percent is the part of the reinvest amount that should be used in this target. the sum of all percent-values must not be greater than 100.
If the sum of all given percent numbers is below 100, the remaining percent are equally distributed among all targets without defined percent.

If the token is a LP token, the DFI get swapped 50:50 to the two needed tokens and added to the pool. resulting LP tokens can be send to a targetAddress.

For collateralTokens the targetAddressVault can be a vault-id. Then the tokens are deposited to this vault.

For easier usage you can use `wallet` or `vault` as shortcut for your own address and vault.

examples:

* `DFI` : full reinvest as DFI into the vault
* `DFI DUSD` : half of the amount gets swapped to DUSD, DFI and DUSD get deposited to the vault
* `BTC:10:df1address1 TSLA:15 BTC-DFI:8 SPY-DUSD:20:otheraddress DFI USDT`: 10% swapped to BTC and sent to df1address1, 15% swapped to TSLA and kept in wallet, 8% swapped half to BTC and put into BTC-DFI pool, 20% swapped to SPY and DUSD and the LP-token send to otheraddress, rest (47%) split in DFI and USDT both deposited to the vault.
* `DFI DUSD::wallet` : half of the amount gets swapped to DUSD, DFI get deposited to the vault, DUSD stay in the wallet
* `BTC:10:df1address1 TSLA:15 BTC-DFI:8 SPY-DUSD:20:otheraddress DFI USDT::someVault`: 10% swapped to BTC and sent to df1address1, 15% swapped to TSLA and kept in wallet, 8% swapped half to BTC and put into BTC-DFI pool, 20% swapped to SPY and DUSD and the LP-token send to otheraddress, rest (47%) split in DFI (deposited to own vault) and USDT (deposited to `someVault`)

## Advanced usage
Besides having parameters in the AWS ParameterStore, there is the possibility to set environment variables on a AWS Lambda execution.

Currently following keys are respected with a small description on how they alter execution functionality

### VAULTMAXI_LOGID
(overrides the parameter `/defichain-maxi/settings/log-id` but same functionality)
value: string

will be shown in the prefix of every telegram message. Meant to easily distinguish log messages of different bots
Expand Down Expand Up @@ -117,6 +132,7 @@ value: string
This value overwrites the default seed key parameter to another SecureString parameter, which is further used to initialise your wallet.

### VAULTMAXI_KEEP_CLEAN
(overrides parameter `/defichain-maxi/settings/keep-wallet-clean` but same functionality)
value: string
possible values: `"true", "false"`
default: true
Expand All @@ -126,6 +142,7 @@ Enabled: keeps your address clean by using commissions (dust) to payback loans a
Disabled: will not touch commissions (dust), only what is needed by default calculations

### VAULTMAXI_SWAP_REWARDS_TO_MAIN
DEPRECATED since the new reinvest-pattern
kuegi marked this conversation as resolved.
Show resolved Hide resolved
value: string
possible values: `"true", "false"`
default: true
Expand All @@ -135,6 +152,7 @@ Enabled: rewards will be swapped to your main collateral asset ("DUSD" if not DF
Disabled: rewards will be directly reinvested as DFI

### VAULTMAXI_OCEAN_URL
(will be added internally to the list of `/defichain-maxi/settings/ocean-urls`)
value: string

If provided, this overrides the url to be used as the ocean endpoint. default is "https://ocean.defichain.com" , but you could use custom providers like mydefichain: "https://ocean.mydefichain.com"
Expand Down
6 changes: 3 additions & 3 deletions ocean-client/defichain-cloudtemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
"default": "Heartbeat URL to be called by vault-maxi"
},
"OceanUrls": {
"default": "comma seperated list of ocean urls to use. last in list will be used first. in case of error, it will iterate. official ocean url is always the final fallback."
"default": "Alternative Ocean Urls"
},
"KeepWalletClean": {
"default": "If true, maxi also uses dust (f.e. from commissions) to payback loans or increase more liquidity."
"default": "Keep Wallet Clean"
},
"LogId": {
"default": "Added to every telegram message to help identify between different vault maxi instances."
"default": "Log id"
},
"TelegramNotificationChatId": {
"default": "Notification Chat Id"
Expand Down
2 changes: 1 addition & 1 deletion ocean-client/src/lm-reinvest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class maxiEvent {

const MIN_TIME_PER_ACTION_MS = 300 * 1000 //min 5 minutes for action. probably only needs 1-2, but safety first?

export const VERSION = 'v2.0beta'
export const VERSION = 'v2.0'

export async function main(event: maxiEvent, context: any): Promise<Object> {
console.log('lm-reinvest ' + VERSION)
Expand Down
4 changes: 2 additions & 2 deletions ocean-client/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function delay(ms: number) {
}

export function simplifyAddress(address: string) {
if (address.length > 10) {
return address.substring(0, 5) + '...' + address.substring(address.length - 4)
if (address.length > 15) {
return address.substring(0, 8) + '...' + address.substring(address.length - 4)
} else {
return address
}
Expand Down
2 changes: 1 addition & 1 deletion ocean-client/src/vault-maxi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class maxiEvent {

const MIN_TIME_PER_ACTION_MS = 300 * 1000 //min 5 minutes for action. probably only needs 1-2, but safety first?

export const VERSION = 'v2.4.0rc1'
export const VERSION = 'v2.4.0'

export async function main(event: maxiEvent, context: any): Promise<Object> {
console.log('vault maxi ' + VERSION)
Expand Down