tx · BFdZVrAwZyw4YCq6b6ksJuKmGyiDr1M9pkwEfbpU43rY

3NAToHPcRGMR4M2pUpy6gPcpiMX5via7vf9:  -0.04000000 Waves

2021.08.31 22:35 [1682943] smart account 3NAToHPcRGMR4M2pUpy6gPcpiMX5via7vf9 > SELF 0.00000000 Waves

{ "type": 13, "id": "BFdZVrAwZyw4YCq6b6ksJuKmGyiDr1M9pkwEfbpU43rY", "fee": 4000000, "feeAssetId": null, "timestamp": 1630438574411, "version": 2, "chainId": 84, "sender": "3NAToHPcRGMR4M2pUpy6gPcpiMX5via7vf9", "senderPublicKey": "5fe3Hm6UB8fRqvLYhGeeNdy7rEgwpxWjdEFPgnNwSRCz", "proofs": [ "59wkrwfW3CGBJhm7kUMjtC48sVV7vNSacbrw6Aw9QEsET8sL1v6Dy5JhhQQLeYuQErA2MaaaL6a3WidXuktzMtef" ], "script": "base64:AAIFAAAAAAAAABAIAhIECgIIBBIGCgQICAgIAAAAJgAAAAAKYmFzZUZhY3RvcgAAAAAAAAAD6AAAAAAJYmFzZUluZGV4AAAjhvJvwQAAAAAAAA1ibG9ja3NQZXJZZWFyAAAAAAAACAUgAAAAAAZjb25maWcJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAANY29uZmlnQWRkcmVzcwIAAAAAAAAAAAVhZG1pbgkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZjb25maWcCAAAABWFkbWluAgAAAAAAAAAAC3dhdmV0cm9sbGVyCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAABmNvbmZpZwIAAAALd2F2ZXRyb2xsZXICAAAAAAAAAAAKYXNzZXRJZFN1YgkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAB2Fzc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aWdodAUAAAAGaGVpZ2h0CQAETAAAAAIJAQAAAAt3cml0ZVN0cmluZwAAAAICAAAACmRUb2tlbk5hbWUFAAAACXRva2VuTmFtZQkABEwAAAACCQEAAAALd3JpdGVTdHJpbmcAAAACAgAAAAhkVG9rZW5JZAkAAlgAAAABBQAAAAd0b2tlbklkCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAA5kVG9rZW5EZWNpbWFscwAAAAAAAAAACAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAMZFRva2VuU3VwcGx5AAAAAAAAAAAABQAAAANuaWwJAAACAAAAAQIAAAATUG9vbCBhbHJlYWR5IHNldHVwIQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V575F3mw==", "height": 1682943, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CktDf4byRdBvazVqb69heJofmHXchMiWCY54amF4yp7Q Next: 78GFiPu57Wrs8XsixStoXHkvJdWjrf9Cao784FR7NuL3 Diff:
OldNewDifferences
9292
9393 let dTokenExchangeRate = if ((dTokenSupply > 0))
9494 then {
95- let exponent = ((10 - 8) + assetDecimals)
96- let exponentDecPoint = if ((10 > exponent))
97- then 1
98- else 2
99- let mantissa = pow(10, 2, exponent, 2, 18, CEILING)
95+ let exponent = ((18 - dTokenDecimals) + assetDecimals)
96+ let mantissa = pow(10, 0, exponent, 0, 0, CEILING)
10097 fraction(currentSupply, mantissa, dTokenSupply)
10198 }
10299 else {
103- let rBaseExponent = (assetDecimals + 6)
104- let baseExpoDecPoint = if ((10 > rBaseExponent))
105- then 1
106- else 2
107- let baseMantissa = pow(10, 2, rBaseExponent, baseExpoDecPoint, 18, CEILING)
108- fraction(2, baseMantissa, 1)
100+ let baseExchangeRate = 2
101+ let baseExponent = (assetDecimals + 6)
102+ let baseMantissa = pow(10, 0, baseExponent, 0, 0, CEILING)
103+ fraction(baseExchangeRate, baseMantissa, 1)
109104 }
110105
111-func calcTokenAmout (assetAmount) = {
112- let exponent = ((10 - 8) + assetDecimals)
113- let exponentPoint = if ((10 > exponent))
114- then 1
115- else 2
116- let mantissa = pow(10, 2, exponent, exponentPoint, 18, CEILING)
117- fraction(assetAmount, 2, dTokenExchangeRate)
106+func calcTokenAmount (assetAmount) = {
107+ let exponent = ((18 - dTokenDecimals) + assetDecimals)
108+ let mantissa = pow(10, 0, exponent, 0, 0, CEILING)
109+ fraction(assetAmount, mantissa, dTokenExchangeRate)
118110 }
119111
120112
121113 @Callable(i)
122-func deposit (user,isCollateral) = {
123- let userTokenAmount = calcTokenAmout(i.payments[0].amount)
124- let currentDTokenSupply = (dTokenSupply + 25000000000)
125- let userBalance = (userTokenBalance(user) + 25000000000)
126-[Reissue(fromBase58String(dTokenId), 25000000000, true), writeInteger("dTokenSupply", currentDTokenSupply), writeInteger((user + "_tokenBalance"), userBalance), BooleanEntry((user + "_useAsCollateral"), isCollateral), writeInteger("totalBorrow", currentTotalBorrow), writeInteger("totalSupply", (currentSupply + i.payments[0].amount)), writeInteger("totalReserve", currentReserve), writeInteger("storedIndex", currentIndex), writeInteger("storedHeight", height), ScriptTransfer(i.caller, 25000000000, fromBase58String(dTokenId))]
127- }
114+func deposit (user,isCollateral) = if (isWavetroller(i.caller))
115+ then {
116+ let userTokenAmount = calcTokenAmount(i.payments[0].amount)
117+ let currentDTokenSupply = (dTokenSupply + userTokenAmount)
118+ let userBalance = (userTokenBalance(user) + userTokenAmount)
119+[Reissue(fromBase58String(dTokenId), userTokenAmount, true), writeInteger("dTokenSupply", currentDTokenSupply), writeInteger((user + "_tokenBalance"), userBalance), BooleanEntry((user + "_useAsCollateral"), isCollateral), writeInteger("totalBorrow", currentTotalBorrow), writeInteger("totalSupply", (currentSupply + i.payments[0].amount)), writeInteger("totalReserve", currentReserve), writeInteger("storedIndex", currentIndex), writeInteger("storedHeight", height), ScriptTransfer(i.caller, userTokenAmount, fromBase58String(dTokenId))]
120+ }
121+ else throw("Address does not match with wavetroller address!")
128122
129123
130124
131125 @Callable(i)
132-func setup (aId,configAdd,tokenName,tokenDescription) = {
133- let asset = Issue(tokenName, tokenDescription, 0, 8, true)
134- let tokenId = calculateAssetId(asset)
126+func setup (aId,configAdd,tokenName,tokenDescription) = if (if (!(isDefined(getString(this, "config"))))
127+ then !(isDefined(getString(this, "admin")))
128+ else false)
129+ then {
130+ let asset = Issue(tokenName, tokenDescription, 0, 8, true)
131+ let tokenId = calculateAssetId(asset)
135132 [asset, writeString("assetId", aId), writeString("configAddress", configAdd), IntegerEntry("totalBorrow", 0), IntegerEntry("totalSupply", 0), IntegerEntry("totalReserve", 0), IntegerEntry("storedIndex", baseIndex), IntegerEntry("storedHeight", height), writeString("dTokenName", tokenName), writeString("dTokenId", toBase58String(tokenId)), IntegerEntry("dTokenDecimals", 8), IntegerEntry("dTokenSupply", 0)]
136- }
133+ }
134+ else throw("Pool already setup!")
137135
138136
139137 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let baseFactor = 1000
55
66 let baseIndex = 10000000000000000
77
88 let blocksPerYear = 525600
99
1010 let config = valueOrElse(getString(this, "configAddress"), "")
1111
1212 let admin = valueOrElse(getString(addressFromStringValue(config), "admin"), "")
1313
1414 let wavetroller = valueOrElse(getString(addressFromStringValue(config), "wavetroller"), "")
1515
1616 let assetIdSub = valueOrErrorMessage(getString(this, "assetId"), "No assetId could be found in data storage!")
1717
1818 let assetDecimals = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Decimals")), (("No key " + (assetIdSub + "_Decimals")) + " was found"))
1919
2020 let multiplier = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Multiplier")), (("No key " + (assetIdSub + "_Multiplier")) + " was found"))
2121
2222 let kink = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Kink")), (("No key " + (assetIdSub + "_Kink")) + " was found"))
2323
2424 let jumpMultiplier = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_JumpMultiplier")), (("No key " + (assetIdSub + "_JumpMultiplier")) + " was found"))
2525
2626 let baseRate = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_BaseRate")), (("No key " + (assetIdSub + "_BaseRate")) + " was found"))
2727
2828 let reserveFactor = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_ReserveFactor")), (("No key " + (assetIdSub + "_ReserveFactor")) + " was found"))
2929
3030 let totalBorrow = valueOrElse(getInteger(this, "totalBorrow"), 0)
3131
3232 let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0)
3333
3434 let totalReserve = valueOrElse(getInteger(this, "totalReserve"), 0)
3535
3636 let dTokenSupply = valueOrErrorMessage(getInteger(this, "dTokenSupply"), "No key dTokenSupply was found")
3737
3838 let dTokenDecimals = valueOrErrorMessage(getInteger(this, "dTokenDecimals"), "No key dTokenDecimals was found")
3939
4040 let dTokenId = valueOrErrorMessage(getString(this, "dTokenId"), "No key dTokenId was found")
4141
4242 let storedHeight = valueOrElse(getInteger(this, "storedHeight"), height)
4343
4444 let storedIndex = valueOrElse(getInteger(this, "storedIndex"), 10000000000000000)
4545
4646 func isAdminAddress (address) = if ((addressFromStringValue(admin) == address))
4747 then true
4848 else false
4949
5050
5151 func isWavetroller (address) = if ((addressFromStringValue(wavetroller) == address))
5252 then true
5353 else false
5454
5555
5656 func writeString (key,stringValue) = StringEntry(key, stringValue)
5757
5858
5959 func writeInteger (key,integerValue) = IntegerEntry(key, integerValue)
6060
6161
6262 func userTokenBalance (userAddress) = valueOrElse(getInteger(this, (userAddress + "_tokenBalance")), 0)
6363
6464
6565 let utilization = if ((totalSupply > 0))
6666 then fraction(totalBorrow, baseFactor, totalSupply)
6767 else 0
6868
6969 let apr = {
7070 let minValue = [utilization, kink]
7171 let minValueItem = min(minValue)
7272 let maxValue = [0, (utilization - kink)]
7373 let maxValueItem = max(maxValue)
7474 ((fraction(multiplier, minValueItem, baseFactor) + fraction(jumpMultiplier, maxValueItem, baseFactor)) + baseRate)
7575 }
7676
7777 let apy = fraction(fraction(apr, utilization, baseFactor), (baseFactor - reserveFactor), baseFactor)
7878
7979 let borrowRatePerBlock = fraction(apr, baseIndex, (blocksPerYear * baseFactor))
8080
8181 let deltaBlocks = (height - storedHeight)
8282
8383 let currentIndex = fraction(storedIndex, (baseIndex + (borrowRatePerBlock * deltaBlocks)), baseIndex, CEILING)
8484
8585 let currentTotalBorrow = fraction(totalBorrow, currentIndex, storedIndex)
8686
8787 let collectedInterest = fraction(totalBorrow, (borrowRatePerBlock * deltaBlocks), baseIndex)
8888
8989 let currentSupply = (totalSupply + fraction((baseFactor - reserveFactor), collectedInterest, baseFactor))
9090
9191 let currentReserve = (totalReserve + fraction(reserveFactor, collectedInterest, baseFactor))
9292
9393 let dTokenExchangeRate = if ((dTokenSupply > 0))
9494 then {
95- let exponent = ((10 - 8) + assetDecimals)
96- let exponentDecPoint = if ((10 > exponent))
97- then 1
98- else 2
99- let mantissa = pow(10, 2, exponent, 2, 18, CEILING)
95+ let exponent = ((18 - dTokenDecimals) + assetDecimals)
96+ let mantissa = pow(10, 0, exponent, 0, 0, CEILING)
10097 fraction(currentSupply, mantissa, dTokenSupply)
10198 }
10299 else {
103- let rBaseExponent = (assetDecimals + 6)
104- let baseExpoDecPoint = if ((10 > rBaseExponent))
105- then 1
106- else 2
107- let baseMantissa = pow(10, 2, rBaseExponent, baseExpoDecPoint, 18, CEILING)
108- fraction(2, baseMantissa, 1)
100+ let baseExchangeRate = 2
101+ let baseExponent = (assetDecimals + 6)
102+ let baseMantissa = pow(10, 0, baseExponent, 0, 0, CEILING)
103+ fraction(baseExchangeRate, baseMantissa, 1)
109104 }
110105
111-func calcTokenAmout (assetAmount) = {
112- let exponent = ((10 - 8) + assetDecimals)
113- let exponentPoint = if ((10 > exponent))
114- then 1
115- else 2
116- let mantissa = pow(10, 2, exponent, exponentPoint, 18, CEILING)
117- fraction(assetAmount, 2, dTokenExchangeRate)
106+func calcTokenAmount (assetAmount) = {
107+ let exponent = ((18 - dTokenDecimals) + assetDecimals)
108+ let mantissa = pow(10, 0, exponent, 0, 0, CEILING)
109+ fraction(assetAmount, mantissa, dTokenExchangeRate)
118110 }
119111
120112
121113 @Callable(i)
122-func deposit (user,isCollateral) = {
123- let userTokenAmount = calcTokenAmout(i.payments[0].amount)
124- let currentDTokenSupply = (dTokenSupply + 25000000000)
125- let userBalance = (userTokenBalance(user) + 25000000000)
126-[Reissue(fromBase58String(dTokenId), 25000000000, true), writeInteger("dTokenSupply", currentDTokenSupply), writeInteger((user + "_tokenBalance"), userBalance), BooleanEntry((user + "_useAsCollateral"), isCollateral), writeInteger("totalBorrow", currentTotalBorrow), writeInteger("totalSupply", (currentSupply + i.payments[0].amount)), writeInteger("totalReserve", currentReserve), writeInteger("storedIndex", currentIndex), writeInteger("storedHeight", height), ScriptTransfer(i.caller, 25000000000, fromBase58String(dTokenId))]
127- }
114+func deposit (user,isCollateral) = if (isWavetroller(i.caller))
115+ then {
116+ let userTokenAmount = calcTokenAmount(i.payments[0].amount)
117+ let currentDTokenSupply = (dTokenSupply + userTokenAmount)
118+ let userBalance = (userTokenBalance(user) + userTokenAmount)
119+[Reissue(fromBase58String(dTokenId), userTokenAmount, true), writeInteger("dTokenSupply", currentDTokenSupply), writeInteger((user + "_tokenBalance"), userBalance), BooleanEntry((user + "_useAsCollateral"), isCollateral), writeInteger("totalBorrow", currentTotalBorrow), writeInteger("totalSupply", (currentSupply + i.payments[0].amount)), writeInteger("totalReserve", currentReserve), writeInteger("storedIndex", currentIndex), writeInteger("storedHeight", height), ScriptTransfer(i.caller, userTokenAmount, fromBase58String(dTokenId))]
120+ }
121+ else throw("Address does not match with wavetroller address!")
128122
129123
130124
131125 @Callable(i)
132-func setup (aId,configAdd,tokenName,tokenDescription) = {
133- let asset = Issue(tokenName, tokenDescription, 0, 8, true)
134- let tokenId = calculateAssetId(asset)
126+func setup (aId,configAdd,tokenName,tokenDescription) = if (if (!(isDefined(getString(this, "config"))))
127+ then !(isDefined(getString(this, "admin")))
128+ else false)
129+ then {
130+ let asset = Issue(tokenName, tokenDescription, 0, 8, true)
131+ let tokenId = calculateAssetId(asset)
135132 [asset, writeString("assetId", aId), writeString("configAddress", configAdd), IntegerEntry("totalBorrow", 0), IntegerEntry("totalSupply", 0), IntegerEntry("totalReserve", 0), IntegerEntry("storedIndex", baseIndex), IntegerEntry("storedHeight", height), writeString("dTokenName", tokenName), writeString("dTokenId", toBase58String(tokenId)), IntegerEntry("dTokenDecimals", 8), IntegerEntry("dTokenSupply", 0)]
136- }
133+ }
134+ else throw("Pool already setup!")
137135
138136
139137 @Verifier(tx)
140138 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
141139

github/deemru/w8io/169f3d6 
46.39 ms