tx · 9vnSnznJu69UUXtsX2NnvoyBFyoFBCVV8ctQMf9STgLm

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01300000 Waves

2023.02.10 17:33 [2443665] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "9vnSnznJu69UUXtsX2NnvoyBFyoFBCVV8ctQMf9STgLm", "fee": 1300000, "feeAssetId": null, "timestamp": 1676039687759, "version": 2, "chainId": 84, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "Kg2hPojW4mNbJc5GkLdosUoeG9rZRNSVpJG2g2uuhtM39BXgGEhvQvTnNvGWeMCnNQwQ6KhYVT16xw97VauV88p" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAWAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAIDC1y8BD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5AAxwb29sRGlzYWJsZWQJAAIBAg1Qb29sIGRpc2FibGVkAAxwb29sTm90RXhpc3QJAAIBAhFQb29sIGlzIG5vdCBleGlzdAAOc2xpcHBhZ2VUb29CaWcJAAIBAhNTbGlwcGFnZSBpcyB0b28gYmlnARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5AQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJA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c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BaQEOY29uZmlybU1hbmFnZXIABAJwbQkBHXBlbmRpbmdNYW5hZ2VyUHVibGljS2V5T3JVbml0AAQFaGFzUE0DCQEJaXNEZWZpbmVkAQUCcG0GCQACAQISbm8gcGVuZGluZyBtYW5hZ2VyAwkAAAIFBWhhc1BNBQVoYXNQTQQHY2hlY2tQTQMJAAACCAUBaQ9jYWxsZXJQdWJsaWNLZXkJAQV2YWx1ZQEFAnBtBgkAAgECG3lvdSBhcmUgbm90IHBlbmRpbmcgbWFuYWdlcgMJAAACBQdjaGVja1BNBQdjaGVja1BNCQDMCAIJAQtTdHJpbmdFbnRyeQIJARNrZXlNYW5hZ2VyUHVibGljS2V5AAkA2AQBCQEFdmFsdWUBBQJwbQkAzAgCCQELRGVsZXRlRW50cnkBCQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkABQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABA90YXJnZXRQdWJsaWNLZXkEByRtYXRjaDAJARZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJwawUHJG1hdGNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXkVdnZn", "height": 2443665, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 45dDeyhUhVVjpKMDBZyhGQMTpoidFAMpjSfunZ7dDsWz Next: HneYaxY5kQ5AcxHTqRmfH1avhNSsPk7m2sr4Hn7GFYiW Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
6-let feeScale = toBigInt(100000)
6+let feeScale = toBigInt(100000000)
77
88 func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key))
99
2525
2626 let factoryContract = addressFromStringValue(getStringOrFail(fc()))
2727
28-func feeProtocolContractAddress () = makeString(["%s", "feeProtocolContractAddress"], SEP)
29-
30-
31-let feeContract = addressFromStringValue(getStringOrFail(feeProtocolContractAddress()))
32-
3328 func protocolFee () = makeString(["%s", "protocolFee"], SEP)
3429
3530
3631 func poolFee () = makeString(["%s", "poolFee"], SEP)
3732
33+
34+func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
35+
36+
37+let keyFeeCollectorAddress = "%s__feeCollectorAddress"
38+
39+let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress))
3840
3941 func asInt (val) = match val {
4042 case valInt: Int =>
102104 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmountCalc)
103105 let lpNonReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
104106 let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
105- let $t029343437 = if ((lpNonReverse != unit))
107+ let $t031263629 = if ((lpNonReverse != unit))
106108 then {
107109 let isReverse = false
108110 let pool = {
125127 $Tuple2(isReverse, pool)
126128 }
127129 else poolNotExist
128- let isReverse = $t029343437._1
129- let pool = $t029343437._2
130+ let isReverse = $t031263629._1
131+ let pool = $t031263629._2
130132 let poolStatus = {
131133 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
132134 if ($isInstanceOf(@, "Int"))
187189 then @
188190 else unit
189191 }
190- let $t050735592 = if ((lpNonReverse != unit))
192+ let $t052655784 = if ((lpNonReverse != unit))
191193 then {
192194 let isReverse = false
193195 let pool = {
210212 $Tuple2(isReverse, pool)
211213 }
212214 else poolNotExist
213- let isReverse = $t050735592._1
214- let pool = $t050735592._2
215+ let isReverse = $t052655784._1
216+ let pool = $t052655784._2
215217 let poolStatus = {
216218 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
217219 if ($isInstanceOf(@, "Int"))
230232 then @
231233 else throw(($getType(@) + " couldn't be cast to Int"))
232234 }
233- $Tuple2([ScriptTransfer(feeContract, toInt(feeProtocolAmount), assetIn), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetIn)], totalGetRaw)
235+ $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetIn), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetIn)], totalGetRaw)
234236 }
235237 else throw("Strict value is not equal to itself.")
236238 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
6-let feeScale = toBigInt(100000)
6+let feeScale = toBigInt(100000000)
77
88 func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key))
99
1010
1111 let poolDisabled = throw("Pool disabled")
1212
1313 let poolNotExist = throw("Pool is not exist")
1414
1515 let slippageTooBig = throw("Slippage is too big")
1616
1717 func keyManagerPublicKey () = "%s__managerPublicKey"
1818
1919
2020 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
2121
2222
2323 func fc () = "%s__factoryContract"
2424
2525
2626 let factoryContract = addressFromStringValue(getStringOrFail(fc()))
2727
28-func feeProtocolContractAddress () = makeString(["%s", "feeProtocolContractAddress"], SEP)
29-
30-
31-let feeContract = addressFromStringValue(getStringOrFail(feeProtocolContractAddress()))
32-
3328 func protocolFee () = makeString(["%s", "protocolFee"], SEP)
3429
3530
3631 func poolFee () = makeString(["%s", "poolFee"], SEP)
3732
33+
34+func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
35+
36+
37+let keyFeeCollectorAddress = "%s__feeCollectorAddress"
38+
39+let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress))
3840
3941 func asInt (val) = match val {
4042 case valInt: Int =>
4143 valInt
4244 case _ =>
4345 throw("fail to cast into Int")
4446 }
4547
4648
4749 func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP)
4850
4951
5052 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
5153 case s: String =>
5254 fromBase58String(s)
5355 case _: Unit =>
5456 unit
5557 case _ =>
5658 throw("Match error")
5759 }
5860
5961
6062 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
6163 case s: String =>
6264 fromBase58String(s)
6365 case _: Unit =>
6466 unit
6567 case _ =>
6668 throw("Match error")
6769 }
6870
6971
7072 func isManager (i) = match managerPublicKeyOrUnit() {
7173 case pk: ByteVector =>
7274 (i.callerPublicKey == pk)
7375 case _: Unit =>
7476 (i.caller == this)
7577 case _ =>
7678 throw("Match error")
7779 }
7880
7981
8082 func mustManager (i) = if (isManager(i))
8183 then true
8284 else throw("permission denied")
8385
8486
8587 func getAccBalance (assetId) = if ((assetId == "WAVES"))
8688 then wavesBalance(this).available
8789 else assetBalance(this, fromBase58String(assetId))
8890
8991
9092 @Callable(i)
9193 func swapCalculateREADONLY (amountIn,assetIn,assetOut) = {
9294 let prFee = value(getInteger(protocolFee()))
9395 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
9496 let plFee = value(getInteger(poolFee()))
9597 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
9698 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
9799 then toBigInt(1)
98100 else feeProtocolAmountCalc
99101 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
100102 then toBigInt(1)
101103 else feePoolAmountCalc
102104 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmountCalc)
103105 let lpNonReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil)
104106 let lpReverse = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil)
105- let $t029343437 = if ((lpNonReverse != unit))
107+ let $t031263629 = if ((lpNonReverse != unit))
106108 then {
107109 let isReverse = false
108110 let pool = {
109111 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpNonReverse], nil)
110112 if ($isInstanceOf(@, "String"))
111113 then @
112114 else throw(($getType(@) + " couldn't be cast to String"))
113115 }
114116 $Tuple2(isReverse, pool)
115117 }
116118 else if ((lpReverse != unit))
117119 then {
118120 let isReverse = true
119121 let pool = {
120122 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [lpReverse], nil)
121123 if ($isInstanceOf(@, "String"))
122124 then @
123125 else throw(($getType(@) + " couldn't be cast to String"))
124126 }
125127 $Tuple2(isReverse, pool)
126128 }
127129 else poolNotExist
128- let isReverse = $t029343437._1
129- let pool = $t029343437._2
130+ let isReverse = $t031263629._1
131+ let pool = $t031263629._2
130132 let poolStatus = {
131133 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
132134 if ($isInstanceOf(@, "Int"))
133135 then @
134136 else throw(($getType(@) + " couldn't be cast to Int"))
135137 }
136138 let check = if ((poolStatus == 1))
137139 then true
138140 else poolDisabled
139141 if ((check == check))
140142 then {
141143 let poolAdr = addressFromStringValue(valueOrElse(pool, ""))
142144 let res = {
143145 let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse], nil)
144146 if ($isInstanceOf(@, "Int"))
145147 then @
146148 else throw(($getType(@) + " couldn't be cast to Int"))
147149 }
148150 $Tuple2(nil, res)
149151 }
150152 else throw("Strict value is not equal to itself.")
151153 }
152154
153155
154156
155157 @Callable(i)
156158 func swap (amountOutMin,assetOut,addressTo) = {
157159 let pmt = value(i.payments[0])
158160 let assetIn = if ((pmt.assetId == unit))
159161 then toBytes("WAVES")
160162 else value(pmt.assetId)
161163 let amountIn = value(pmt.amount)
162164 let prFee = value(getInteger(protocolFee()))
163165 let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale)
164166 let plFee = value(getInteger(poolFee()))
165167 let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale)
166168 let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0))
167169 then toBigInt(1)
168170 else feeProtocolAmountCalc
169171 let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0))
170172 then toBigInt(1)
171173 else feePoolAmountCalc
172174 let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmountCalc)
173175 let checks = [if ((size(i.payments) == 1))
174176 then true
175177 else throw("exactly 1 payment are expected")]
176178 if ((checks == checks))
177179 then {
178180 let lpNonReverse = {
179181 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [toBase58String(assetIn), assetOut], nil)
180182 if ($isInstanceOf(@, "String"))
181183 then @
182184 else unit
183185 }
184186 let lpReverse = {
185187 let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, toBase58String(assetIn)], nil)
186188 if ($isInstanceOf(@, "String"))
187189 then @
188190 else unit
189191 }
190- let $t050735592 = if ((lpNonReverse != unit))
192+ let $t052655784 = if ((lpNonReverse != unit))
191193 then {
192194 let isReverse = false
193195 let pool = {
194196 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil)
195197 if ($isInstanceOf(@, "String"))
196198 then @
197199 else throw(($getType(@) + " couldn't be cast to String"))
198200 }
199201 $Tuple2(isReverse, pool)
200202 }
201203 else if ((lpReverse != unit))
202204 then {
203205 let isReverse = true
204206 let pool = {
205207 let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil)
206208 if ($isInstanceOf(@, "String"))
207209 then @
208210 else throw(($getType(@) + " couldn't be cast to String"))
209211 }
210212 $Tuple2(isReverse, pool)
211213 }
212214 else poolNotExist
213- let isReverse = $t050735592._1
214- let pool = $t050735592._2
215+ let isReverse = $t052655784._1
216+ let pool = $t052655784._2
215217 let poolStatus = {
216218 let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil)
217219 if ($isInstanceOf(@, "Int"))
218220 then @
219221 else throw(($getType(@) + " couldn't be cast to Int"))
220222 }
221223 let check = if ((poolStatus == 1))
222224 then true
223225 else poolDisabled
224226 if ((check == check))
225227 then {
226228 let poolAdr = addressFromStringValue(pool)
227229 let totalGetRaw = {
228230 let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo], [AttachedPayment(assetIn, toInt(cleanAmountIn))])
229231 if ($isInstanceOf(@, "Int"))
230232 then @
231233 else throw(($getType(@) + " couldn't be cast to Int"))
232234 }
233- $Tuple2([ScriptTransfer(feeContract, toInt(feeProtocolAmount), assetIn), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetIn)], totalGetRaw)
235+ $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetIn), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetIn)], totalGetRaw)
234236 }
235237 else throw("Strict value is not equal to itself.")
236238 }
237239 else throw("Strict value is not equal to itself.")
238240 }
239241
240242
241243
242244 @Callable(i)
243245 func setManager (pendingManagerPublicKey) = {
244246 let checkCaller = mustManager(i)
245247 if ((checkCaller == checkCaller))
246248 then {
247249 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
248250 if ((checkManagerPublicKey == checkManagerPublicKey))
249251 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
250252 else throw("Strict value is not equal to itself.")
251253 }
252254 else throw("Strict value is not equal to itself.")
253255 }
254256
255257
256258
257259 @Callable(i)
258260 func confirmManager () = {
259261 let pm = pendingManagerPublicKeyOrUnit()
260262 let hasPM = if (isDefined(pm))
261263 then true
262264 else throw("no pending manager")
263265 if ((hasPM == hasPM))
264266 then {
265267 let checkPM = if ((i.callerPublicKey == value(pm)))
266268 then true
267269 else throw("you are not pending manager")
268270 if ((checkPM == checkPM))
269271 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
270272 else throw("Strict value is not equal to itself.")
271273 }
272274 else throw("Strict value is not equal to itself.")
273275 }
274276
275277
276278 @Verifier(tx)
277279 func verify () = {
278280 let targetPublicKey = match managerPublicKeyOrUnit() {
279281 case pk: ByteVector =>
280282 pk
281283 case _: Unit =>
282284 tx.senderPublicKey
283285 case _ =>
284286 throw("Match error")
285287 }
286288 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
287289 }
288290

github/deemru/w8io/026f985 
44.70 ms