Created
August 14, 2023 18:54
-
-
Save thedavidmeister/1ffc12751bc654443605de089306815d to your computer and use it in GitHub Desktop.
slosh seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* op meta ref 613769424da0faccd68bfa8d9b3af911a278c706 */ | |
@0x47ed85f917e187757bff09371cedcf5c0eb277c27e4673feb2d3cc040c66c993 | |
/* ob meta ref 613769424da0faccd68bfa8d9b3af911a278c706 */ | |
@0x56ffc3fc82109c33f1e1544157a70144fc15e7c6e9ae9c65a636fd165b1bc51c | |
#one 1e18 | |
#target-threshold 1e14 | |
#start-time 1683480203 | |
#calculate-order | |
input-slosh-seconds: call<'calculate-slosh-seconds 1>( | |
hash(order-hash() vault-input-token-address()) | |
vault-input-token-decimals() | |
vault-input-balance-before()), | |
output-slosh-seconds: call<'calculate-slosh-seconds 1>( | |
hash(order-hash() vault-output-token-address()) | |
vault-output-token-decimals() | |
vault-output-balance-before()), | |
input-threshold-multiplier: decimal18-div(input-slosh-seconds output-slosh-seconds), | |
amount io-ratio: infinity decimal18-add(one decimal18-mul(target-threshold input-threshold-multiplier)) | |
#handle-io | |
: | |
#calculate-slosh-seconds | |
key vault-decimals vault-balance:, | |
encoded-slosh-seconds: get(key), | |
previous-slosh-seconds: decode-256<0 224>(encoded-slosh-seconds), | |
previous-slosh-time: any(decode-256<224 32>(encoded-slosh-seconds) start-time), | |
elapsed: int-sub(now() previous-slosh-time), | |
new-slosh-seconds: decimal18-add( | |
previous-slosh-seconds | |
decimal18-mul( | |
scale-18-dynamic<0 1>(vault-decimals vault-balance) | |
scale-18<0 1 0>(elapsed) | |
) | |
), | |
:set(key encode-256<224 32>(now() new-slosh-seconds)), | |
_: new-slosh-seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment