From 2be93ad70d58767df30e296f20af6903b27f8ab3 Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Mon, 14 Aug 2023 21:57:17 +0200 Subject: [PATCH 1/4] fix(bid-script/IBC): keep leading zero --- charts/akash-provider/scripts/price_script_generic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index 7b177c82..792574a1 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -169,7 +169,7 @@ if [[ $isDenom = true ]]; then # sandbox: Axelar USDC *"ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84") max_rate_usd=$(echo '{"price":"'$price'"}' | jq -r '.price | gsub("[^0-9.]"; "")') - rate_per_block_usd_normalized=$(bc -l <<<"scale=18; (${rate_per_block_usd}*1000000)/1") + rate_per_block_usd_normalized=$(bc -l <<<"scale=18; (${rate_per_block_usd}*1000000)/1" | awk '{printf "%.18f", $0}') if bc <<< "$rate_per_block_usd_normalized > $max_rate_usd" | grep -qw 1; then printf "requested rate is too low. min expected %.8f%s" "$rate_per_block_usd_normalized" "$denom" >&2 exit 1 From d789369f24c4feb44e1123e306a3f83c9e659f8f Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Mon, 14 Aug 2023 21:59:01 +0200 Subject: [PATCH 2/4] fix(bid-script/uakt): use the fractional pricing --- charts/akash-provider/scripts/price_script_generic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index 792574a1..e0b8d037 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -145,7 +145,7 @@ total_cost_akt_target=$(bc -l <<<"(${total_cost_usd_target}/$usd_per_akt)") total_cost_uakt_target=$(bc -l <<<"(${total_cost_akt_target}*1000000)") rate_per_block_uakt=$(bc -l <<<"(${total_cost_uakt_target}/${blocks_a_month})") rate_per_block_usd=$(bc -l <<<"(${total_cost_usd_target}/${blocks_a_month})") -total_cost_uakt=$(echo "$rate_per_block_uakt" | jq 'def ceil: if . | floor == . then . else . + 1.0 | floor end; .|ceil') +total_cost_uakt="$(printf "%.8f" $rate_per_block_uakt)" # NOTE: max_rate_usd, max_rate_uakt = are per block rates ! From ba2d5d0835b72eb2cc6626796da10600aba39466 Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Mon, 14 Aug 2023 22:03:06 +0200 Subject: [PATCH 3/4] bump bid script version --- charts/akash-provider/scripts/price_script_generic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index e0b8d037..310d4178 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -2,7 +2,7 @@ # WARNING: the runtime of this script should NOT exceed 5 seconds! (Perhaps can be amended via AKASH_BID_PRICE_SCRIPT_PROCESS_TIMEOUT env variable) # Requirements: # curl jq bc mawk ca-certificates -# Version: Aug-08-2023 +# Version: Aug-14-2023 set -o pipefail # Example: From 5420e8cf15c259efed7bbfa01aa9b85c84a43087 Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Mon, 14 Aug 2023 22:31:04 +0200 Subject: [PATCH 4/4] fix(bid-script): keep 18 digits after a dot --- charts/akash-provider/scripts/price_script_generic.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index 310d4178..79680361 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -145,7 +145,7 @@ total_cost_akt_target=$(bc -l <<<"(${total_cost_usd_target}/$usd_per_akt)") total_cost_uakt_target=$(bc -l <<<"(${total_cost_akt_target}*1000000)") rate_per_block_uakt=$(bc -l <<<"(${total_cost_uakt_target}/${blocks_a_month})") rate_per_block_usd=$(bc -l <<<"(${total_cost_usd_target}/${blocks_a_month})") -total_cost_uakt="$(printf "%.8f" $rate_per_block_uakt)" +total_cost_uakt="$(printf "%.18f" $rate_per_block_uakt)" # NOTE: max_rate_usd, max_rate_uakt = are per block rates ! @@ -158,7 +158,7 @@ if [[ $isDenom = true ]]; then max_rate_uakt=$(echo '{"price":"'$price'"}' | jq -r '.price | gsub("[^0-9.]"; "")') # Hint: bc <<< "$a > $b" (if a is greater than b, it will return 1, otherwise 0) if bc <<< "$rate_per_block_uakt > $max_rate_uakt" | grep -qw 1; then - printf "requested rate is too low. min expected %.8f%s" "$rate_per_block_uakt" "$denom" >&2 + printf "requested rate is too low. min expected %.18f%s" "$rate_per_block_uakt" "$denom" >&2 exit 1 fi @@ -171,7 +171,7 @@ if [[ $isDenom = true ]]; then max_rate_usd=$(echo '{"price":"'$price'"}' | jq -r '.price | gsub("[^0-9.]"; "")') rate_per_block_usd_normalized=$(bc -l <<<"scale=18; (${rate_per_block_usd}*1000000)/1" | awk '{printf "%.18f", $0}') if bc <<< "$rate_per_block_usd_normalized > $max_rate_usd" | grep -qw 1; then - printf "requested rate is too low. min expected %.8f%s" "$rate_per_block_usd_normalized" "$denom" >&2 + printf "requested rate is too low. min expected %.18f%s" "$rate_per_block_usd_normalized" "$denom" >&2 exit 1 fi