tx · 8FBo93fXARxRaEYLjaAoAqenXTR38bRWxmTbyb4zAoNV

3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9:  -0.01400000 Waves

2021.08.18 16:17 [1663827] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves

{ "type": 13, "id": "8FBo93fXARxRaEYLjaAoAqenXTR38bRWxmTbyb4zAoNV", "fee": 1400000, "feeAssetId": null, "timestamp": 1629292681470, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "vJwmQvFWaYxrCbQRWwHzquYxtrZ2iGy86rDucsL7g2HmRA4dR9TGYYz9B7cUiRa8ZWGSvTAUvPG3qf6vYmaWLoV", "5is7raXugGLYNPKAynsS757qazakjN5iwLBEFDJm1SBnsnQcySg8aydTkjhwYmmUfjMtQrbkqVLdvXg2UW8WT7mu" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgQKAggIEgQKAggIAAAAEwAAAAAQa2V5UG9vbHNMaXN0TmFtZQIAAAAFcG9vbHMAAAAAEWtleVByZWZpeFBvb2xOYW1lAgAAAAVwb29sXwAAAAASa2V5UHJlZml4UG9vbEluZGV4AgAAAAZpbmRleF8AAAAAEWtleUluaXRQb29sSGVpZ2h0AgAAABFpbml0X3Bvb2xfaGVpZ2h0XwAAAAASa2V5Q29uZmlybWVkQXNzZXRzAgAAABBjb25maXJtZWRfYXNzZXRzAAAAABBrZXlBc3NldFByaW9yaXR5AgAAAA9hc3NldF9wcmlvcml0eV8AAAAAB2tleVBhaXICAAAABXBhaXJfAAAAAAtrZXlBc3NldElkQQIAAAAKQV9hc3NldF9pZAAAAAALa2V5QXNzZXRJZEICAAAACkJfYXNzZXRfaWQAAAAAD2tleUFkbWluUHViS2V5MQIAAAALYWRtaW5fcHViXzEAAAAAD2tleUFkbWluUHVi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FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAWQ3JlYXRlQWxpYXNUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFkxlYXNlQ2FuY2VsVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABBMZWFzZVRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAQSXNzdWVUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAGlVwZGF0ZUFzc2V0SW5mb1RyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABlTZXRBc3NldFNjcmlwdFRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE0V4Y2hhbmdlVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdNYXNzVHJhbnNmZXJUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0J1cm5UcmFuc2FjdGlvbgYJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAASUmVpc3N1ZVRyYW5zYWN0aW9uBQAAAA1zaWduZWRCeUFkbWluCQAAAgAAAAECAAAAC01hdGNoIGVycm9yIVwaLw==", "height": 1663827, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CmW44eM4AhggAhNWfxXpXA1YBNrXb8FFjyiCWVWmj2fF Next: FFpUMsAPjD53ymn7sGi6uq928a2nwfuGLDzEuW85xiE2 Diff:
OldNewDifferences
66 let keyPrefixPoolName = "pool_"
77
88 let keyPrefixPoolIndex = "index_"
9+
10+let keyInitPoolHeight = "init_pool_height_"
911
1012 let keyConfirmedAssets = "confirmed_assets"
1113
1618 let keyAssetIdA = "A_asset_id"
1719
1820 let keyAssetIdB = "B_asset_id"
19-
20-let keyOracleScriptHashCPMM = "script_hash_cpmm"
21-
22-let keyOracleScriptHashFlat = "script_hash_flat"
23-
24-let cpmmScriptReferenesAddress = base58'3N77kfPbQyjXWpDALX3xjKw3iEGMWEctV37'
25-
26-let flatScriptReferenesAddress = base58'3N5Xd7QVQZWntaJwha9Kg42is626GUPjtUW'
2721
2822 let keyAdminPubKey1 = "admin_pub_1"
2923
3731
3832 let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP'
3933
40-let adminStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
41-
42-let adminStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
43-
4434 let pools = match getString(this, keyPoolsListName) {
4535 case string: String =>
4636 split(string, ",")
5040
5141 func isSelfCall (i) = if ((i.caller == this))
5242 then unit
53- else unit
43+ else throw("Only the Oracle itself can invoke this function")
5444
5545
5646 func getPoolNameIfValid (poolName) = {
7161
7262
7363 @Callable(i)
74-func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority))
75- then throw("Priority must be positive")
76- else [IntegerEntry((keyAssetPriority + assetId), priority)])
77-
78-
79-
80-@Callable(i)
8164 func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(keyAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(keyAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(keyAdminPubKey3, toBase58String(adminPubKey3))])
8265
8366
8972 let keyIndex = (keyPrefixPoolIndex + validatedAddress)
9073 let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect")
9174 let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect")
92- let check = isDataStorageUntouched(this)
93- let userScriptHash = value(scriptHash(i.caller))
94- let cpmmHash = getBinaryValue(keyOracleScriptHashCPMM)
95- let flatHash = getBinaryValue(keyOracleScriptHashFlat)
96- let isNotCpmm = if ((userScriptHash != cpmmHash))
97- then true
98- else false
99- let isNotFlat = if ((userScriptHash != flatHash))
100- then true
101- else false
102- let isNotEmptyData = if ((!(check) == true))
103- then true
104- else false
105- let isEmptyData = if ((!(check) == false))
106- then true
107- else false
108- let isNotEmpty = if ((check == false))
109- then true
110- else false
111- let isEmpty = if ((check == true))
112- then true
113- else false
114- let isNotPoolContract = if (if (isNotCpmm)
115- then isNotFlat
116- else false)
117- then true
118- else false
119- if (if (isNotPoolContract)
120- then true
121- else if (if (if (isNotEmptyData)
122- then !(isEmptyData)
123- else false)
124- then isNotEmpty
125- else false)
126- then !(isEmpty)
127- else false)
128- then throw("Unexpected script was found.")
129- else {
130- let possiblyAlreadyAddedPool = getString(this, keyName)
131- let possibleDuplicateA = getString(this, (((keyPair + assetIdA) + "_") + assetIdB))
132- let possibleDuplicateB = getString(this, (((keyPair + assetIdB) + "_") + assetIdA))
133- if (isDefined(possiblyAlreadyAddedPool))
134- then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
135- else if (if (isDefined(possibleDuplicateA))
136- then true
137- else isDefined(possibleDuplicateB))
138- then throw((((("Pool with assets \"" + assetIdA) + "\" and \"") + assetIdB) + "\" is already exists"))
139- else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
140- }
75+ let possiblyAlreadyAddedPool = getString(this, keyName)
76+ if (isDefined(possiblyAlreadyAddedPool))
77+ then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
78+ else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
14179 })
14280
14381
15189 then [StringEntry(keyName, getPoolNameIfValid(newPoolName))]
15290 else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added"))
15391 })
154-
155-
156-
157-@Callable(i)
158-func updateHashes () = valueOrElse(isSelfCall(i), [BinaryEntry(keyOracleScriptHashCPMM, value(scriptHash(Address(cpmmScriptReferenesAddress)))), BinaryEntry(keyOracleScriptHashFlat, value(scriptHash(Address(flatScriptReferenesAddress))))])
15992
16093
16194 @Verifier(tx)
179112 let isSelfInvokeSetAdmin = if ((inv.dApp == this))
180113 then containsElement(["setAdmin"], inv.function)
181114 else false
182- let isInvokeAddPool = containsElement(["addPool"], inv.function)
183- let isSelfInvokeUpdateHashes = if ((inv.dApp == this))
184- then containsElement(["updateHashes"], inv.function)
115+ let isSelfInvokeAddPool = if ((inv.dApp == this))
116+ then containsElement(["addPool"], inv.function)
185117 else false
186- if (if (if (if (if (signedByAdmin)
118+ if (if (if (if (signedByAdmin)
187119 then (size(inv.payments) == 0)
188120 else false)
189121 then isSelfInvokeRenamePool
190122 else false)
191123 then true
192- else if ((size(inv.payments) == 0))
193- then isInvokeAddPool
124+ else if (if (signedByAdminToCallAddPool)
125+ then (size(inv.payments) == 0)
126+ else false)
127+ then isSelfInvokeAddPool
194128 else false)
195129 then true
196130 else if (if (signedByAdmin)
197131 then (size(inv.payments) == 0)
198132 else false)
199133 then isSelfInvokeSetAdmin
200- else false)
201- then true
202- else if (if (signedByAdmin)
203- then (size(inv.payments) == 0)
204- else false)
205- then isSelfInvokeUpdateHashes
206134 else false
207135 case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
208136 signedByAdmin
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let keyPoolsListName = "pools"
55
66 let keyPrefixPoolName = "pool_"
77
88 let keyPrefixPoolIndex = "index_"
9+
10+let keyInitPoolHeight = "init_pool_height_"
911
1012 let keyConfirmedAssets = "confirmed_assets"
1113
1214 let keyAssetPriority = "asset_priority_"
1315
1416 let keyPair = "pair_"
1517
1618 let keyAssetIdA = "A_asset_id"
1719
1820 let keyAssetIdB = "B_asset_id"
19-
20-let keyOracleScriptHashCPMM = "script_hash_cpmm"
21-
22-let keyOracleScriptHashFlat = "script_hash_flat"
23-
24-let cpmmScriptReferenesAddress = base58'3N77kfPbQyjXWpDALX3xjKw3iEGMWEctV37'
25-
26-let flatScriptReferenesAddress = base58'3N5Xd7QVQZWntaJwha9Kg42is626GUPjtUW'
2721
2822 let keyAdminPubKey1 = "admin_pub_1"
2923
3024 let keyAdminPubKey2 = "admin_pub_2"
3125
3226 let keyAdminPubKey3 = "admin_pub_3"
3327
3428 let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy'
3529
3630 let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk'
3731
3832 let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP'
3933
40-let adminStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
41-
42-let adminStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
43-
4434 let pools = match getString(this, keyPoolsListName) {
4535 case string: String =>
4636 split(string, ",")
4737 case nothing =>
4838 nil
4939 }
5040
5141 func isSelfCall (i) = if ((i.caller == this))
5242 then unit
53- else unit
43+ else throw("Only the Oracle itself can invoke this function")
5444
5545
5646 func getPoolNameIfValid (poolName) = {
5747 let underscoreIndex = valueOrElse(indexOf(poolName, "_"), -1)
5848 let underscoreLastIndex = valueOrElse(lastIndexOf(poolName, "_"), -1)
5949 let hasSingleUnderscore = if (if ((underscoreIndex == underscoreLastIndex))
6050 then (underscoreIndex > 0)
6151 else false)
6252 then (underscoreIndex != (size(poolName) - 1))
6353 else false
6454 if (hasSingleUnderscore)
6555 then poolName
6656 else throw("Pool name must consist of two asset names separated by an underscore character")
6757 }
6858
6959
7060 func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address")))
7161
7262
7363 @Callable(i)
74-func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority))
75- then throw("Priority must be positive")
76- else [IntegerEntry((keyAssetPriority + assetId), priority)])
77-
78-
79-
80-@Callable(i)
8164 func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(keyAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(keyAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(keyAdminPubKey3, toBase58String(adminPubKey3))])
8265
8366
8467
8568 @Callable(i)
8669 func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), {
8770 let validatedAddress = getAddressIfValid(poolAddress)
8871 let keyName = (keyPrefixPoolName + validatedAddress)
8972 let keyIndex = (keyPrefixPoolIndex + validatedAddress)
9073 let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect")
9174 let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect")
92- let check = isDataStorageUntouched(this)
93- let userScriptHash = value(scriptHash(i.caller))
94- let cpmmHash = getBinaryValue(keyOracleScriptHashCPMM)
95- let flatHash = getBinaryValue(keyOracleScriptHashFlat)
96- let isNotCpmm = if ((userScriptHash != cpmmHash))
97- then true
98- else false
99- let isNotFlat = if ((userScriptHash != flatHash))
100- then true
101- else false
102- let isNotEmptyData = if ((!(check) == true))
103- then true
104- else false
105- let isEmptyData = if ((!(check) == false))
106- then true
107- else false
108- let isNotEmpty = if ((check == false))
109- then true
110- else false
111- let isEmpty = if ((check == true))
112- then true
113- else false
114- let isNotPoolContract = if (if (isNotCpmm)
115- then isNotFlat
116- else false)
117- then true
118- else false
119- if (if (isNotPoolContract)
120- then true
121- else if (if (if (isNotEmptyData)
122- then !(isEmptyData)
123- else false)
124- then isNotEmpty
125- else false)
126- then !(isEmpty)
127- else false)
128- then throw("Unexpected script was found.")
129- else {
130- let possiblyAlreadyAddedPool = getString(this, keyName)
131- let possibleDuplicateA = getString(this, (((keyPair + assetIdA) + "_") + assetIdB))
132- let possibleDuplicateB = getString(this, (((keyPair + assetIdB) + "_") + assetIdA))
133- if (isDefined(possiblyAlreadyAddedPool))
134- then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
135- else if (if (isDefined(possibleDuplicateA))
136- then true
137- else isDefined(possibleDuplicateB))
138- then throw((((("Pool with assets \"" + assetIdA) + "\" and \"") + assetIdB) + "\" is already exists"))
139- else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
140- }
75+ let possiblyAlreadyAddedPool = getString(this, keyName)
76+ if (isDefined(possiblyAlreadyAddedPool))
77+ then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
78+ else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
14179 })
14280
14381
14482
14583 @Callable(i)
14684 func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), {
14785 let validatedAddress = getAddressIfValid(poolAddress)
14886 let keyName = (keyPrefixPoolName + validatedAddress)
14987 let possiblyAlreadyAddedPool = getString(this, keyName)
15088 if (isDefined(possiblyAlreadyAddedPool))
15189 then [StringEntry(keyName, getPoolNameIfValid(newPoolName))]
15290 else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added"))
15391 })
154-
155-
156-
157-@Callable(i)
158-func updateHashes () = valueOrElse(isSelfCall(i), [BinaryEntry(keyOracleScriptHashCPMM, value(scriptHash(Address(cpmmScriptReferenesAddress)))), BinaryEntry(keyOracleScriptHashFlat, value(scriptHash(Address(flatScriptReferenesAddress))))])
15992
16093
16194 @Verifier(tx)
16295 func verify () = {
16396 let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
16497 then 1
16598 else 0
16699 let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
167100 then 1
168101 else 0
169102 let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
170103 then 1
171104 else 0
172105 let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
173106 let signedByAdminToCallAddPool = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 1)
174107 match tx {
175108 case inv: InvokeScriptTransaction =>
176109 let isSelfInvokeRenamePool = if ((inv.dApp == this))
177110 then containsElement(["renamePool"], inv.function)
178111 else false
179112 let isSelfInvokeSetAdmin = if ((inv.dApp == this))
180113 then containsElement(["setAdmin"], inv.function)
181114 else false
182- let isInvokeAddPool = containsElement(["addPool"], inv.function)
183- let isSelfInvokeUpdateHashes = if ((inv.dApp == this))
184- then containsElement(["updateHashes"], inv.function)
115+ let isSelfInvokeAddPool = if ((inv.dApp == this))
116+ then containsElement(["addPool"], inv.function)
185117 else false
186- if (if (if (if (if (signedByAdmin)
118+ if (if (if (if (signedByAdmin)
187119 then (size(inv.payments) == 0)
188120 else false)
189121 then isSelfInvokeRenamePool
190122 else false)
191123 then true
192- else if ((size(inv.payments) == 0))
193- then isInvokeAddPool
124+ else if (if (signedByAdminToCallAddPool)
125+ then (size(inv.payments) == 0)
126+ else false)
127+ then isSelfInvokeAddPool
194128 else false)
195129 then true
196130 else if (if (signedByAdmin)
197131 then (size(inv.payments) == 0)
198132 else false)
199133 then isSelfInvokeSetAdmin
200- else false)
201- then true
202- else if (if (signedByAdmin)
203- then (size(inv.payments) == 0)
204- else false)
205- then isSelfInvokeUpdateHashes
206134 else false
207135 case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
208136 signedByAdmin
209137 case _ =>
210138 throw("Match error")
211139 }
212140 }
213141

github/deemru/w8io/169f3d6 
43.85 ms