tx · 64zSRVXDZ6oyANU3aCNma2gjBca33pwWwT4a2irxo9sV

3N6gW9pPZr3SAo2nBKpANYM19CZRva5Ygh8:  -0.01400000 Waves

2021.10.22 18:06 [1757665] smart account 3N6gW9pPZr3SAo2nBKpANYM19CZRva5Ygh8 > SELF 0.00000000 Waves

{ "type": 13, "id": "64zSRVXDZ6oyANU3aCNma2gjBca33pwWwT4a2irxo9sV", "fee": 1400000, "feeAssetId": null, "timestamp": 1634915238054, "version": 1, "sender": "3N6gW9pPZr3SAo2nBKpANYM19CZRva5Ygh8", "senderPublicKey": "HLqVgP5nfMJq44e9bWX6pKhhzghEdUHUExBcseZb28jy", "proofs": [ "5zS99yMaMnYpHCZ18A4JuVZew1HL9pDjCkqf2MoLUg7Fz4iDJCM8nwYKbTqiY6c44ENnHqzer9stcKffg8RKSW8L" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgASAwoBCAAAAB8AAAAAA1NFUAIAAAACX18AAAAABnNjYWxlOAAAAAAABfXhAAAAAAARcG9vbFN0YXRzUHJpY2VLZXkAAAAAAAAAAAQAAAAADmlkeFBvb2xBZGRyZXNzAAAAAAAAAAABAAAAAA1pZHhQb29sU3RhdHVzAAAAAAAAAAACAAAAABBpZHhQb29sTFBBc3NldElkAAAAAAAAAAADAAAAAA1pZHhBbXRBc3NldElkAAAAAAAAAAAEAAAAAA9pZHhQcmljZUFzc2V0SWQAAAAAAAAAAAUAAAAADmlkeEFtdEFzc2V0RGNtAAAAAAAAAAAGAAAAABBpZHhQcmljZUFzc2V0RGNtAAAAAAAAAAAHAAAAAA5pZHhJQW10QXNzZXRJZAAAAAAAAAAACAAAAAAQaWR4SVByaWNlQXNzZXRJZAAAAAAAAAAACQAAAAANaWR4TFBBc3NldERjbQAAAAAAAAAACgAAAAATaWR4TWF0Y2hlclB1YmxpY0tleQAAAAAAAAAACwEAAAAOa2V5UmVnaXN0ZXJQdXQAAAACAAAAC3Bvb2xBZGRyZXNzAAAABHR4SWQJAAEsA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AAVhbUFtdAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAFmtleVBvb2xUb3RhbEFtdEJ5QXNzZXQAAAACBQAAAA5wb29sQWRkcmVzc1N0cgUAAAAEcHJJZAkAAGUAAAACBQAAAAlwckJhbGFuY2UFAAAABXByQW10BQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmvrONr", "chainId": 84, "height": 1757665, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GTEonpwdJaU8CCGSqWb5un4B6xgZhQ1smkTBdLNzJMgt Next: none Diff:
OldNewDifferences
114114
115115
116116 @Callable(i)
117-func invest (poolAddress) = {
118- let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddress)), "Invalid pool passed."), SEP)
119- let poolAmountAssetId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found")
120- let poolPriceAssetId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found")
121- let poolConfig = split(valueOrErrorMessage(getString(factoryContract, keyPoolConfig(poolAssets[1], poolAssets[2])), "No factory config found for pool assets."), SEP)
122- let amountAssetDecimals = parseIntValue(poolConfig[idxAmtAssetDcm])
123- let priceAssetDecimals = parseIntValue(poolConfig[idxPriceAssetDcm])
124- let amountAssetBalance = toScale(valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddress, poolAmountAssetId)), 0), scale8, amountAssetDecimals)
125- let priceAssetBalance = toScale(valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddress, poolPriceAssetId)), 0), scale8, priceAssetDecimals)
126- let poolStats = asString(invoke(addressFromStringValue(poolAddress), "statsREADONLY", nil, nil))
127- if ((poolStats == poolStats))
128- then {
129- let currentPrice = parseIntValue(split(poolStats, SEP)[poolStatsPriceKey])
130- let pEqByA = fraction(currentPrice, amountAssetBalance, scale8)
131- let resAssetsToPut = if ((pEqByA > priceAssetBalance))
132- then $Tuple2(fraction(priceAssetBalance, scale8, currentPrice), priceAssetBalance)
133- else $Tuple2(amountAssetBalance, pEqByA)
134- let resultAmountAssetAmt = toScale(resAssetsToPut._1, amountAssetDecimals, scale8)
135- let resultPriceAssetAmt = toScale(resAssetsToPut._2, priceAssetDecimals, scale8)
136- let amtAssetId = if ((poolAmountAssetId == "WAVES"))
137- then unit
138- else fromBase58String(poolAmountAssetId)
139- let priceAssetId = if ((poolPriceAssetId == "WAVES"))
140- then unit
141- else fromBase58String(poolPriceAssetId)
142- let lpPut = invoke(addressFromStringValue(poolAddress), "putForFree", [1000], [AttachedPayment(amtAssetId, resultAmountAssetAmt), AttachedPayment(priceAssetId, resultPriceAssetAmt)])
143- if ((lpPut == lpPut))
144- then [StringEntry(keyRegisterInvest(poolAddress, toBase58String(i.transactionId)), dataInvestActionInfo(resultAmountAssetAmt, resultPriceAssetAmt, height, lastBlock.timestamp))]
145- else throw("Strict value is not equal to itself.")
146- }
117+func invest (poolAddressStr) = {
118+ let poolAddress = valueOrErrorMessage(addressFromString(poolAddressStr), "invalid pool address")
119+ let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddressStr)), "Invalid pool passed."), SEP)
120+ let amId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found")
121+ let prId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found")
122+ let amBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, amId)), 0)
123+ let prBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, prId)), 0)
124+ let estByPrResult = invoke(poolAddress, "evaluatePutByPriceAssetREADONLY", [prBalance], nil)
125+ let estByAmResult = invoke(poolAddress, "evaluatePutByAmountAssetREADONLY", [amBalance], nil)
126+ let IdxEstAmAmount = 7
127+ let IdxEstPrAmount = 8
128+ let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount")
129+ let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount")
130+ let $t060346135 = if ((amBalance >= estAmAmt))
131+ then $Tuple2(estAmAmt, prBalance)
132+ else $Tuple2(amBalance, estPrAmt)
133+ let amAmt = $t060346135._1
134+ let prAmt = $t060346135._2
135+ let amAssetId = if ((amId == "WAVES"))
136+ then unit
137+ else fromBase58String(amId)
138+ let prAssetId = if ((prId == "WAVES"))
139+ then unit
140+ else fromBase58String(prId)
141+ let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)])
142+ if ((lpPut == lpPut))
143+ 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))]
147144 else throw("Strict value is not equal to itself.")
148145 }
149146
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
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 let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Acc found."))
6666
6767 func convertAssetId (assetId) = if (!(isDefined(assetId)))
6868 then "WAVES"
6969 else assetId
7070
7171
7272 func dataPutActionInfo (inAssetId,inAssetAmt,txHeight,txTimestamp) = makeString(["%s%d%d%d", inAssetId, toString(inAssetAmt), toString(txHeight), toString(txTimestamp)], SEP)
7373
7474
7575 func dataInvestActionInfo (outAmountAssetAmt,outPriceAssetAmt,txHeight,txTimestamp) = makeString(["%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(txHeight), toString(txTimestamp)], SEP)
7676
7777
7878 func asString (val) = match val {
7979 case valStr: String =>
8080 valStr
8181 case _ =>
8282 throw("fail to cast into String")
8383 }
8484
8585
8686 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
8787
8888
8989 @Callable(i)
9090 func constructor (factoryContract) = if ((i.caller != this))
9191 then throw("permissions denied")
9292 else [StringEntry(keyFactoryContract(), factoryContract)]
9393
9494
9595
9696 @Callable(i)
9797 func put () = {
9898 let pool = toString(i.caller)
9999 let pmtAmtAsset = value(i.payments[0])
100100 let pmtAssetId = if (!(isDefined(pmtAmtAsset.assetId)))
101101 then "WAVES"
102102 else toBase58String(value(pmtAmtAsset.assetId))
103103 let pmtAssetAmt = pmtAmtAsset.amount
104104 let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(pool)), "Invalid caller"), SEP)
105105 let amountAssetId = parseIntValue(poolAssets[1])
106106 let priceAssetId = parseIntValue(poolAssets[2])
107107 let amountAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(amountAssetId)), "Cannot find asset")
108108 let priceAsset = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(priceAssetId)), "Cannot find asset")
109109 let totalAmt = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(pool, pmtAssetId)), 0)
110110 let cumulativeSlippageAmt = valueOrElse(getInteger(this, keySlippageAmtPerAssetCumulative(pool, pmtAssetId)), 0)
111111 [StringEntry(keyRegisterPut(pool, toBase58String(i.transactionId)), dataPutActionInfo(pmtAssetId, pmtAssetAmt, height, lastBlock.timestamp)), IntegerEntry(keyPoolTotalAmtByAsset(pool, pmtAssetId), (totalAmt + pmtAssetAmt)), IntegerEntry(keySlippageAmtPerAssetCumulative(pool, pmtAssetId), (cumulativeSlippageAmt + pmtAssetAmt))]
112112 }
113113
114114
115115
116116 @Callable(i)
117-func invest (poolAddress) = {
118- let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddress)), "Invalid pool passed."), SEP)
119- let poolAmountAssetId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found")
120- let poolPriceAssetId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found")
121- let poolConfig = split(valueOrErrorMessage(getString(factoryContract, keyPoolConfig(poolAssets[1], poolAssets[2])), "No factory config found for pool assets."), SEP)
122- let amountAssetDecimals = parseIntValue(poolConfig[idxAmtAssetDcm])
123- let priceAssetDecimals = parseIntValue(poolConfig[idxPriceAssetDcm])
124- let amountAssetBalance = toScale(valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddress, poolAmountAssetId)), 0), scale8, amountAssetDecimals)
125- let priceAssetBalance = toScale(valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddress, poolPriceAssetId)), 0), scale8, priceAssetDecimals)
126- let poolStats = asString(invoke(addressFromStringValue(poolAddress), "statsREADONLY", nil, nil))
127- if ((poolStats == poolStats))
128- then {
129- let currentPrice = parseIntValue(split(poolStats, SEP)[poolStatsPriceKey])
130- let pEqByA = fraction(currentPrice, amountAssetBalance, scale8)
131- let resAssetsToPut = if ((pEqByA > priceAssetBalance))
132- then $Tuple2(fraction(priceAssetBalance, scale8, currentPrice), priceAssetBalance)
133- else $Tuple2(amountAssetBalance, pEqByA)
134- let resultAmountAssetAmt = toScale(resAssetsToPut._1, amountAssetDecimals, scale8)
135- let resultPriceAssetAmt = toScale(resAssetsToPut._2, priceAssetDecimals, scale8)
136- let amtAssetId = if ((poolAmountAssetId == "WAVES"))
137- then unit
138- else fromBase58String(poolAmountAssetId)
139- let priceAssetId = if ((poolPriceAssetId == "WAVES"))
140- then unit
141- else fromBase58String(poolPriceAssetId)
142- let lpPut = invoke(addressFromStringValue(poolAddress), "putForFree", [1000], [AttachedPayment(amtAssetId, resultAmountAssetAmt), AttachedPayment(priceAssetId, resultPriceAssetAmt)])
143- if ((lpPut == lpPut))
144- then [StringEntry(keyRegisterInvest(poolAddress, toBase58String(i.transactionId)), dataInvestActionInfo(resultAmountAssetAmt, resultPriceAssetAmt, height, lastBlock.timestamp))]
145- else throw("Strict value is not equal to itself.")
146- }
117+func invest (poolAddressStr) = {
118+ let poolAddress = valueOrErrorMessage(addressFromString(poolAddressStr), "invalid pool address")
119+ let poolAssets = split(valueOrErrorMessage(getString(factoryContract, keyMappingPoolContractAddressToPoolAssets(poolAddressStr)), "Invalid pool passed."), SEP)
120+ let amId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[1]))), "No asset mapping found")
121+ let prId = valueOrErrorMessage(getString(factoryContract, keyMappingsInternal2baseAssetId(parseIntValue(poolAssets[2]))), "No asset mapping found")
122+ let amBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, amId)), 0)
123+ let prBalance = valueOrElse(getInteger(this, keyPoolTotalAmtByAsset(poolAddressStr, prId)), 0)
124+ let estByPrResult = invoke(poolAddress, "evaluatePutByPriceAssetREADONLY", [prBalance], nil)
125+ let estByAmResult = invoke(poolAddress, "evaluatePutByAmountAssetREADONLY", [amBalance], nil)
126+ let IdxEstAmAmount = 7
127+ let IdxEstPrAmount = 8
128+ let estAmAmt = valueOrErrorMessage(parseIntValue(split(asString(estByPrResult), SEP)[IdxEstAmAmount]), "fail to parse estimated amAsset amount")
129+ let estPrAmt = valueOrErrorMessage(parseIntValue(split(asString(estByAmResult), SEP)[IdxEstPrAmount]), "fail to parse estimated prAsset amount")
130+ let $t060346135 = if ((amBalance >= estAmAmt))
131+ then $Tuple2(estAmAmt, prBalance)
132+ else $Tuple2(amBalance, estPrAmt)
133+ let amAmt = $t060346135._1
134+ let prAmt = $t060346135._2
135+ let amAssetId = if ((amId == "WAVES"))
136+ then unit
137+ else fromBase58String(amId)
138+ let prAssetId = if ((prId == "WAVES"))
139+ then unit
140+ else fromBase58String(prId)
141+ let lpPut = invoke(poolAddress, "putForFree", [1000], [AttachedPayment(amAssetId, amAmt), AttachedPayment(prAssetId, prAmt)])
142+ if ((lpPut == lpPut))
143+ 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))]
147144 else throw("Strict value is not equal to itself.")
148145 }
149146
150147
151148 @Verifier(tx)
152149 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
153150

github/deemru/w8io/026f985 
30.44 ms