tx · 9EqW81K7UzarSSYzPNFaeEYnpTnkLucafmETxAn2zN2K 3N799v7gQfWUJUZftyn8N5KCT6kEk9mptyv: -0.01300000 Waves 2023.05.04 13:13 [2562879] smart account 3N799v7gQfWUJUZftyn8N5KCT6kEk9mptyv > SELF 0.00000000 Waves
{ "type": 13, "id": "9EqW81K7UzarSSYzPNFaeEYnpTnkLucafmETxAn2zN2K", "fee": 1300000, "feeAssetId": null, "timestamp": 1683195219367, "version": 2, "chainId": 84, "sender": "3N799v7gQfWUJUZftyn8N5KCT6kEk9mptyv", "senderPublicKey": "8nc1Yja4nyKr26X3vCYrtM9NpCzMHDz5ne8Lfw6QHymE", "proofs": [ "4PgrTzsfzRdByjPnDZUnJRCduU1QaA5S8ueMUjZaVuN9bEWKykTGKE1yLAi9K1HshUdKyQVArsW558vaJd8Ysuoe" ], "script": "base64:BgIOCAISAwoBCBIAEgMKAQgkAANTRVACAl9fAAZzY2FsZTgAgMLXLwARcG9vbFN0YXRzUHJpY2VLZXkABAAOaWR4UG9vbEFkZHJlc3MAAQANaWR4UG9vbFN0YXR1cwACABBpZHhQb29sTFBBc3NldElkAAMADWlkeEFtdEFzc2V0SWQABAAPaWR4UHJpY2VBc3NldElkAAUADmlkeEFtdEFzc2V0RGNtAAYAEGlkeFByaWNlQXNzZXREY20ABwAOaWR4SUFtdEFzc2V0SWQACAAQaWR4SVByaWNlQXNzZXRJZAAJAA1pZHhMUEFzc2V0RGNtAAoAE2lkeE1hdGNoZXJQdWJsaWNLZXkACwEOa2V5UmVnaXN0ZXJQdXQCC3Bvb2xBZGRyZXNzBHR4SWQJAKwCAgkArAICCQCsAgICCyVzJXMlc19fUF9fBQtwb29sQWRkcmVzcwICX18FBHR4SWQBEWtleVJlZ2lzdGVySW52ZXN0Agtwb29sQWRkcmVzcwR0eElkCQCsAgIJAKwCAgkArAICAhAlcyVzJXNfX2ludmVzdF9fBQtwb29sQWRkcmVzcwICX18FBHR4SWQBFmtleVBvb2xUb3RhbEFtdEJ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HVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5NKEDhA==", "height": 2562879, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9aUmmBXs2nRT5sMFxuD9rbFJjMmnhrnWUHt8gnQbGKtc Next: none Diff:
Old | New | Differences | |
---|---|---|---|
65 | 65 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
66 | 66 | ||
67 | 67 | ||
68 | - | func | |
68 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Acc found.")) | |
92 | 92 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
93 | 93 | ||
94 | 94 | ||
95 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
96 | - | case s: String => | |
97 | - | fromBase58String(s) | |
98 | - | case _: Unit => | |
99 | - | unit | |
100 | - | case _ => | |
101 | - | throw("Match error") | |
102 | - | } | |
95 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
103 | 96 | ||
104 | 97 | ||
105 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
106 | - | case s: String => | |
107 | - | fromBase58String(s) | |
108 | - | case _: Unit => | |
109 | - | unit | |
110 | - | case _ => | |
111 | - | throw("Match error") | |
112 | - | } | |
98 | + | func managerPublicKeyOrUnit () = { | |
99 | + | let managerVaultAddress = getManagerAddressOrFail() | |
100 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
101 | + | case s: String => | |
102 | + | fromBase58String(s) | |
103 | + | case _: Unit => | |
104 | + | unit | |
105 | + | case _ => | |
106 | + | throw("Match error") | |
107 | + | } | |
108 | + | } | |
113 | 109 | ||
114 | 110 | ||
115 | 111 | func mustManager (i) = { | |
173 | 169 | let IdxEstPrAmount = 8 | |
174 | 170 | let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount") | |
175 | 171 | let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount") | |
176 | - | let $ | |
172 | + | let $t066646765 = if ((amBalance >= estAmAmt)) | |
177 | 173 | then $Tuple2(estAmAmt, prBalance) | |
178 | 174 | else $Tuple2(amBalance, estPrAmt) | |
179 | - | let amAmt = $ | |
180 | - | let prAmt = $ | |
175 | + | let amAmt = $t066646765._1 | |
176 | + | let prAmt = $t066646765._2 | |
181 | 177 | let amAssetId = if ((amId == "WAVES")) | |
182 | 178 | then unit | |
183 | 179 | else fromBase58String(amId) | |
187 | 183 | let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)]) | |
188 | 184 | if ((lpPut == lpPut)) | |
189 | 185 | then [StringEntry(keyRegisterInvest(poolAddressStr, toBase58String(i.transactionId)), dataInvestActionInfo(amAmt, prAmt, height, lastBlock.timestamp)), IntegerEntry(keyPoolTotalAmtByAsset(poolAddressStr, amId), (amBalance - amAmt)), IntegerEntry(keyPoolTotalAmtByAsset(poolAddressStr, prId), (prBalance - prAmt))] | |
190 | - | else throw("Strict value is not equal to itself.") | |
191 | - | } | |
192 | - | ||
193 | - | ||
194 | - | ||
195 | - | @Callable(i) | |
196 | - | func setManager (pendingManagerPublicKey) = { | |
197 | - | let checkCaller = mustManager(i) | |
198 | - | if ((checkCaller == checkCaller)) | |
199 | - | then { | |
200 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
201 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
202 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
203 | - | else throw("Strict value is not equal to itself.") | |
204 | - | } | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | ||
210 | - | @Callable(i) | |
211 | - | func confirmManager () = { | |
212 | - | let pm = pendingManagerPublicKeyOrUnit() | |
213 | - | let hasPM = if (isDefined(pm)) | |
214 | - | then true | |
215 | - | else throw("No pending manager") | |
216 | - | if ((hasPM == hasPM)) | |
217 | - | then { | |
218 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
219 | - | then true | |
220 | - | else throw("You are not pending manager") | |
221 | - | if ((checkPM == checkPM)) | |
222 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
223 | - | else throw("Strict value is not equal to itself.") | |
224 | - | } | |
225 | 186 | else throw("Strict value is not equal to itself.") | |
226 | 187 | } | |
227 | 188 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let poolStatsPriceKey = 4 | |
9 | 9 | ||
10 | 10 | let idxPoolAddress = 1 | |
11 | 11 | ||
12 | 12 | let idxPoolStatus = 2 | |
13 | 13 | ||
14 | 14 | let idxPoolLPAssetId = 3 | |
15 | 15 | ||
16 | 16 | let idxAmtAssetId = 4 | |
17 | 17 | ||
18 | 18 | let idxPriceAssetId = 5 | |
19 | 19 | ||
20 | 20 | let idxAmtAssetDcm = 6 | |
21 | 21 | ||
22 | 22 | let idxPriceAssetDcm = 7 | |
23 | 23 | ||
24 | 24 | let idxIAmtAssetId = 8 | |
25 | 25 | ||
26 | 26 | let idxIPriceAssetId = 9 | |
27 | 27 | ||
28 | 28 | let idxLPAssetDcm = 10 | |
29 | 29 | ||
30 | 30 | let idxMatcherPublicKey = 11 | |
31 | 31 | ||
32 | 32 | func keyRegisterPut (poolAddress,txId) = ((("%s%s%s__P__" + poolAddress) + "__") + txId) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyRegisterInvest (poolAddress,txId) = ((("%s%s%s__invest__" + poolAddress) + "__") + txId) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func keyPoolTotalAmtByAsset (poolAddress,assetId) = ((("%s%s%s__total__" + poolAddress) + "__") + assetId) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func keyFactoryContract () = "%s__factoryContract" | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func keySlippageAmtPerAssetCumulative (poolAddress,assetId) = (((("%s%s%s__" + poolAddress) + "__") + assetId) + "__slippageCumulative") | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func keyFactoryConfig () = "%s__factoryConfig" | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2PoolAssets") | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func keyAllPoolsShutdown () = "%s__shutdown" | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
66 | 66 | ||
67 | 67 | ||
68 | - | func | |
68 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Acc found.")) | |
72 | 72 | ||
73 | 73 | func convertAssetId (assetId) = if (!(isDefined(assetId))) | |
74 | 74 | then "WAVES" | |
75 | 75 | else assetId | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func dataPutActionInfo (inAssetId,inAssetAmt,txHeight,txTimestamp) = makeString(["%s%d%d%d", inAssetId, toString(inAssetAmt), toString(txHeight), toString(txTimestamp)], SEP) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func dataInvestActionInfo (outAmountAssetAmt,outPriceAssetAmt,txHeight,txTimestamp) = makeString(["%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(txHeight), toString(txTimestamp)], SEP) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func asString (val) = match val { | |
85 | 85 | case valStr: String => | |
86 | 86 | valStr | |
87 | 87 | case _ => | |
88 | 88 | throw("fail to cast into String") | |
89 | 89 | } | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
93 | 93 | ||
94 | 94 | ||
95 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
96 | - | case s: String => | |
97 | - | fromBase58String(s) | |
98 | - | case _: Unit => | |
99 | - | unit | |
100 | - | case _ => | |
101 | - | throw("Match error") | |
102 | - | } | |
95 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
103 | 96 | ||
104 | 97 | ||
105 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
106 | - | case s: String => | |
107 | - | fromBase58String(s) | |
108 | - | case _: Unit => | |
109 | - | unit | |
110 | - | case _ => | |
111 | - | throw("Match error") | |
112 | - | } | |
98 | + | func managerPublicKeyOrUnit () = { | |
99 | + | let managerVaultAddress = getManagerAddressOrFail() | |
100 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
101 | + | case s: String => | |
102 | + | fromBase58String(s) | |
103 | + | case _: Unit => | |
104 | + | unit | |
105 | + | case _ => | |
106 | + | throw("Match error") | |
107 | + | } | |
108 | + | } | |
113 | 109 | ||
114 | 110 | ||
115 | 111 | func mustManager (i) = { | |
116 | 112 | let pd = throw("Permission denied") | |
117 | 113 | match managerPublicKeyOrUnit() { | |
118 | 114 | case pk: ByteVector => | |
119 | 115 | if ((i.callerPublicKey == pk)) | |
120 | 116 | then true | |
121 | 117 | else pd | |
122 | 118 | case _: Unit => | |
123 | 119 | if ((i.caller == this)) | |
124 | 120 | then true | |
125 | 121 | else pd | |
126 | 122 | case _ => | |
127 | 123 | throw("Match error") | |
128 | 124 | } | |
129 | 125 | } | |
130 | 126 | ||
131 | 127 | ||
132 | 128 | @Callable(i) | |
133 | 129 | func constructor (factoryContract) = { | |
134 | 130 | let checkCaller = mustManager(i) | |
135 | 131 | if ((checkCaller == checkCaller)) | |
136 | 132 | then [StringEntry(keyFactoryContract(), factoryContract)] | |
137 | 133 | else throw("Strict value is not equal to itself.") | |
138 | 134 | } | |
139 | 135 | ||
140 | 136 | ||
141 | 137 | ||
142 | 138 | @Callable(i) | |
143 | 139 | func put () = { | |
144 | 140 | let pool = toString(i.caller) | |
145 | 141 | let pmtAmtAsset = value(i.payments[0]) | |
146 | 142 | let pmtAssetId = if (!(isDefined(pmtAmtAsset.assetId))) | |
147 | 143 | then "WAVES" | |
148 | 144 | else toBase58String(value(pmtAmtAsset.assetId)) | |
149 | 145 | let pmtAssetAmt = pmtAmtAsset.amount | |
150 | 146 | let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(pool)), "Invalid caller"), SEP) | |
151 | 147 | let amountAssetId = parseIntValue(poolAssets[1]) | |
152 | 148 | let priceAssetId = parseIntValue(poolAssets[2]) | |
153 | 149 | let amountAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(amountAssetId)), "Cannot find asset") | |
154 | 150 | let priceAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(priceAssetId)), "Cannot find asset") | |
155 | 151 | let totalAmt = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(pool, pmtAssetId)), 0) | |
156 | 152 | let cumulativeSlippageAmt = valueOrElse(getInteger(this, keySlippageAmtPerAssetCumulative(pool, pmtAssetId)), 0) | |
157 | 153 | [StringEntry(keyRegisterPut(pool, toBase58String(i.transactionId)), dataPutActionInfo(pmtAssetId, pmtAssetAmt, height, lastBlock.timestamp)), IntegerEntry(keyPoolTotalAmtByAsset(pool, pmtAssetId), (totalAmt + pmtAssetAmt)), IntegerEntry(keySlippageAmtPerAssetCumulative(pool, pmtAssetId), (cumulativeSlippageAmt + pmtAssetAmt))] | |
158 | 154 | } | |
159 | 155 | ||
160 | 156 | ||
161 | 157 | ||
162 | 158 | @Callable(i) | |
163 | 159 | func invest (poolAddressStr) = { | |
164 | 160 | let poolAddress = valueOrErrorMessage(addressFromString(poolAddressStr), "invalid pool address") | |
165 | 161 | let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddressStr)), "Invalid pool passed."), SEP) | |
166 | 162 | let amId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found") | |
167 | 163 | let prId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found") | |
168 | 164 | let amBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, amId)), 0) | |
169 | 165 | let prBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, prId)), 0) | |
170 | 166 | let estByPrResult = invoke(poolAddress, "evaluatePutByPriceAssetREADONLY", [prBalance], nil) | |
171 | 167 | let estByAmResult = invoke(poolAddress, "evaluatePutByAmountAssetREADONLY", [amBalance], nil) | |
172 | 168 | let IdxEstAmAmount = 7 | |
173 | 169 | let IdxEstPrAmount = 8 | |
174 | 170 | let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount") | |
175 | 171 | let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount") | |
176 | - | let $ | |
172 | + | let $t066646765 = if ((amBalance >= estAmAmt)) | |
177 | 173 | then $Tuple2(estAmAmt, prBalance) | |
178 | 174 | else $Tuple2(amBalance, estPrAmt) | |
179 | - | let amAmt = $ | |
180 | - | let prAmt = $ | |
175 | + | let amAmt = $t066646765._1 | |
176 | + | let prAmt = $t066646765._2 | |
181 | 177 | let amAssetId = if ((amId == "WAVES")) | |
182 | 178 | then unit | |
183 | 179 | else fromBase58String(amId) | |
184 | 180 | let prAssetId = if ((prId == "WAVES")) | |
185 | 181 | then unit | |
186 | 182 | else fromBase58String(prId) | |
187 | 183 | let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)]) | |
188 | 184 | if ((lpPut == lpPut)) | |
189 | 185 | then [StringEntry(keyRegisterInvest(poolAddressStr, toBase58String(i.transactionId)), dataInvestActionInfo(amAmt, prAmt, height, lastBlock.timestamp)), IntegerEntry(keyPoolTotalAmtByAsset(poolAddressStr, amId), (amBalance - amAmt)), IntegerEntry(keyPoolTotalAmtByAsset(poolAddressStr, prId), (prBalance - prAmt))] | |
190 | - | else throw("Strict value is not equal to itself.") | |
191 | - | } | |
192 | - | ||
193 | - | ||
194 | - | ||
195 | - | @Callable(i) | |
196 | - | func setManager (pendingManagerPublicKey) = { | |
197 | - | let checkCaller = mustManager(i) | |
198 | - | if ((checkCaller == checkCaller)) | |
199 | - | then { | |
200 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
201 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
202 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
203 | - | else throw("Strict value is not equal to itself.") | |
204 | - | } | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | ||
210 | - | @Callable(i) | |
211 | - | func confirmManager () = { | |
212 | - | let pm = pendingManagerPublicKeyOrUnit() | |
213 | - | let hasPM = if (isDefined(pm)) | |
214 | - | then true | |
215 | - | else throw("No pending manager") | |
216 | - | if ((hasPM == hasPM)) | |
217 | - | then { | |
218 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
219 | - | then true | |
220 | - | else throw("You are not pending manager") | |
221 | - | if ((checkPM == checkPM)) | |
222 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
223 | - | else throw("Strict value is not equal to itself.") | |
224 | - | } | |
225 | 186 | else throw("Strict value is not equal to itself.") | |
226 | 187 | } | |
227 | 188 | ||
228 | 189 | ||
229 | 190 | @Verifier(tx) | |
230 | 191 | func verify () = { | |
231 | 192 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
232 | 193 | case pk: ByteVector => | |
233 | 194 | pk | |
234 | 195 | case _: Unit => | |
235 | 196 | tx.senderPublicKey | |
236 | 197 | case _ => | |
237 | 198 | throw("Match error") | |
238 | 199 | } | |
239 | 200 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
240 | 201 | } | |
241 | 202 |
github/deemru/w8io/026f985 31.39 ms ◑