tx · 4KrmqVaCtZ5TjTTno6NKAjoCmCY7jJwPSg3iNi3C78ZP 3MyfKzBNordUSxbv54zj1hxm98ojcDvaiXU: -0.01000000 Waves 2021.09.01 01:44 [1683133] smart account 3MyfKzBNordUSxbv54zj1hxm98ojcDvaiXU > SELF 0.00000000 Waves
{ "type": 13, "id": "4KrmqVaCtZ5TjTTno6NKAjoCmCY7jJwPSg3iNi3C78ZP", "fee": 1000000, "feeAssetId": null, "timestamp": 1630449937193, "version": 2, "chainId": 84, "sender": "3MyfKzBNordUSxbv54zj1hxm98ojcDvaiXU", "senderPublicKey": "EhGswdVQkp8SXCWyKvRCUKYDidTrRjnzTPa8CZk6GYgN", "proofs": [ "67GMFsxxWqjeZmNjab8JEDiXrEYTE1yQWDcx6bAqy88TXFUr6REZwScpaHeijPG9AW3XuRDoMJjPLPhAXsjg1Ygk" ], "script": "base64:AAIFAAAAAAAAABAIAhIECgIIBBIGCgQICAgIAAAAJgAAAAAKYmFzZUZhY3RvcgAAAAAAAAAD6AAAAAAJYmFzZUluZGV4AAAjhvJvwQAAAAAAAA1ibG9ja3NQZXJZZWFyAAAAAAAACAUgAAAAAAZjb25maWcJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAANY29uZmlnQWRkcmVzcwIAAAAAAAAAAAVhZG1pbgkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZjb25maWcCAAAABWFkbWluAgAAAAAAAAAAC3dhdmV0cm9sbGVyCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAABmNvbmZpZwIAAAALd2F2ZXRyb2xsZXICAAAAAAAAAAAKYXNzZXRJZFN1YgkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAB2Fzc2V0S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VyRW50cnkAAAACAgAAAAxkVG9rZW5TdXBwbHkAAAAAAAAAAAAFAAAAA25pbAkAAAIAAAABAgAAABNQb29sIGFscmVhZHkgc2V0dXAhAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXnH6mRe", "height": 1683133, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 64X3AS6Ptwc2fnmRtPvAPQzYPTk3daUKtMUvSXi3bY57 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let baseFactor = 1000 | |
5 | + | ||
6 | + | let baseIndex = 10000000000000000 | |
7 | + | ||
8 | + | let blocksPerYear = 525600 | |
9 | + | ||
10 | + | let config = valueOrElse(getString(this, "configAddress"), "") | |
11 | + | ||
12 | + | let admin = valueOrElse(getString(addressFromStringValue(config), "admin"), "") | |
13 | + | ||
14 | + | let wavetroller = valueOrElse(getString(addressFromStringValue(config), "wavetroller"), "") | |
15 | + | ||
16 | + | let assetIdSub = valueOrErrorMessage(getString(this, "assetId"), "No assetId could be found in data storage!") | |
17 | + | ||
18 | + | let assetDecimals = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Decimals")), (("No key " + (assetIdSub + "_Decimals")) + " was found")) | |
19 | + | ||
20 | + | let multiplier = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Multiplier")), (("No key " + (assetIdSub + "_Multiplier")) + " was found")) | |
21 | + | ||
22 | + | let kink = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_Kink")), (("No key " + (assetIdSub + "_Kink")) + " was found")) | |
23 | + | ||
24 | + | let jumpMultiplier = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_JumpMultiplier")), (("No key " + (assetIdSub + "_JumpMultiplier")) + " was found")) | |
25 | + | ||
26 | + | let baseRate = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_BaseRate")), (("No key " + (assetIdSub + "_BaseRate")) + " was found")) | |
27 | + | ||
28 | + | let reserveFactor = valueOrErrorMessage(getInteger(addressFromStringValue(config), (assetIdSub + "_ReserveFactor")), (("No key " + (assetIdSub + "_ReserveFactor")) + " was found")) | |
29 | + | ||
30 | + | let totalBorrow = valueOrElse(getInteger(this, "totalBorrow"), 0) | |
31 | + | ||
32 | + | let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0) | |
33 | + | ||
34 | + | let totalReserve = valueOrElse(getInteger(this, "totalReserve"), 0) | |
35 | + | ||
36 | + | let dTokenSupply = valueOrErrorMessage(getInteger(this, "dTokenSupply"), "No key dTokenSupply was found") | |
37 | + | ||
38 | + | let dTokenDecimals = valueOrErrorMessage(getInteger(this, "dTokenDecimals"), "No key dTokenDecimals was found") | |
39 | + | ||
40 | + | let dTokenId = valueOrErrorMessage(getString(this, "dTokenId"), "No key dTokenId was found") | |
41 | + | ||
42 | + | let storedHeight = valueOrElse(getInteger(this, "storedHeight"), height) | |
43 | + | ||
44 | + | let storedIndex = valueOrElse(getInteger(this, "storedIndex"), 10000000000000000) | |
45 | + | ||
46 | + | func isAdminAddress (address) = if ((addressFromStringValue(admin) == address)) | |
47 | + | then true | |
48 | + | else false | |
49 | + | ||
50 | + | ||
51 | + | func isWavetroller (address) = if ((addressFromStringValue(wavetroller) == address)) | |
52 | + | then true | |
53 | + | else false | |
54 | + | ||
55 | + | ||
56 | + | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
57 | + | ||
58 | + | ||
59 | + | func writeInteger (key,integerValue) = IntegerEntry(key, integerValue) | |
60 | + | ||
61 | + | ||
62 | + | func userTokenBalance (userAddress) = valueOrElse(getInteger(this, (userAddress + "_tokenBalance")), 0) | |
63 | + | ||
64 | + | ||
65 | + | let utilization = if ((totalSupply > 0)) | |
66 | + | then fraction(totalBorrow, baseFactor, totalSupply) | |
67 | + | else 0 | |
68 | + | ||
69 | + | let apr = { | |
70 | + | let minValue = [utilization, kink] | |
71 | + | let minValueItem = min(minValue) | |
72 | + | let maxValue = [0, (utilization - kink)] | |
73 | + | let maxValueItem = max(maxValue) | |
74 | + | ((fraction(multiplier, minValueItem, baseFactor) + fraction(jumpMultiplier, maxValueItem, baseFactor)) + baseRate) | |
75 | + | } | |
76 | + | ||
77 | + | let apy = fraction(fraction(apr, utilization, baseFactor), (baseFactor - reserveFactor), baseFactor) | |
78 | + | ||
79 | + | let borrowRatePerBlock = fraction(apr, baseIndex, (blocksPerYear * baseFactor)) | |
80 | + | ||
81 | + | let deltaBlocks = (height - storedHeight) | |
82 | + | ||
83 | + | let currentIndex = fraction(storedIndex, (baseIndex + (borrowRatePerBlock * deltaBlocks)), baseIndex, CEILING) | |
84 | + | ||
85 | + | let currentTotalBorrow = fraction(totalBorrow, currentIndex, storedIndex) | |
86 | + | ||
87 | + | let collectedInterest = fraction(totalBorrow, (borrowRatePerBlock * deltaBlocks), baseIndex) | |
88 | + | ||
89 | + | let currentSupply = (totalSupply + fraction((baseFactor - reserveFactor), collectedInterest, baseFactor)) | |
90 | + | ||
91 | + | let currentReserve = (totalReserve + fraction(reserveFactor, collectedInterest, baseFactor)) | |
92 | + | ||
93 | + | let dTokenExchangeRate = if ((dTokenSupply > 0)) | |
94 | + | then { | |
95 | + | let exponent = ((18 - dTokenDecimals) + assetDecimals) | |
96 | + | let mantissa = pow(10, 0, exponent, 0, 0, CEILING) | |
97 | + | fraction(currentSupply, mantissa, dTokenSupply) | |
98 | + | } | |
99 | + | else 20000000000000000 | |
100 | + | ||
101 | + | func calcTokenAmount (assetAmount) = { | |
102 | + | let exponent = ((18 - dTokenDecimals) + assetDecimals) | |
103 | + | let mantissa = pow(10, 0, exponent, 0, 0, CEILING) | |
104 | + | fraction(assetAmount, mantissa, dTokenExchangeRate) | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | @Callable(i) | |
109 | + | func deposit (user,isCollateral) = if (isWavetroller(i.caller)) | |
110 | + | then { | |
111 | + | let userTokenAmount = calcTokenAmount(i.payments[0].amount) | |
112 | + | let currentDTokenSupply = (dTokenSupply + userTokenAmount) | |
113 | + | let userBalance = (userTokenBalance(user) + userTokenAmount) | |
114 | + | $Tuple2([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))], userTokenAmount) | |
115 | + | } | |
116 | + | else throw("Address does not match with wavetroller address!") | |
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | @Callable(i) | |
121 | + | func setup (aId,configAdd,tokenName,tokenDescription) = if (if (!(isDefined(getString(this, "config")))) | |
122 | + | then !(isDefined(getString(this, "admin"))) | |
123 | + | else false) | |
124 | + | then { | |
125 | + | let asset = Issue(tokenName, tokenDescription, 0, 8, true) | |
126 | + | let tokenId = calculateAssetId(asset) | |
127 | + | [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)] | |
128 | + | } | |
129 | + | else throw("Pool already setup!") | |
130 | + | ||
131 | + | ||
132 | + | @Verifier(tx) | |
133 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
134 | + |
github/deemru/w8io/026f985 22.14 ms ◑