Working with automations
In the Strategies section of the website, the Automations tab allows users to set up automated actions which are executed when given conditions are met.
Conditions
Before an action is executed, the protocol checks whether the circumstances fit the conditions that have been set. Each Automation must have at least one condition. The following conditions exist:
Value
Checks the price of one currency represented in another currency.
Price change ($)
Checks the change of given currency's price in relation to when the condition was created.
Wallet funds
Checks the amount or value of a given currency in the user’s wallet.
Collateral
Checks the amount or value of a given currency of the user's provided collateral.
Liquidity
Checks the amount or value of a given currency of the user's provided DEX liquidity.
Loan
Checks the size or value of a given currency of a loan taken by the user.
Borrowable amount
Checks the amount of funds a user can borrow of a given borrowable currency.
Interest rate
Checks the interest rate of a given borrowable currency.
Credit line usage
Checks the user's credit line usage.
Automation funds
Checks amount of the user's provided Automation funds.
Staking rewards
Checks to amount of withdrawable staking rewards.
Actions
When all conditions are met, the Automation's action is executed. The following action types exist:
Sell / Buy
Executes a trade on the DEX. Trades are executed at market price for the amount set by the user. When creating the action, the second row determines the minimum trade amount.
Deposit and Redeem
To deposit funds into or create a redemption request in the Money Market.
Add / Withdraw collateral
To add or withdraw collateral.
Add / Withdraw liquidity
To add or withdraw DEX liquidity.
Add / Withdraw Automation funds
To add or withdraw Automation funds.
Borrow / Repay loan
To take out or repay a loan.
Send coins
To send coins to another wallet.
Stake
To stake XKP with a validator.
Withdraw rewards
To withdraw staking awards or re-stake them.
Automation Fees and Funds
As Automations use computational power and blockspace whenever they are executed, the protocol charges a fee. There are two fees to be paid sequentially; Condition fees followed by Action fees. Users pay Condition fees for every checked condition, and thereafter Action fees when the action has been executed successfully.
In the scenario where all conditions have been met but an action cannot be executed, for example when the action is to send coins but there are not enough coins available, Condition fees will be deducted, but not the Action fees as the actions cannot be executed.
Conditions are checked in the order in which they are created. A fee has to paid for every checked condition. However, when there are multiple conditions and one is not met, the following conditions are not checked and no fee has to be paid.
Amounts
When creating an Automation action, an amount has to be entered, for example to decide how much collateral to provide or how many coins to send. There are three different ways how amounts can be set:
The most obvious way is to set a plain number, for example when wanting to send 10 kUSD.
The second option is to set a percentage value. Percentage value have to be entered like
50%
or25%
, decimals are not supported. It is then checked how much funds are available and then the amount corresponding to the given percentage value is used. For example, when there is 500 kUSD provided as collateral and the action is to withdraw 90% of kUSD, 450 kUSD will be withdrawn. When withdrawing collateral, keep in mind that not all of it can be withdrawn because it is needed to back loans.The third option is called
everything except
and can be used by setting negative numbers. For example, it is possible to stake XKP and set the amount-10
. In that case, as many coins will be used as available so that after executing the action exactly 10 XKP will be left.
Examplary use cases
When the value of kUSD is less than 0.99 USDC, sell 10 USDC to buy kUSD.
When the user's collateral of kUSD is less than 100 kUSD, add additional 10 kUSD.
Whenever the amount of liquidity held by the user in kBTC is larger than 0, withdraw all of it.
Whenever the user's loan is worth more than 1000 kUSD, use 10 kUSD to partially repay the loan.
Whenever the interest rate for kUSD loans is below 6%, borrow 100 kUSD.
Whenever your credit line usage is above 90%, add additional 50 XKP as collateral.
Whenever the amount of XKP in the user's wallet is more than 15, stake 10 of it.
Whenever the amount of Automation funds is below 10, add 10 more.
Last updated