tx · mvBeaTcVMZgX6bMcNUspWUWGPuG2YgeKrdGoGYsLbGe 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8: -0.00400000 Waves 2023.01.22 16:54 [2416247] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves
{ "type": 13, "id": "mvBeaTcVMZgX6bMcNUspWUWGPuG2YgeKrdGoGYsLbGe", "fee": 400000, "feeAssetId": null, "timestamp": 1674395683925, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "2R1yVss8XXXmsSB4YBJw9G8QjW4Q4qVh4RPy7M2qfLMkvZBvJPvHZyN6grM463YckYfurHDKLYSv9LdB96u3xK5Z" ], "script": "base64:BgIPCAISABIAEgMKAQgSABIAGQAFd2NkSWQCLDVXRTZIQlZzbUFiYXBUbVRLcG15V21VUjY3ZmMxNnliRnJOanh6bURCdFBhAAt3Y2REZWNpbWFscwACARN0b3RhbFNoYXJlQnlVc2VyS0VZAQVvd25lcgkAuQkCCQDMCAICBnNoYXJlcwkAzAgCBQVvd25lcgUDbmlsAgFfARR0b3RhbFNoYXJlQnlVc2VyUkVBRAEFb3duZXIJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwkBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBQVvd25lcgAAABJ0b3RhbElzc3VlZFdDRF9LRVkCEHRvdGFsX2lzc3VlZF9XQ0QBE3RvdGFsSXNzdWVkV0NEX1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFEnRvdGFsSXNzdWVkV0NEX0tFWQAAAA50b3RhbFNoYXJlc0tFWQIMdG90YWxfc2hhcmVzAQ90b3RhbFNoYXJlc1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFDnRvdGFsU2hhcmVzS0VZAAAAEnRvdG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AgOmDsd4WBA90b3RhbENvbGxhdGVyYWwJARN0b3RhbENvbGxhdGVyYWxSRUFEAAQMdG90YWxfaXNzdWVkCQETdG90YWxJc3N1ZWRXQ0RfUkVBRAAJAMwIAgkBDEludGVnZXJFbnRyeQIFEnRvdGFsQ29sbGF0ZXJhbEtFWQkAZAIFD3RvdGFsQ29sbGF0ZXJhbAgFA3BtdAZhbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIFEnRvdGFsSXNzdWVkV0NEX0tFWQkAZAIFDHRvdGFsX2lzc3VlZAUQd2NkX2lzc3VlX2Ftb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQERQGV4dHJOYXRpdmUoMTA2MikBBQdhY2NvdW50BRB3Y2RfaXNzdWVfYW1vdW50CQDZBAEFBXdjZElkBQNuaWwBaQESdGVzdF9nZXRfdXNlcl90bWR1AQdhY2NvdW50CQACAQkArAICAghSZXN1bHQ6IAkApAMBCQEPZ2V0VXNlclRNRFVfV0NEAQUHYWNjb3VudAFpAQ10ZXN0X2dldF90bWR1AAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBB2dldFRNRFUAAWkBDXRlc3RfZ2V0X3RtZGkACQACAQkArAICAghSZXN1bHQ6IAkApAMBCQEHZ2V0VE1ESQAA+qgWZw==", "height": 2416247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6B8yquQo5zKWp4TxiBXMmMUNszj1kwqXtNnd5NxF5xxf Next: CuuvyDUBVWrFjNi6QpNg5BYQ6Xgkot66vAjiLjxqrjtr Diff:
Old | New | Differences | |
---|---|---|---|
63 | 63 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
64 | 64 | ||
65 | 65 | ||
66 | + | func getBaseTMDU () = { | |
67 | + | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | + | TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
69 | + | } | |
70 | + | ||
71 | + | ||
66 | 72 | func getTMDU () = { | |
67 | 73 | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | 74 | if ((diff > 0)) | |
69 | 75 | then { | |
70 | - | let max_ | |
71 | - | if ((diff > max_ | |
72 | - | then max_ | |
73 | - | else | |
76 | + | let max_base_unlockable_waves = getBaseTMDU() | |
77 | + | if ((diff > max_base_unlockable_waves)) | |
78 | + | then max_base_unlockable_waves | |
79 | + | else diff | |
74 | 80 | } | |
75 | 81 | else 0 | |
76 | 82 | } | |
127 | 133 | ||
128 | 134 | ||
129 | 135 | @Callable(i) | |
130 | - | func test (account) = throw(("Result: " + toString(getUserTMDU_WCD(account)))) | |
136 | + | func test_get_user_tmdu (account) = throw(("Result: " + toString(getUserTMDU_WCD(account)))) | |
131 | 137 | ||
132 | 138 | ||
133 | 139 | ||
134 | 140 | @Callable(i) | |
135 | - | func test_ii () = throw(("Result: " + toString(getTMDU()))) | |
141 | + | func test_get_tmdu () = throw(("Result: " + toString(getTMDU()))) | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
146 | + | func test_get_tmdi () = throw(("Result: " + toString(getTMDI()))) | |
136 | 147 | ||
137 | 148 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let wcdId = "5WE6HBVsmAbapTmTKpmyWmUR67fc16ybFrNjxzmDBtPa" | |
5 | 5 | ||
6 | 6 | let wcdDecimals = 2 | |
7 | 7 | ||
8 | 8 | func totalShareByUserKEY (owner) = makeString(["shares", owner], "_") | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func totalShareByUserREAD (owner) = valueOrElse(getInteger(this, totalShareByUserKEY(owner)), 0) | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | let totalIssuedWCD_KEY = "total_issued_WCD" | |
15 | 15 | ||
16 | 16 | func totalIssuedWCD_READ () = valueOrElse(getInteger(this, totalIssuedWCD_KEY), 0) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | let totalSharesKEY = "total_shares" | |
20 | 20 | ||
21 | 21 | func totalSharesREAD () = valueOrElse(getInteger(this, totalSharesKEY), 0) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | let totalCollateralKEY = "total_collateral" | |
25 | 25 | ||
26 | 26 | func totalCollateralREAD () = valueOrElse(getInteger(this, totalCollateralKEY), 0) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | let INITIAL_PRICE = 240000000 | |
30 | 30 | ||
31 | 31 | let wavesReferencePrice_KEY = "waves_reference_price" | |
32 | 32 | ||
33 | 33 | func wavesReferencePrice_READ () = valueOrElse(getInteger(this, wavesReferencePrice_KEY), INITIAL_PRICE) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func userShareFraction (owner) = { | |
37 | 37 | let totalShares = totalSharesREAD() | |
38 | 38 | if ((totalShares > 0)) | |
39 | 39 | then { | |
40 | 40 | let totalUserShare = totalShareByUserREAD(owner) | |
41 | 41 | fraction(100000000, totalUserShare, totalShares) | |
42 | 42 | } | |
43 | 43 | else 0 | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | let paramA_KEY = "A" | |
48 | 48 | ||
49 | 49 | func paramA_READ () = valueOrElse(getInteger(this, "A"), 100) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func computeLogTMDIR (issued_wcd,A) = (500000000 - (log(issued_wcd, wcdDecimals, 10, 0, 6, HALFUP) * A)) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000)) | |
59 | 59 | then TMDIRmultiply(issued_wcd, issued_wcd, A) | |
60 | 60 | else 10000000 | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
64 | 64 | ||
65 | 65 | ||
66 | + | func getBaseTMDU () = { | |
67 | + | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | + | TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
69 | + | } | |
70 | + | ||
71 | + | ||
66 | 72 | func getTMDU () = { | |
67 | 73 | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | 74 | if ((diff > 0)) | |
69 | 75 | then { | |
70 | - | let max_ | |
71 | - | if ((diff > max_ | |
72 | - | then max_ | |
73 | - | else | |
76 | + | let max_base_unlockable_waves = getBaseTMDU() | |
77 | + | if ((diff > max_base_unlockable_waves)) | |
78 | + | then max_base_unlockable_waves | |
79 | + | else diff | |
74 | 80 | } | |
75 | 81 | else 0 | |
76 | 82 | } | |
77 | 83 | ||
78 | 84 | ||
79 | 85 | func getUserTMDI_WAVES (owner) = (1000000 * fraction(getTMDI(), userShareFraction(owner), wavesReferencePrice_READ())) | |
80 | 86 | ||
81 | 87 | ||
82 | 88 | func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000) | |
83 | 89 | ||
84 | 90 | ||
85 | 91 | func getUserTMDU_WCD (owner) = fraction(fraction(getTMDU(), userShareFraction(owner), 100000000), wavesReferencePrice_READ(), 100000000) | |
86 | 92 | ||
87 | 93 | ||
88 | 94 | @Callable(i) | |
89 | 95 | func deposit_share () = { | |
90 | 96 | let pmt = if ((size(i.payments) == 1)) | |
91 | 97 | then i.payments[0] | |
92 | 98 | else throw("Attached payment is required") | |
93 | 99 | if (isDefined(pmt.assetId)) | |
94 | 100 | then throw("Only WAVES is allowed.") | |
95 | 101 | else { | |
96 | 102 | let account = toString(i.caller) | |
97 | 103 | let totalShareByUser = totalShareByUserREAD(account) | |
98 | 104 | let totalShares = totalSharesREAD() | |
99 | 105 | let totalCollateral = totalCollateralREAD() | |
100 | 106 | [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))] | |
101 | 107 | } | |
102 | 108 | } | |
103 | 109 | ||
104 | 110 | ||
105 | 111 | ||
106 | 112 | @Callable(i) | |
107 | 113 | func issue () = { | |
108 | 114 | let pmt = if ((size(i.payments) == 1)) | |
109 | 115 | then i.payments[0] | |
110 | 116 | else throw("Attached payment is required") | |
111 | 117 | if (isDefined(pmt.assetId)) | |
112 | 118 | then throw("Only WAVES is allowed.") | |
113 | 119 | else { | |
114 | 120 | let account = toString(i.caller) | |
115 | 121 | let max_waves = getUserTMDI_WAVES(account) | |
116 | 122 | if ((pmt.amount > max_waves)) | |
117 | 123 | then throw((((("User lock limit is " + toString(max_waves)) + " WAVES. Sent ") + toString(pmt.amount)) + " WAVES.")) | |
118 | 124 | else { | |
119 | 125 | let wcd_issue_amount = fraction(pmt.amount, wavesReferencePrice_READ(), 100000000000000) | |
120 | 126 | let totalCollateral = totalCollateralREAD() | |
121 | 127 | let total_issued = totalIssuedWCD_READ() | |
122 | 128 | [IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount)), IntegerEntry(totalIssuedWCD_KEY, (total_issued + wcd_issue_amount)), ScriptTransfer(addressFromStringValue(account), wcd_issue_amount, fromBase58String(wcdId))] | |
123 | 129 | } | |
124 | 130 | } | |
125 | 131 | } | |
126 | 132 | ||
127 | 133 | ||
128 | 134 | ||
129 | 135 | @Callable(i) | |
130 | - | func test (account) = throw(("Result: " + toString(getUserTMDU_WCD(account)))) | |
136 | + | func test_get_user_tmdu (account) = throw(("Result: " + toString(getUserTMDU_WCD(account)))) | |
131 | 137 | ||
132 | 138 | ||
133 | 139 | ||
134 | 140 | @Callable(i) | |
135 | - | func test_ii () = throw(("Result: " + toString(getTMDU()))) | |
141 | + | func test_get_tmdu () = throw(("Result: " + toString(getTMDU()))) | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
146 | + | func test_get_tmdi () = throw(("Result: " + toString(getTMDI()))) | |
136 | 147 | ||
137 | 148 |
github/deemru/w8io/169f3d6 106.12 ms ◑