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:BgIOCAISAwoBCBIAEgMKAQgkAANTRVACAl9fAAZzY2FsZTgAgMLXLwARcG9vbFN0YXRzUHJpY2VLZXkABAAOaWR4UG9vbEFkZHJlc3MAAQANaWR4UG9vbFN0YXR1cwACABBpZHhQb29sTFBBc3NldElkAAMADWlkeEFtdEFzc2V0SWQABAAPaWR4UHJpY2VBc3NldElkAAUADmlkeEFtdEFzc2V0RGNtAAYAEGlkeFByaWNlQXNzZXREY20ABwAOaWR4SUFtdEFzc2V0SWQACAAQaWR4SVByaWNlQXNzZXRJZAAJAA1pZHhMUEFzc2V0RGNtAAoAE2lkeE1hdGNoZXJQdWJsaWNLZXkACwEOa2V5UmVnaXN0ZXJQdXQCC3Bvb2xBZGRyZXNzBHR4SWQJAKwCAgkArAICCQCsAgICCyVzJXMlc19fUF9fBQtwb29sQWRkcmVzcwICX18FBHR4SWQBEWtleVJlZ2lzdGVySW52ZXN0Agtwb29sQWRkcmVzcwR0eElkCQCsAgIJAKwCAgkArAICAhAlcyVzJXNfX2ludmVzdF9fBQtwb29sQWRkcmVzcwICX18FBHR4SWQBFmtleVBvb2xUb3RhbEFtdE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UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5NKEDhA==", "height": 2562879, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9aUmmBXs2nRT5sMFxuD9rbFJjMmnhrnWUHt8gnQbGKtc Next: none Diff:
OldNewDifferences
6565 func keyManagerPublicKey () = "%s__managerPublicKey"
6666
6767
68-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
68+func keyManagerVaultAddress () = "%s__managerVaultAddress"
6969
7070
7171 let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Acc found."))
9292 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
9393
9494
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()))
10396
10497
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+ }
113109
114110
115111 func mustManager (i) = {
173169 let IdxEstPrAmount = 8
174170 let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount")
175171 let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount")
176- let $t066436744 = if ((amBalance >= estAmAmt))
172+ let $t066646765 = if ((amBalance >= estAmAmt))
177173 then $Tuple2(estAmAmt, prBalance)
178174 else $Tuple2(amBalance, estPrAmt)
179- let amAmt = $t066436744._1
180- let prAmt = $t066436744._2
175+ let amAmt = $t066646765._1
176+ let prAmt = $t066646765._2
181177 let amAssetId = if ((amId == "WAVES"))
182178 then unit
183179 else fromBase58String(amId)
187183 let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)])
188184 if ((lpPut == lpPut))
189185 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- }
225186 else throw("Strict value is not equal to itself.")
226187 }
227188
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let scale8 = 100000000
77
88 let poolStatsPriceKey = 4
99
1010 let idxPoolAddress = 1
1111
1212 let idxPoolStatus = 2
1313
1414 let idxPoolLPAssetId = 3
1515
1616 let idxAmtAssetId = 4
1717
1818 let idxPriceAssetId = 5
1919
2020 let idxAmtAssetDcm = 6
2121
2222 let idxPriceAssetDcm = 7
2323
2424 let idxIAmtAssetId = 8
2525
2626 let idxIPriceAssetId = 9
2727
2828 let idxLPAssetDcm = 10
2929
3030 let idxMatcherPublicKey = 11
3131
3232 func keyRegisterPut (poolAddress,txId) = ((("%s%s%s__P__" + poolAddress) + "__") + txId)
3333
3434
3535 func keyRegisterInvest (poolAddress,txId) = ((("%s%s%s__invest__" + poolAddress) + "__") + txId)
3636
3737
3838 func keyPoolTotalAmtByAsset (poolAddress,assetId) = ((("%s%s%s__total__" + poolAddress) + "__") + assetId)
3939
4040
4141 func keyFactoryContract () = "%s__factoryContract"
4242
4343
4444 func keySlippageAmtPerAssetCumulative (poolAddress,assetId) = (((("%s%s%s__" + poolAddress) + "__") + assetId) + "__slippageCumulative")
4545
4646
4747 func keyFactoryConfig () = "%s__factoryConfig"
4848
4949
5050 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2PoolAssets")
5151
5252
5353 func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset))
5454
5555
5656 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
5757
5858
5959 func keyAllPoolsShutdown () = "%s__shutdown"
6060
6161
6262 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
6363
6464
6565 func keyManagerPublicKey () = "%s__managerPublicKey"
6666
6767
68-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
68+func keyManagerVaultAddress () = "%s__managerVaultAddress"
6969
7070
7171 let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Acc found."))
7272
7373 func convertAssetId (assetId) = if (!(isDefined(assetId)))
7474 then "WAVES"
7575 else assetId
7676
7777
7878 func dataPutActionInfo (inAssetId,inAssetAmt,txHeight,txTimestamp) = makeString(["%s%d%d%d", inAssetId, toString(inAssetAmt), toString(txHeight), toString(txTimestamp)], SEP)
7979
8080
8181 func dataInvestActionInfo (outAmountAssetAmt,outPriceAssetAmt,txHeight,txTimestamp) = makeString(["%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(txHeight), toString(txTimestamp)], SEP)
8282
8383
8484 func asString (val) = match val {
8585 case valStr: String =>
8686 valStr
8787 case _ =>
8888 throw("fail to cast into String")
8989 }
9090
9191
9292 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
9393
9494
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()))
10396
10497
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+ }
113109
114110
115111 func mustManager (i) = {
116112 let pd = throw("Permission denied")
117113 match managerPublicKeyOrUnit() {
118114 case pk: ByteVector =>
119115 if ((i.callerPublicKey == pk))
120116 then true
121117 else pd
122118 case _: Unit =>
123119 if ((i.caller == this))
124120 then true
125121 else pd
126122 case _ =>
127123 throw("Match error")
128124 }
129125 }
130126
131127
132128 @Callable(i)
133129 func constructor (factoryContract) = {
134130 let checkCaller = mustManager(i)
135131 if ((checkCaller == checkCaller))
136132 then [StringEntry(keyFactoryContract(), factoryContract)]
137133 else throw("Strict value is not equal to itself.")
138134 }
139135
140136
141137
142138 @Callable(i)
143139 func put () = {
144140 let pool = toString(i.caller)
145141 let pmtAmtAsset = value(i.payments[0])
146142 let pmtAssetId = if (!(isDefined(pmtAmtAsset.assetId)))
147143 then "WAVES"
148144 else toBase58String(value(pmtAmtAsset.assetId))
149145 let pmtAssetAmt = pmtAmtAsset.amount
150146 let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(pool)), "Invalid caller"), SEP)
151147 let amountAssetId = parseIntValue(poolAssets[1])
152148 let priceAssetId = parseIntValue(poolAssets[2])
153149 let amountAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(amountAssetId)), "Cannot find asset")
154150 let priceAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(priceAssetId)), "Cannot find asset")
155151 let totalAmt = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(pool, pmtAssetId)), 0)
156152 let cumulativeSlippageAmt = valueOrElse(getInteger(this, keySlippageAmtPerAssetCumulative(pool, pmtAssetId)), 0)
157153 [StringEntry(keyRegisterPut(pool, toBase58String(i.transactionId)), dataPutActionInfo(pmtAssetId, pmtAssetAmt, height, lastBlock.timestamp)), IntegerEntry(keyPoolTotalAmtByAsset(pool, pmtAssetId), (totalAmt + pmtAssetAmt)), IntegerEntry(keySlippageAmtPerAssetCumulative(pool, pmtAssetId), (cumulativeSlippageAmt + pmtAssetAmt))]
158154 }
159155
160156
161157
162158 @Callable(i)
163159 func invest (poolAddressStr) = {
164160 let poolAddress = valueOrErrorMessage(addressFromString(poolAddressStr), "invalid pool address")
165161 let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddressStr)), "Invalid pool passed."), SEP)
166162 let amId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found")
167163 let prId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found")
168164 let amBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, amId)), 0)
169165 let prBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, prId)), 0)
170166 let estByPrResult = invoke(poolAddress, "evaluatePutByPriceAssetREADONLY", [prBalance], nil)
171167 let estByAmResult = invoke(poolAddress, "evaluatePutByAmountAssetREADONLY", [amBalance], nil)
172168 let IdxEstAmAmount = 7
173169 let IdxEstPrAmount = 8
174170 let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount")
175171 let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount")
176- let $t066436744 = if ((amBalance >= estAmAmt))
172+ let $t066646765 = if ((amBalance >= estAmAmt))
177173 then $Tuple2(estAmAmt, prBalance)
178174 else $Tuple2(amBalance, estPrAmt)
179- let amAmt = $t066436744._1
180- let prAmt = $t066436744._2
175+ let amAmt = $t066646765._1
176+ let prAmt = $t066646765._2
181177 let amAssetId = if ((amId == "WAVES"))
182178 then unit
183179 else fromBase58String(amId)
184180 let prAssetId = if ((prId == "WAVES"))
185181 then unit
186182 else fromBase58String(prId)
187183 let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)])
188184 if ((lpPut == lpPut))
189185 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- }
225186 else throw("Strict value is not equal to itself.")
226187 }
227188
228189
229190 @Verifier(tx)
230191 func verify () = {
231192 let targetPublicKey = match managerPublicKeyOrUnit() {
232193 case pk: ByteVector =>
233194 pk
234195 case _: Unit =>
235196 tx.senderPublicKey
236197 case _ =>
237198 throw("Match error")
238199 }
239200 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
240201 }
241202

github/deemru/w8io/026f985 
31.39 ms