tx · HDoVXExPvAmYpm3krZRECdhHF2oVuPvvGHFDCPnDGvqu 3MztEGxPimSg5sunfGXqcQ4E8XyfCUdFuR4: -0.01000000 Waves 2020.09.10 10:13 [1170895] smart account 3MztEGxPimSg5sunfGXqcQ4E8XyfCUdFuR4 > SELF 0.00000000 Waves
{ "type": 13, "id": "HDoVXExPvAmYpm3krZRECdhHF2oVuPvvGHFDCPnDGvqu", "fee": 1000000, "feeAssetId": null, "timestamp": 1599721984720, "version": 1, "sender": "3MztEGxPimSg5sunfGXqcQ4E8XyfCUdFuR4", "senderPublicKey": "HsPwhJfQ8X8geAdxMReSS5zWVoAfAPMhGKfMcpoV8eP4", "proofs": [ "63z8Tq6uTuy7m6QRhpxmb7QQatGvNF3q6YNMYBVXriK1UzwFVCacbfs4Ah4CcfAuB1d9YWpsNAhE3SJ2Bb8kMfJa" ], "script": "base64:AAIEAAAAAAAAAA0IAhIAEgASBQoDCAEBAAAASAEAAAAOa2V5VWNvbGxhdGVyYWwAAAAAAgAAAAt1Y29sbGF0ZXJhbAEAAAAbZ2VuZXJhdGVLZXlBc3NldExvY2tlZFRvdGFsAAAAAQAAAAdhc3NldElkCQABLAAAAAICAAAAFGFzc2V0X2xvY2tlZF90b3RhbF9fBQAAAAdhc3NldElkAQAAABNrZXlBY2NvdW50T3BlcmF0aW9uAAAAAwAAAAx1bmxvY2tIZWlnaHQAAAAHYWRkcmVzcwAAAAZzdGF0dXMJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABJkZWZvQXNzZXRfbG9ja2VkX18FAAAAB2FkZHJlc3MCAAAAAl9fCQABpAAAAAEFAAAADHVubG9ja0hlaWdodAIAAAACX18FAAAABnN0YXR1cwAAAAAUSWR4T3BlcmF0aW9uQW1vdW50SW4AAAAAAAAAAAAAAAAAE0lkeE9wZXJhdGlvbkFzc2V0SW4AAAAAAAAAAAEAAAAAEUlkeE9wZXJhdGlvblByaWNlAAAAAAAAAAACAAAAABVJ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QFAAAACGFzc2V0T3V0BQAAAANuaWwFAAAAC2J1cm5Pcklzc3VlBQAAABR0cmFuc2ZlclN5bnRoT3JCYXNpYwUAAAAQdWNvbGxhdGVyYWxFbnRyeQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5epDPvQ==", "chainId": 84, "height": 1170895, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func keyUcollateral () = "ucollateral" | |
5 | + | ||
6 | + | ||
7 | + | func generateKeyAssetLockedTotal (assetId) = ("asset_locked_total__" + assetId) | |
8 | + | ||
9 | + | ||
10 | + | func keyAccountOperation (unlockHeight,address,status) = ((((("defoAsset_locked__" + address) + "__") + toString(unlockHeight)) + "__") + status) | |
11 | + | ||
12 | + | ||
13 | + | let IdxOperationAmountIn = 0 | |
14 | + | ||
15 | + | let IdxOperationAssetIn = 1 | |
16 | + | ||
17 | + | let IdxOperationPrice = 2 | |
18 | + | ||
19 | + | let IdxOperationAmountOut = 3 | |
20 | + | ||
21 | + | let IdxOperationAssetOut = 4 | |
22 | + | ||
23 | + | func dataAccountOperation (amountIn,assetIn,price,amountOut,assetOut) = ((((((((toString(amountIn) + "__") + assetIn) + "__") + toString(price)) + "__") + toString(amountOut)) + "__") + assetOut) | |
24 | + | ||
25 | + | ||
26 | + | func readAccountOperationDataArrayOrFail (accOperationKey) = { | |
27 | + | let accOperationDataStr = valueOrErrorMessage(getString(this, accOperationKey), ("There is no request for passed arguments: " + accOperationKey)) | |
28 | + | split(accOperationDataStr, "__") | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | let nullInt = -1 | |
33 | + | ||
34 | + | let nullStr = "NULL" | |
35 | + | ||
36 | + | let factoryAcc = addressFromStringValue(getStringValue(this, "factory")) | |
37 | + | ||
38 | + | func getAssetAddressBySymbolKey (assetSymbol) = (("asset_" + assetSymbol) + "_address") | |
39 | + | ||
40 | + | ||
41 | + | func getAssetSymbolKey (assetAddress) = (("asset_" + assetAddress) + "_symbol") | |
42 | + | ||
43 | + | ||
44 | + | func getAssetMetaKey (assetAddress) = (("asset_" + assetAddress) + "_meta") | |
45 | + | ||
46 | + | ||
47 | + | func getAssetStatusKey (assetAddress) = (("asset_" + assetAddress) + "_status") | |
48 | + | ||
49 | + | ||
50 | + | func getAssetInitHeightKey (assetAddress) = (("asset_" + assetAddress) + "_init_height") | |
51 | + | ||
52 | + | ||
53 | + | func getAssetActivateHeightKey (assetAddress) = (("asset_" + assetAddress) + "_activate_height") | |
54 | + | ||
55 | + | ||
56 | + | func getAssetAddressKey (assetAddress) = (("asset_" + assetAddress) + "_address") | |
57 | + | ||
58 | + | ||
59 | + | func getAssetMinRequiredPoolAmountKey (assetAddress) = (("asset_" + assetAddress) + "_min_pool") | |
60 | + | ||
61 | + | ||
62 | + | func getAssetCurrrentPoolAmountKey (assetAddress) = (("asset_" + assetAddress) + "_current_pool") | |
63 | + | ||
64 | + | ||
65 | + | func getAssetMaxPoolAmountKey (assetAddress) = (("asset_" + assetAddress) + "_max_pool") | |
66 | + | ||
67 | + | ||
68 | + | func getPoolMakerParticipationAmountKey (assetAddress,poolMakerAddress) = (((("pool_" + assetAddress) + "_") + poolMakerAddress) + "_amount") | |
69 | + | ||
70 | + | ||
71 | + | func getPoolMakerParticipationMaxAmountKey (assetAddress,poolMakerAddress) = (((("pool_" + assetAddress) + "_") + poolMakerAddress) + "max_amount") | |
72 | + | ||
73 | + | ||
74 | + | let IdxDefoAssetCode = 0 | |
75 | + | ||
76 | + | let IdxDefoAssetId = 1 | |
77 | + | ||
78 | + | let IdxDefoAssetStatus = 2 | |
79 | + | ||
80 | + | let IdxDefoAssetInitHeight = 3 | |
81 | + | ||
82 | + | let IdxDefoAssetActivateHeight = 4 | |
83 | + | ||
84 | + | let IdxBuyFeePercent = 5 | |
85 | + | ||
86 | + | let IdxSellFeePercent = 6 | |
87 | + | ||
88 | + | let IdxMinPool = 7 | |
89 | + | ||
90 | + | let IdxCurrentPool = 8 | |
91 | + | ||
92 | + | let IdxMaxPool = 9 | |
93 | + | ||
94 | + | let IdxOverCollateralPercent = 10 | |
95 | + | ||
96 | + | let IdxPriceDecimals = 11 | |
97 | + | ||
98 | + | let IdxBaseAssetId = 12 | |
99 | + | ||
100 | + | let IdxMinBuyPayment = 13 | |
101 | + | ||
102 | + | let IdxMinSellPayment = 14 | |
103 | + | ||
104 | + | let IdxBuyLockInterval = 15 | |
105 | + | ||
106 | + | let IdxSellLockInterval = 16 | |
107 | + | ||
108 | + | let IdxPriceOracleAddress = 17 | |
109 | + | ||
110 | + | let stakingAddressStr = getStringValue(factoryAcc, "neutrino_staking") | |
111 | + | ||
112 | + | let stakingAddress = addressFromStringValue(stakingAddressStr) | |
113 | + | ||
114 | + | let cfg = getStringValue(factoryAcc, ("defoAsset_" + toString(this))) | |
115 | + | ||
116 | + | let cfgArray = split(cfg, "__") | |
117 | + | ||
118 | + | let defoAssetCode = cfgArray[IdxDefoAssetCode] | |
119 | + | ||
120 | + | let defoAssetId = fromBase58String(cfgArray[IdxDefoAssetId]) | |
121 | + | ||
122 | + | let priceOracleAddress = addressFromStringValue(cfgArray[IdxPriceOracleAddress]) | |
123 | + | ||
124 | + | let overCollateralPercent = parseIntValue(cfgArray[IdxOverCollateralPercent]) | |
125 | + | ||
126 | + | let baseAssetIdStr = cfgArray[IdxBaseAssetId] | |
127 | + | ||
128 | + | let baseAssetId = fromBase58String(baseAssetIdStr) | |
129 | + | ||
130 | + | let priceDecimals = parseIntValue(cfgArray[IdxPriceDecimals]) | |
131 | + | ||
132 | + | let minBasicBuyAmount = parseIntValue(cfgArray[IdxMinBuyPayment]) | |
133 | + | ||
134 | + | let minSynthSellAmount = parseIntValue(cfgArray[IdxMinSellPayment]) | |
135 | + | ||
136 | + | let buyLockInterval = parseIntValue(cfgArray[IdxBuyLockInterval]) | |
137 | + | ||
138 | + | let sellLockInterval = parseIntValue(cfgArray[IdxSellLockInterval]) | |
139 | + | ||
140 | + | func controlAccReadCurrIdxOrFail () = valueOrErrorMessage(getInteger(priceOracleAddress, "currIdx"), ("No currIdx at controlAcc=" + toString(priceOracleAddress))) | |
141 | + | ||
142 | + | ||
143 | + | func controlAccReadIdxHeight (idx) = { | |
144 | + | let idxHeightKey = ("idxHeight_" + toString(idx)) | |
145 | + | valueOrElse(getInteger(priceOracleAddress, idxHeightKey), 0) | |
146 | + | } | |
147 | + | ||
148 | + | ||
149 | + | func controlAccReadPriceByHeight (priceHeight) = { | |
150 | + | let priceByHeightKey = ("price_" + toString(priceHeight)) | |
151 | + | valueOrErrorMessage(getInteger(priceOracleAddress, priceByHeightKey), ((("No " + priceByHeightKey) + " at controlAcc=") + toString(priceOracleAddress))) | |
152 | + | } | |
153 | + | ||
154 | + | ||
155 | + | func getStakingBalance () = valueOrElse(getInteger(this, ((("rpd_balance_" + baseAssetIdStr) + "_") + toString(this))), 0) | |
156 | + | ||
157 | + | ||
158 | + | let ucollateral = valueOrElse(getInteger(this, keyUcollateral()), 0) | |
159 | + | ||
160 | + | let currPoolAmount = parseIntValue(cfgArray[IdxCurrentPool]) | |
161 | + | ||
162 | + | let doubleCheckBasicBalance = (assetBalance(this, baseAssetId) + getStakingBalance()) | |
163 | + | ||
164 | + | let doubleCheckUcollateral = if ((0 > ucollateral)) | |
165 | + | then 0 | |
166 | + | else ucollateral | |
167 | + | ||
168 | + | let doubleCheckCurrPoolAmount = (doubleCheckBasicBalance - doubleCheckUcollateral) | |
169 | + | ||
170 | + | let price = getIntegerValue(priceOracleAddress, ("price_" + defoAssetCode)) | |
171 | + | ||
172 | + | let overPrice = (((priceDecimals + overCollateralPercent) * price) / priceDecimals) | |
173 | + | ||
174 | + | let emission = value(assetInfo(defoAssetId)).quantity | |
175 | + | ||
176 | + | let basicAssetLockedAmt = valueOrElse(getInteger(this, generateKeyAssetLockedTotal(baseAssetIdStr)), 0) | |
177 | + | ||
178 | + | let availablePoolBalance = (currPoolAmount - basicAssetLockedAmt) | |
179 | + | ||
180 | + | @Callable(i) | |
181 | + | func buyAsset () = if ((currPoolAmount != doubleCheckCurrPoolAmount)) | |
182 | + | then throw(((("Invalid currPoolAmount calculations: currPoolAmount=" + toString(currPoolAmount)) + " doubleCheckCurrPoolAmount=") + toString(doubleCheckCurrPoolAmount))) | |
183 | + | else { | |
184 | + | let pmt = value(i.payments[0]) | |
185 | + | let pmtAsset = value(pmt.assetId) | |
186 | + | let availableDefoAssetInPool = (fraction(availablePoolBalance, priceDecimals, overPrice) - emission) | |
187 | + | let fullDefoAssetAmount = fraction(pmt.amount, priceDecimals, price) | |
188 | + | let defoAssetAmount = if ((fullDefoAssetAmount > availableDefoAssetInPool)) | |
189 | + | then (fullDefoAssetAmount - availableDefoAssetInPool) | |
190 | + | else fullDefoAssetAmount | |
191 | + | let requiredBasicAssetAmount = fraction(defoAssetAmount, price, priceDecimals) | |
192 | + | let change = (pmt.amount - requiredBasicAssetAmount) | |
193 | + | if ((0 >= availableDefoAssetInPool)) | |
194 | + | then throw((("Impossible to issue new " + defoAssetCode) + ": not enough collateral")) | |
195 | + | else if ((pmtAsset != baseAssetId)) | |
196 | + | then throw(((("Payment asset id doesn't match basic asset: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
197 | + | else if ((minBasicBuyAmount > pmt.amount)) | |
198 | + | then throw(((((("Impossible to issue new " + defoAssetCode) + ": payment=") + toString(pmt.amount)) + "is less then min amount=") + toString(minBasicBuyAmount))) | |
199 | + | else [IntegerEntry(keyUcollateral(), (ucollateral + requiredBasicAssetAmount)), Reissue(defoAssetId, defoAssetAmount, true), ScriptTransfer(i.caller, defoAssetAmount, defoAssetId), ScriptTransfer(i.caller, change, baseAssetId)] | |
200 | + | } | |
201 | + | ||
202 | + | ||
203 | + | ||
204 | + | @Callable(i) | |
205 | + | func sellAssetRequest () = { | |
206 | + | let pmt = value(i.payments[0]) | |
207 | + | let pmtAsset = value(pmt.assetId) | |
208 | + | let callerAddress = toString(i.caller) | |
209 | + | let keyAssetLockedTotal = generateKeyAssetLockedTotal(toBase58String(pmtAsset)) | |
210 | + | let currAssetTotalLocked = valueOrElse(getInteger(this, keyAssetLockedTotal), 0) | |
211 | + | let unlockHeight = (height + sellLockInterval) | |
212 | + | let keyAccountLock = keyAccountOperation(unlockHeight, callerAddress, "PENDING") | |
213 | + | if ((pmtAsset != defoAssetId)) | |
214 | + | then throw(((("Invalid payment asset id: expected=" + toBase58String(defoAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
215 | + | else if ((minSynthSellAmount > pmt.amount)) | |
216 | + | then throw(((("Payment amount less then mininimal allowed: paymentAmount=" + toString(pmt.amount)) + " minAmount=") + toString(minSynthSellAmount))) | |
217 | + | else if (isDefined(getInteger(this, keyAccountLock))) | |
218 | + | then throw((((("Sell request has been already defined for " + callerAddress) + "_") + toString(unlockHeight)) + " pair: need to wait next block")) | |
219 | + | else [IntegerEntry(keyAssetLockedTotal, (currAssetTotalLocked + pmt.amount)), StringEntry(keyAccountLock, dataAccountOperation(pmt.amount, toBase58String(defoAssetId), nullInt, nullInt, toBase58String(baseAssetId)))] | |
220 | + | } | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(i) | |
225 | + | func withdraw (accountAddress,unlockHeight,idx) = { | |
226 | + | let accOperationKey = keyAccountOperation(unlockHeight, accountAddress, "PENDING") | |
227 | + | let accOperationDataArray = readAccountOperationDataArrayOrFail(accOperationKey) | |
228 | + | let amountIn = parseIntValue(accOperationDataArray[IdxOperationAmountIn]) | |
229 | + | let assetIn = accOperationDataArray[IdxOperationAssetIn] | |
230 | + | let assetOut = accOperationDataArray[IdxOperationAssetOut] | |
231 | + | if ((unlockHeight > height)) | |
232 | + | then throw((("Please wait " + toString(unlockHeight)) + " to withdraw your funds")) | |
233 | + | else { | |
234 | + | let accountLockedAmt = amountIn | |
235 | + | if ((0 >= accountLockedAmt)) | |
236 | + | then throw("LockedAmount <= 0") | |
237 | + | else { | |
238 | + | let keyAssetLockedTotal = generateKeyAssetLockedTotal(accOperationDataArray[IdxOperationAssetIn]) | |
239 | + | let currAssetLockedTotal = valueOrErrorMessage(getInteger(this, keyAssetLockedTotal), (("State contains sellAssetRequest=" + accOperationKey) + " BUT no totalLocked")) | |
240 | + | let idxHeight = controlAccReadIdxHeight(idx) | |
241 | + | let prevIdxHeight = controlAccReadIdxHeight((idx - 1)) | |
242 | + | let currIdx = controlAccReadCurrIdxOrFail() | |
243 | + | if (if (if ((idx > currIdx)) | |
244 | + | then true | |
245 | + | else (unlockHeight > idxHeight)) | |
246 | + | then true | |
247 | + | else if ((prevIdxHeight != 0)) | |
248 | + | then (prevIdxHeight >= unlockHeight) | |
249 | + | else false) | |
250 | + | then throw(((((((((("invalid price idx: idx=" + toString(idx)) + " currIdx=") + toString(currIdx)) + " idxHeight=") + toString(idxHeight)) + " unlockHeight=") + toString(unlockHeight)) + " prevIdxHeight=") + toString(prevIdxHeight))) | |
251 | + | else { | |
252 | + | let synth2basicPrice = controlAccReadPriceByHeight(idxHeight) | |
253 | + | let assetInBytes = fromBase58String(assetIn) | |
254 | + | let $t01095411824 = if ((assetInBytes == baseAssetId)) | |
255 | + | then { | |
256 | + | let synthAmt = fraction(amountIn, priceDecimals, synth2basicPrice) | |
257 | + | $Tuple4(synthAmt, Reissue(defoAssetId, synthAmt, true), ScriptTransfer(addressFromStringValue(accountAddress), synthAmt, defoAssetId), IntegerEntry(keyUcollateral(), (ucollateral + amountIn))) | |
258 | + | } | |
259 | + | else if ((assetInBytes == defoAssetId)) | |
260 | + | then { | |
261 | + | let basicAmt = fraction(amountIn, synth2basicPrice, priceDecimals) | |
262 | + | let newUcollateral = (ucollateral - basicAmt) | |
263 | + | $Tuple4(basicAmt, Burn(baseAssetId, basicAmt), ScriptTransfer(addressFromStringValue(accountAddress), basicAmt, baseAssetId), IntegerEntry(keyUcollateral(), (ucollateral - basicAmt))) | |
264 | + | } | |
265 | + | else throw(("Unsupported assetIn=" + assetIn)) | |
266 | + | let amountOut = $t01095411824._1 | |
267 | + | let burnOrIssue = $t01095411824._2 | |
268 | + | let transferSynthOrBasic = $t01095411824._3 | |
269 | + | let ucollateralEntry = $t01095411824._4 | |
270 | + | if ((0 > (currAssetLockedTotal - accountLockedAmt))) | |
271 | + | then throw((("Invalid data state: " + keyAssetLockedTotal) + " less then 0")) | |
272 | + | else ((([IntegerEntry(keyAssetLockedTotal, (currAssetLockedTotal - accountLockedAmt)), DeleteEntry(accOperationKey), StringEntry(keyAccountOperation(unlockHeight, accountAddress, "FINISHED"), dataAccountOperation(amountIn, assetIn, synth2basicPrice, amountOut, assetOut))] :+ burnOrIssue) :+ transferSynthOrBasic) :+ ucollateralEntry) | |
273 | + | } | |
274 | + | } | |
275 | + | } | |
276 | + | } | |
277 | + | ||
278 | + | ||
279 | + | @Verifier(tx) | |
280 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
281 | + |
github/deemru/w8io/026f985 22.88 ms ◑