Automator
mimo automator: automate swap for advanced trader.
You need the following tools or knowledge for this page
- 1.
- 2.bash - you need to have basic knowledge about bash functions
The recommended environment of running the automator is on macOS or Linux. On Windows, the best way to use it is WSL (windows subsystem for linux).
Enjoy the lightning fast trading experience provided by mimo on IoTeX network, now with automator!
function deadline() {
ts=`date +"%s"`
printf "%064x\n" `expr $ts + 60`
}
function decimal2hex() {
echo "ibase=A;obase=16;$1" | bc | xargs -0 -I h printf "%64s" h | sed "s/ /0/g"
}
function addLiquidity() {
exchange=$1
min_liquidity=`decimal2hex $2`
max_tokens=`decimal2hex $3`
iotx_amount=$4
dl=`deadline`
ioctl contract invoke bytecode $exchange 422f1043${min_liquidity}${max_tokens}${dl}
}
function removeLiquidity() {
exchange=$1
amount=`decimal2hex $2`
min_iotx=`decimal2hex $3`
min_tokens=`decimal2hex $4`
dl=`deadline`
ioctl contract invoke bytecode $exchange f88bf15a${amount}${min_iotx}${min_tokens}${dl}
}
function getTokenToIotxInputPrice() {
exchange=$1
amount=`decimal2hex $2`
ioctl action read $exchange d458a2d1${amount}
}
function getIotxToTokenInputPrice() {
exchange=$1
amount=`decimal2hex $2`
ioctl action read $exchange a46f9389${amount}
}
function tokenToIotxSwapInput() {
exchange=$1
token_sold=`decimal2hex $2`
min_iotx=`decimal2hex $3`
dl=`deadline`
ioctl contract invoke bytecode $exchange 10dc202f${token_sold}${min_iotx}${dl}
}
function iotxToTokenSwapInput() {
exchange=$1
iotx_sold=`decimal2hex $2`
min_token=`decimal2hex $3`
dl=`deadline`
ioctl contract invoke bytecode $exchange eecd096a${iotx_sold}${min_token}${dl}
}
Last modified 2yr ago