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