tx · 5uvTNbCYV47eK3yoiMZRXERtywbMdohVAQtKGLvTKidN 3Muh4FMqQEciR4eM8aRSHaeSsezQpwgsewY: -0.01000000 Waves 2022.11.24 09:29 [2330822] smart account 3Muh4FMqQEciR4eM8aRSHaeSsezQpwgsewY > SELF 0.00000000 Waves
{ "type": 13, "id": "5uvTNbCYV47eK3yoiMZRXERtywbMdohVAQtKGLvTKidN", "fee": 1000000, "feeAssetId": null, "timestamp": 1669271404580, "version": 2, "chainId": 84, "sender": "3Muh4FMqQEciR4eM8aRSHaeSsezQpwgsewY", "senderPublicKey": "AbKSXC77cdmH8X3UJXcPzxsXqAX2mr2mkYZRjfRBQ7te", "proofs": [ "bAiUAU1V1CNX98x3TYNiGqWj7w7WXTytzJrZp8ZXsLCKuc7NtKn534JPBeGH2JRQadqMPYpzwvpa3STsMYiwf2F" ], "script": "base64:BgIKCAISBgoEAQEBAQsABnNjYWxlOACAwtcvAAdzY2FsZTE2AICAhP6m3uERAAdkaWdpdHM4AAgAFWV4Y2hhbmdlUmF0aW9MaW1pdE1pbgCAlfUqABVleGNoYW5nZVJhdGlvTGltaXRNYXgAgO+5NAAFYWxwaGEAMgALYWxwaGFEaWdpdHMAAgAEYmV0YQCAgN6vz/WVCAEIc2tld25lc3MCAXgBeQkAaQIJAGQCCQBrAwUHc2NhbGUxNgUBeAUBeQkAawMFB3NjYWxlMTYFAXkFAXgAAgENaW52YXJpYW50Q2FsYwIBeAF5BAJzawkBCHNrZXduZXNzAgUBeAUBeQkAZAIJAGsDCQBkAgUBeAUBeQUHc2NhbGUxNgkAbAYFAnNrBQdkaWdpdHM4BQVhbHBoYQULYWxwaGFEaWdpdHMFB2RpZ2l0czgFB0NFSUxJTkcJAGgCAAIJAGsDCQCgAwEJAHYGCQC8AgMJALYCAQUBeAkAtgIBBQF5CQC2AgEFBnNjYWxlOAAACQC2AgEABQABCQBpAgUHZGlnaXRzOAACBQRET1dOCQBsBgkAZQIFAnNrBQRiZXRhBQdkaWdpdHM4B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QDMCAIAAQkAzAgCAAIJAMwIAgADCQDMCAIABAkAzAgCAAUJAMwIAgAGCQDMCAIABwkAzAgCAAgJAMwIAgAJCQDMCAIACgkAzAgCAAsJAMwIAgAMBQNuaWwKAAIkcwkAkAMBBQIkbAoABSRhY2MwCQCYCgYAAQUERG1heAD//////////38FAUIFBEZtaW4FBERtaW4KAQUkZjBfMQICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkBAkRGAgUCJGEJAJEDAgUCJGwFAiRpCgEFJGYwXzICAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAAIBAhRMaXN0IHNpemUgZXhjZWVkcyAxMgkBBSRmMF8yAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgUFJGFjYzAAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAMJAAACCAUBYQJfMQAACQBlAgUBQggFAWECXzIJAGUCBQFCCAUBYQJfNAEBaQEBRAQBQQFCCWludmFyaWFudAZhbW91bnQJAJQKAgUDbmlsCQEBZAQFAUEFAUIFCWludmFyaWFudAUGYW1vdW50ALdGC+o=", "height": 2330822, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 48aSt5oow8Mhe99tnm4mKv85VBRZq3etH4tmQcFumLf7 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let scale8 = 100000000 | |
5 | + | ||
6 | + | let scale16 = 10000000000000000 | |
7 | + | ||
8 | + | let digits8 = 8 | |
9 | + | ||
10 | + | let exchangeRatioLimitMin = 90000000 | |
11 | + | ||
12 | + | let exchangeRatioLimitMax = 110000000 | |
13 | + | ||
14 | + | let alpha = 50 | |
15 | + | ||
16 | + | let alphaDigits = 2 | |
17 | + | ||
18 | + | let beta = 4600000000000000 | |
19 | + | ||
20 | + | func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2) | |
21 | + | ||
22 | + | ||
23 | + | func invariantCalc (x,y) = { | |
24 | + | let sk = skewness(x, y) | |
25 | + | (fraction((x + y), scale16, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(toInt(pow(fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)), 0, toBigInt(5), 1, (digits8 / 2), DOWN)), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
26 | + | } | |
27 | + | ||
28 | + | ||
29 | + | func d (A,B,invariant,amount) = { | |
30 | + | let Dmin = (B - fraction(amount, exchangeRatioLimitMax, scale8)) | |
31 | + | let Dmax = (B - fraction(amount, exchangeRatioLimitMin, scale8)) | |
32 | + | let A_new = (A + amount) | |
33 | + | let Fmin = (invariantCalc(A_new, Dmin) - invariant) | |
34 | + | func DF (a,u) = if ((a._1 == 0)) | |
35 | + | then a | |
36 | + | else { | |
37 | + | let D = a._2 | |
38 | + | let Flastvalid = a._3 | |
39 | + | let Dlastvalid = a._4 | |
40 | + | let Fprev = a._5 | |
41 | + | let Dprev = a._6 | |
42 | + | let F = (invariantCalc(A_new, D) - invariant) | |
43 | + | if ((F == 0)) | |
44 | + | then $Tuple6(0, D, 0, 0, 0, 0) | |
45 | + | else { | |
46 | + | let $t021762304 = if (if ((F > 0)) | |
47 | + | then (Flastvalid > F) | |
48 | + | else false) | |
49 | + | then $Tuple2(F, D) | |
50 | + | else $Tuple2(Flastvalid, Dlastvalid) | |
51 | + | let Fvalid = $t021762304._1 | |
52 | + | let Dvalid = $t021762304._2 | |
53 | + | if (((F - Fprev) == 0)) | |
54 | + | then $Tuple6(1, (D + 1), Fvalid, Dvalid, F, D) | |
55 | + | else { | |
56 | + | let Dnext = (D - fraction(F, (D - Dprev), (F - Fprev))) | |
57 | + | if (((D - Dnext) != 0)) | |
58 | + | then $Tuple6(1, Dnext, Fvalid, Dvalid, F, D) | |
59 | + | else if ((0 > F)) | |
60 | + | then $Tuple6(1, (D + 1), Fvalid, Dvalid, F, D) | |
61 | + | else $Tuple6(0, D, 0, 0, 0, 0) | |
62 | + | } | |
63 | + | } | |
64 | + | } | |
65 | + | ||
66 | + | let a = { | |
67 | + | let $l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | |
68 | + | let $s = size($l) | |
69 | + | let $acc0 = $Tuple6(1, Dmax, 9223372036854775807, B, Fmin, Dmin) | |
70 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
71 | + | then $a | |
72 | + | else DF($a, $l[$i]) | |
73 | + | ||
74 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
75 | + | then $a | |
76 | + | else throw("List size exceeds 12") | |
77 | + | ||
78 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12) | |
79 | + | } | |
80 | + | if ((a._1 == 0)) | |
81 | + | then (B - a._2) | |
82 | + | else (B - a._4) | |
83 | + | } | |
84 | + | ||
85 | + | ||
86 | + | @Callable(i) | |
87 | + | func D (A,B,invariant,amount) = $Tuple2(nil, d(A, B, invariant, amount)) | |
88 | + | ||
89 | + |
github/deemru/w8io/169f3d6 24.49 ms ◑