tx · C7YJ5Jd4Sm89gwyG2Pinfr3LKUM57LiAL7XD7eL39g7m 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33: -0.01300000 Waves 2023.03.22 10:52 [2500954] smart account 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33 > SELF 0.00000000 Waves
{ "type": 13, "id": "C7YJ5Jd4Sm89gwyG2Pinfr3LKUM57LiAL7XD7eL39g7m", "fee": 1300000, "feeAssetId": null, "timestamp": 1679471535479, "version": 2, "chainId": 84, "sender": "3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33", "senderPublicKey": "5yoY2Atq5TS6YzXkDHGig1DJdaYnWskuGToqK61rQWQd", "proofs": [ "64fLAnfdj4usb1CpzjfcMi7hKxjJfKiPYQFobzCjQjYBkA5rpbUQEnSD9roeVDHuAooqxez51GQEDRfZ7byuVVXt" ], "script": "base64:BgILCAISABIDCgEIEgANARNrZXlJbnZlc3RXeFh0bkRlbGF5AAITJV9faW52ZXN0V3hYdG5EZWxheQEXa2V5SW52ZXN0V3hYdG5BbW91bnRYdG4AAhclX19pbnZlc3RXeFh0bkFtb3VudFh0bgEMa2V5V3hYdG5Qb29sAAIMJV9fd3hYdG5Qb29sAQ1rZXlYdG5Bc3NldElkAAINJV9feHRuQXNzZXRJZAEKa2V5V3hYdG5McAACCiVfX3d4WHRuTHABDmtleUxwVG9BZGRyZXNzAAIOJV9fbHBUb0FkZHJlc3MBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBGGtleUludmVzdFd4WHRuTGFzdEhlaWdodAACGCVfX2ludmVzdFd4WHRuTGFzdEhlaWdodAEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAEByRtYXRjaDAJAKIIAQkBE2tleU1hbmFnZXJQdWJsaWNLZXkAAwkAAQIFByRtYXRjaDAC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UVudHJ5AQkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQPdGFyZ2V0UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5K17qbA==", "height": 2500954, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3nJkUjxdAteAU7TY77b5Lc8PtxpHnu5wL4SA31XLrt22 Next: 6vHuVSbyymW6czHJj21vW5v9CH69x5KdjzB2kLiT7znY Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func investWxXtn () = { | |
73 | - | let lastCall = valueOrElse(getInteger(keyInvestWxXtnLastHeight()), 0) | |
74 | - | let delay = getIntegerValue(keyInvestWxXtnDelay()) | |
75 | - | let checks = [if ((height > (lastCall + delay))) | |
76 | - | then true | |
77 | - | else throwErr("wait to invest")] | |
78 | - | if ((checks == checks)) | |
73 | + | let checkCaller = mustManager(i) | |
74 | + | if ((checkCaller == checkCaller)) | |
79 | 75 | then { | |
80 | - | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
81 | - | let lpBefore = assetBalance(this, lpAssetId) | |
82 | - | if ((lpBefore == lpBefore)) | |
76 | + | let lastCall = valueOrElse(getInteger(keyInvestWxXtnLastHeight()), 0) | |
77 | + | let delay = getIntegerValue(keyInvestWxXtnDelay()) | |
78 | + | let checks = [if ((height > (lastCall + delay))) | |
79 | + | then true | |
80 | + | else throwErr("wait to invest")] | |
81 | + | if ((checks == checks)) | |
83 | 82 | then { | |
84 | - | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
85 | - | if ((inv == inv)) | |
83 | + | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
84 | + | let lpBefore = assetBalance(this, lpAssetId) | |
85 | + | if ((lpBefore == lpBefore)) | |
86 | 86 | then { | |
87 | - | let | |
88 | - | if (( | |
87 | + | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
88 | + | if ((inv == inv)) | |
89 | 89 | then { | |
90 | - | let lpGot = (lpAfter - lpBefore) | |
91 | - | let notZeroLp = if ((lpGot == 0)) | |
92 | - | then throwErr("lp to get is zero") | |
93 | - | else unit | |
94 | - | if ((notZeroLp == notZeroLp)) | |
95 | - | then [IntegerEntry(keyInvestWxXtnLastHeight(), height), ScriptTransfer(addressFromStringValue(getStringValue(keyLpToAddress())), lpGot, lpAssetId)] | |
90 | + | let lpAfter = assetBalance(this, lpAssetId) | |
91 | + | if ((lpAfter == lpAfter)) | |
92 | + | then { | |
93 | + | let lpGot = (lpAfter - lpBefore) | |
94 | + | let notZeroLp = if ((lpGot == 0)) | |
95 | + | then throwErr("lp to get is zero") | |
96 | + | else unit | |
97 | + | if ((notZeroLp == notZeroLp)) | |
98 | + | then [IntegerEntry(keyInvestWxXtnLastHeight(), height), ScriptTransfer(addressFromStringValue(getStringValue(keyLpToAddress())), lpGot, lpAssetId)] | |
99 | + | else throw("Strict value is not equal to itself.") | |
100 | + | } | |
96 | 101 | else throw("Strict value is not equal to itself.") | |
97 | 102 | } | |
98 | 103 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func keyInvestWxXtnDelay () = "%__investWxXtnDelay" | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func keyInvestWxXtnAmountXtn () = "%__investWxXtnAmountXtn" | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func keyWxXtnPool () = "%__wxXtnPool" | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyXtnAssetId () = "%__xtnAssetId" | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyWxXtnLp () = "%__wxXtnLp" | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyLpToAddress () = "%__lpToAddress" | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func keyInvestWxXtnLastHeight () = "%__investWxXtnLastHeight" | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
32 | 32 | case s: String => | |
33 | 33 | fromBase58String(s) | |
34 | 34 | case _: Unit => | |
35 | 35 | unit | |
36 | 36 | case _ => | |
37 | 37 | throw("Match error") | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
42 | 42 | case s: String => | |
43 | 43 | fromBase58String(s) | |
44 | 44 | case _: Unit => | |
45 | 45 | unit | |
46 | 46 | case _ => | |
47 | 47 | throw("Match error") | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func throwErr (msg) = throw(makeString(["investor.ride:", msg], " ")) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func mustManager (i) = { | |
55 | 55 | let pd = throwErr("permission denied") | |
56 | 56 | match managerPublicKeyOrUnit() { | |
57 | 57 | case pk: ByteVector => | |
58 | 58 | if ((i.callerPublicKey == pk)) | |
59 | 59 | then true | |
60 | 60 | else pd | |
61 | 61 | case _: Unit => | |
62 | 62 | if ((i.caller == this)) | |
63 | 63 | then true | |
64 | 64 | else pd | |
65 | 65 | case _ => | |
66 | 66 | throw("Match error") | |
67 | 67 | } | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func investWxXtn () = { | |
73 | - | let lastCall = valueOrElse(getInteger(keyInvestWxXtnLastHeight()), 0) | |
74 | - | let delay = getIntegerValue(keyInvestWxXtnDelay()) | |
75 | - | let checks = [if ((height > (lastCall + delay))) | |
76 | - | then true | |
77 | - | else throwErr("wait to invest")] | |
78 | - | if ((checks == checks)) | |
73 | + | let checkCaller = mustManager(i) | |
74 | + | if ((checkCaller == checkCaller)) | |
79 | 75 | then { | |
80 | - | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
81 | - | let lpBefore = assetBalance(this, lpAssetId) | |
82 | - | if ((lpBefore == lpBefore)) | |
76 | + | let lastCall = valueOrElse(getInteger(keyInvestWxXtnLastHeight()), 0) | |
77 | + | let delay = getIntegerValue(keyInvestWxXtnDelay()) | |
78 | + | let checks = [if ((height > (lastCall + delay))) | |
79 | + | then true | |
80 | + | else throwErr("wait to invest")] | |
81 | + | if ((checks == checks)) | |
83 | 82 | then { | |
84 | - | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
85 | - | if ((inv == inv)) | |
83 | + | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
84 | + | let lpBefore = assetBalance(this, lpAssetId) | |
85 | + | if ((lpBefore == lpBefore)) | |
86 | 86 | then { | |
87 | - | let | |
88 | - | if (( | |
87 | + | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
88 | + | if ((inv == inv)) | |
89 | 89 | then { | |
90 | - | let lpGot = (lpAfter - lpBefore) | |
91 | - | let notZeroLp = if ((lpGot == 0)) | |
92 | - | then throwErr("lp to get is zero") | |
93 | - | else unit | |
94 | - | if ((notZeroLp == notZeroLp)) | |
95 | - | then [IntegerEntry(keyInvestWxXtnLastHeight(), height), ScriptTransfer(addressFromStringValue(getStringValue(keyLpToAddress())), lpGot, lpAssetId)] | |
90 | + | let lpAfter = assetBalance(this, lpAssetId) | |
91 | + | if ((lpAfter == lpAfter)) | |
92 | + | then { | |
93 | + | let lpGot = (lpAfter - lpBefore) | |
94 | + | let notZeroLp = if ((lpGot == 0)) | |
95 | + | then throwErr("lp to get is zero") | |
96 | + | else unit | |
97 | + | if ((notZeroLp == notZeroLp)) | |
98 | + | then [IntegerEntry(keyInvestWxXtnLastHeight(), height), ScriptTransfer(addressFromStringValue(getStringValue(keyLpToAddress())), lpGot, lpAssetId)] | |
99 | + | else throw("Strict value is not equal to itself.") | |
100 | + | } | |
96 | 101 | else throw("Strict value is not equal to itself.") | |
97 | 102 | } | |
98 | 103 | else throw("Strict value is not equal to itself.") | |
99 | 104 | } | |
100 | 105 | else throw("Strict value is not equal to itself.") | |
101 | 106 | } | |
102 | 107 | else throw("Strict value is not equal to itself.") | |
103 | 108 | } | |
104 | 109 | else throw("Strict value is not equal to itself.") | |
105 | 110 | } | |
106 | 111 | ||
107 | 112 | ||
108 | 113 | ||
109 | 114 | @Callable(i) | |
110 | 115 | func setManager (pendingManagerPublicKey) = { | |
111 | 116 | let checkCaller = mustManager(i) | |
112 | 117 | if ((checkCaller == checkCaller)) | |
113 | 118 | then { | |
114 | 119 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
115 | 120 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
116 | 121 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
117 | 122 | else throw("Strict value is not equal to itself.") | |
118 | 123 | } | |
119 | 124 | else throw("Strict value is not equal to itself.") | |
120 | 125 | } | |
121 | 126 | ||
122 | 127 | ||
123 | 128 | ||
124 | 129 | @Callable(i) | |
125 | 130 | func confirmManager () = { | |
126 | 131 | let pm = pendingManagerPublicKeyOrUnit() | |
127 | 132 | let hasPM = if (isDefined(pm)) | |
128 | 133 | then true | |
129 | 134 | else throw("No pending manager") | |
130 | 135 | if ((hasPM == hasPM)) | |
131 | 136 | then { | |
132 | 137 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
133 | 138 | then true | |
134 | 139 | else throw("You are not pending manager") | |
135 | 140 | if ((checkPM == checkPM)) | |
136 | 141 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
137 | 142 | else throw("Strict value is not equal to itself.") | |
138 | 143 | } | |
139 | 144 | else throw("Strict value is not equal to itself.") | |
140 | 145 | } | |
141 | 146 | ||
142 | 147 | ||
143 | 148 | @Verifier(tx) | |
144 | 149 | func verify () = { | |
145 | 150 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
146 | 151 | case pk: ByteVector => | |
147 | 152 | pk | |
148 | 153 | case _: Unit => | |
149 | 154 | tx.senderPublicKey | |
150 | 155 | case _ => | |
151 | 156 | throw("Match error") | |
152 | 157 | } | |
153 | 158 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
154 | 159 | } | |
155 | 160 |
github/deemru/w8io/169f3d6 50.47 ms ◑