tx · FbDETRYBnqtwDBgMfHFTqC8X5KYN78FgkMYFfJa3QNor 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33: -0.01300000 Waves 2023.03.22 22:26 [2501639] smart account 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33 > SELF 0.00000000 Waves
{ "type": 13, "id": "FbDETRYBnqtwDBgMfHFTqC8X5KYN78FgkMYFfJa3QNor", "fee": 1300000, "feeAssetId": null, "timestamp": 1679513199685, "version": 2, "chainId": 84, "sender": "3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33", "senderPublicKey": "5yoY2Atq5TS6YzXkDHGig1DJdaYnWskuGToqK61rQWQd", "proofs": [ "5s7zi59Qn9MALftXSjzDTm8F4WELp27iS8jirB3mL3nzVipy6bJjdvF9XiCWCWfVgq84J1gqurncM6ewwDfFi2J8" ], "script": "base64:BgILCAISABIDCgEIEgANARNrZXlJbnZlc3RXeFh0bkRlbGF5AAITJV9faW52ZXN0V3hYdG5EZWxheQEXa2V5SW52ZXN0V3hYdG5BbW91bnRYdG4AAhclX19pbnZlc3RXeFh0bkFtb3VudFh0bgEMa2V5V3hYdG5Qb29sAAIMJV9fd3hYdG5Qb29sAQ1rZXlYdG5Bc3NldElkAAINJV9feHRuQXNzZXRJZAEKa2V5V3hYdG5McAACCiVfX3d4WHRuTHABDmtleUxwVG9BZGRyZXNzAAIOJV9fbHBUb0FkZHJlc3MBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBGGtleUludmVzdFd4WHRuTGFzdEhlaWdodAACGCVfX2ludmVzdFd4WHRuTGFzdEhlaWdodAEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAEByRtYXRjaDAJAKIIAQkBE2tleU1hbmFnZXJQdWJsaWNLZXkAAwkAAQIFByRtYXRjaDACBlN0cmluZ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SBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAED3RhcmdldFB1YmxpY0tleQQHJG1hdGNoMAkBFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tlefMjKbM=", "height": 2501639, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4CytMZxhPesoTXAfYRzapDMBnEXLhX4agEVD5e82fYUC Next: 6wRM5vehNqyUqgQ2gVcQSKTgMW3bJymqw4xiyiuh49w2 Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func investWxXtn () = { | |
73 | - | let checkCaller = mustManager(i) | |
74 | - | if ((checkCaller == checkCaller)) | |
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)) | |
75 | 79 | then { | |
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)) | |
80 | + | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
81 | + | let lpBefore = assetBalance(this, lpAssetId) | |
82 | + | if ((lpBefore == lpBefore)) | |
82 | 83 | then { | |
83 | - | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
84 | - | let lpBefore = assetBalance(this, lpAssetId) | |
85 | - | if ((lpBefore == lpBefore)) | |
84 | + | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
85 | + | if ((inv == inv)) | |
86 | 86 | then { | |
87 | - | let | |
88 | - | if (( | |
87 | + | let lpAfter = assetBalance(this, lpAssetId) | |
88 | + | if ((lpAfter == lpAfter)) | |
89 | 89 | then { | |
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 | - | } | |
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)] | |
101 | 96 | else throw("Strict value is not equal to itself.") | |
102 | 97 | } | |
103 | 98 | 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 checkCaller = mustManager(i) | |
74 | - | if ((checkCaller == checkCaller)) | |
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)) | |
75 | 79 | then { | |
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)) | |
80 | + | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
81 | + | let lpBefore = assetBalance(this, lpAssetId) | |
82 | + | if ((lpBefore == lpBefore)) | |
82 | 83 | then { | |
83 | - | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
84 | - | let lpBefore = assetBalance(this, lpAssetId) | |
85 | - | if ((lpBefore == lpBefore)) | |
84 | + | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
85 | + | if ((inv == inv)) | |
86 | 86 | then { | |
87 | - | let | |
88 | - | if (( | |
87 | + | let lpAfter = assetBalance(this, lpAssetId) | |
88 | + | if ((lpAfter == lpAfter)) | |
89 | 89 | then { | |
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 | - | } | |
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)] | |
101 | 96 | else throw("Strict value is not equal to itself.") | |
102 | 97 | } | |
103 | 98 | else throw("Strict value is not equal to itself.") | |
104 | 99 | } | |
105 | 100 | else throw("Strict value is not equal to itself.") | |
106 | 101 | } | |
107 | 102 | else throw("Strict value is not equal to itself.") | |
108 | 103 | } | |
109 | 104 | else throw("Strict value is not equal to itself.") | |
110 | 105 | } | |
111 | 106 | ||
112 | 107 | ||
113 | 108 | ||
114 | 109 | @Callable(i) | |
115 | 110 | func setManager (pendingManagerPublicKey) = { | |
116 | 111 | let checkCaller = mustManager(i) | |
117 | 112 | if ((checkCaller == checkCaller)) | |
118 | 113 | then { | |
119 | 114 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
120 | 115 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
121 | 116 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
122 | 117 | else throw("Strict value is not equal to itself.") | |
123 | 118 | } | |
124 | 119 | else throw("Strict value is not equal to itself.") | |
125 | 120 | } | |
126 | 121 | ||
127 | 122 | ||
128 | 123 | ||
129 | 124 | @Callable(i) | |
130 | 125 | func confirmManager () = { | |
131 | 126 | let pm = pendingManagerPublicKeyOrUnit() | |
132 | 127 | let hasPM = if (isDefined(pm)) | |
133 | 128 | then true | |
134 | 129 | else throw("No pending manager") | |
135 | 130 | if ((hasPM == hasPM)) | |
136 | 131 | then { | |
137 | 132 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
138 | 133 | then true | |
139 | 134 | else throw("You are not pending manager") | |
140 | 135 | if ((checkPM == checkPM)) | |
141 | 136 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
142 | 137 | else throw("Strict value is not equal to itself.") | |
143 | 138 | } | |
144 | 139 | else throw("Strict value is not equal to itself.") | |
145 | 140 | } | |
146 | 141 | ||
147 | 142 | ||
148 | 143 | @Verifier(tx) | |
149 | 144 | func verify () = { | |
150 | 145 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
151 | 146 | case pk: ByteVector => | |
152 | 147 | pk | |
153 | 148 | case _: Unit => | |
154 | 149 | tx.senderPublicKey | |
155 | 150 | case _ => | |
156 | 151 | throw("Match error") | |
157 | 152 | } | |
158 | 153 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
159 | 154 | } | |
160 | 155 |
github/deemru/w8io/169f3d6 30.78 ms ◑