tx · 846gzbT8G28437LLwHE5HNCbxBo1tMPtuAMXi4Sjixwv

3N9XFD2Yw3uN27NjudPVjNEGtvS6JJTxK6Z:  -0.00400000 Waves

2023.04.08 18:24 [2525759] smart account 3N9XFD2Yw3uN27NjudPVjNEGtvS6JJTxK6Z > SELF 0.00000000 Waves

{ "type": 13, "id": "846gzbT8G28437LLwHE5HNCbxBo1tMPtuAMXi4Sjixwv", "fee": 400000, "feeAssetId": null, "timestamp": 1680967478421, "version": 2, "chainId": 84, "sender": "3N9XFD2Yw3uN27NjudPVjNEGtvS6JJTxK6Z", "senderPublicKey": "49QuuedtSwEkoupQ2jEdBY8g6ePKegTkLaL8WDteNCHg", "proofs": [ "3UpDgsffMsiwBwdrDLfuAEzT1Xw2YBA7Eyn8QG4HLChY7TjkeawqTFkamd88yxXzCiJhZvwUVEHYSPJUuoLUGvHF" ], "script": "base64:BgIYCAISABIAEgASABIDCgEIEgASABIDCgEIGwAFV1JDSWQCLDU0dnV4WnBDcjJGYmJ3aDFUdTR5Nm5LVERMWlZwZGdNZGNWM2tzODFHWjdLAAtXUkNEZWNpbWFscwAGAAxXUkNUaHJlc2hvbGQJAGgCAKCNBgCAwtcvAA9XUkNUaHJlc2hvbGRMb2cJAGgCAAUAgMLXLwETdG90YWxTaGFyZUJ5VXNlcktFWQEFb3duZXIJALkJAgkAzAgCAgZzaGFyZXMJAMwIAgUFb3duZXIFA25pbAIBXwEUdG90YWxTaGFyZUJ5VXNlclJFQUQBBW93bmVyCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARN0b3RhbFNoYXJlQnlVc2VyS0VZAQUFb3duZXIAAAASdG90YWxJc3N1ZWRXUkNfS0VZAhB0b3RhbF9pc3N1ZWRfV1JDARN0b3RhbElzc3VlZFdSQ19SRUFEAAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBRJ0b3RhbElzc3VlZFdSQ19LRVkAAAAOdG90YWxTaGFyZXNLRVkCDHRvdGFsX3NoYXJlcwEP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YnVybmFibGVfd3JjAgQgV1JDBAx1bmxvY2tfd2F2ZXMJAGsDCAUDcG10BmFtb3VudACAwtcvCQEcd2F2ZXNSZWZlcmVuY2VQcmljZV9XUkNfUkVBRAAJAAIBCQCkAwEFDHVubG9ja193YXZlcwFpAQ10ZXN0X2dldF90bWRpAAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBC2dldFRNRElfV1JDAAFpARJ0ZXN0X2dldF91c2VyX3RtZGkBB2FjY291bnQJAAIBCQCsAgICCFJlc3VsdDogCQCkAwEJARFnZXRVc2VyVE1ESV9XQVZFUwEFB2FjY291bnQBaQESdGVzdF9nZXRfYmFzZV90bWR1AAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBFGdldE1heEJhc2VUTURVX1dBVkVTAAFpAQ10ZXN0X2dldF90bWR1AAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBDWdldFRNRFVfV0FWRVMAAWkBEnRlc3RfZ2V0X3VzZXJfdG1kdQEHYWNjb3VudAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBD2dldFVzZXJUTURVX1dSQwEFB2FjY291bnQA/7IawQ==", "height": 2525759, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: C9iAKsjde94Ysusy4eZF1jgMYrrM5TSNszsFEofe8qvZ Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let WRCId = "54vuxZpCr2Fbbwh1Tu4y6nKTDLZVpdgMdcV3ks81GZ7K"
5+
6+let WRCDecimals = 6
7+
8+let WRCThreshold = (100000 * 100000000)
9+
10+let WRCThresholdLog = (5 * 100000000)
11+
12+func totalShareByUserKEY (owner) = makeString(["shares", owner], "_")
13+
14+
15+func totalShareByUserREAD (owner) = valueOrElse(getInteger(this, totalShareByUserKEY(owner)), 0)
16+
17+
18+let totalIssuedWRC_KEY = "total_issued_WRC"
19+
20+func totalIssuedWRC_READ () = valueOrElse(getInteger(this, totalIssuedWRC_KEY), 0)
21+
22+
23+let totalSharesKEY = "total_shares"
24+
25+func totalSharesREAD () = valueOrElse(getInteger(this, totalSharesKEY), 0)
26+
27+
28+let totalNoShareCollateralKEY = "total_noshare_collateral"
29+
30+func totalNoShareCollateralREAD () = valueOrElse(getInteger(this, totalNoShareCollateralKEY), 0)
31+
32+
33+let INITIAL_PRICE = (2 * 1000000)
34+
35+let wavesReferencePrice_WRC_KEY = "waves_reference_price"
36+
37+func wavesReferencePrice_WRC_READ () = valueOrElse(getInteger(this, wavesReferencePrice_WRC_KEY), INITIAL_PRICE)
38+
39+
40+func userShareFraction_4 (owner) = {
41+ let totalShares = totalSharesREAD()
42+ if ((totalShares > 0))
43+ then {
44+ let totalUserShare = totalShareByUserREAD(owner)
45+ fraction(10000, totalUserShare, totalShares)
46+ }
47+ else 0
48+ }
49+
50+
51+let paramA_KEY = "A"
52+
53+func paramA_READ () = valueOrElse(getInteger(this, "A"), 100)
54+
55+
56+func computeLogTMDIR (issued_wrc,A) = (WRCThresholdLog - (log(issued_wrc, WRCDecimals, 10, 0, 6, HALFUP) * A))
57+
58+
59+func TMDIRmultiply (amount,issued_wrc,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wrc, A), 8, 8, HALFUP), 100000000)
60+
61+
62+func computeTMDI_WRC (issued_wrc,A) = if ((issued_wrc > WRCThreshold))
63+ then TMDIRmultiply(issued_wrc, issued_wrc, A)
64+ else WRCThreshold
65+
66+
67+func getTMDI_WRC () = computeTMDI_WRC(totalIssuedWRC_READ(), paramA_READ())
68+
69+
70+func getMaxBaseTMDU_WAVES () = TMDIRmultiply((totalNoShareCollateralREAD() * 10), totalIssuedWRC_READ(), paramA_READ())
71+
72+
73+func getTMDU_WAVES () = {
74+ let total_noshare_collateral = totalNoShareCollateralREAD()
75+ if ((total_noshare_collateral > 0))
76+ then {
77+ let max_base_unlockable_waves = getMaxBaseTMDU_WAVES()
78+ if ((total_noshare_collateral > max_base_unlockable_waves))
79+ then max_base_unlockable_waves
80+ else total_noshare_collateral
81+ }
82+ else 0
83+ }
84+
85+
86+func getUserTMDI_WAVES (owner) = fraction(getTMDI_WRC(), (1000 * userShareFraction_4(owner)), wavesReferencePrice_WRC_READ())
87+
88+
89+func getUserTMDU_WAVES (owner) = fraction(getTMDU_WAVES(), userShareFraction_4(owner), 10000)
90+
91+
92+func getUserTMDU_WRC (owner) = fraction(getUserTMDU_WAVES(owner), wavesReferencePrice_WRC_READ(), 100000000)
93+
94+
95+@Callable(i)
96+func deposit_share () = {
97+ let pmt = if ((size(i.payments) == 1))
98+ then i.payments[0]
99+ else throw("Attached payment is required")
100+ if (isDefined(pmt.assetId))
101+ then throw("Only WAVES is allowed.")
102+ else {
103+ let account = toString(i.caller)
104+ let totalShareByUser = totalShareByUserREAD(account)
105+ let totalShares = totalSharesREAD()
106+[IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount))]
107+ }
108+ }
109+
110+
111+
112+@Callable(i)
113+func issue () = {
114+ let pmt = if ((size(i.payments) == 1))
115+ then i.payments[0]
116+ else throw("Attached payment is required")
117+ if (isDefined(pmt.assetId))
118+ then throw("Only WAVES is allowed.")
119+ else {
120+ let account = toString(i.caller)
121+ let max_waves = getUserTMDI_WAVES(account)
122+ if ((pmt.amount > max_waves))
123+ then throw((((("User lock limit is " + toString(max_waves)) + " WAVES. Sent ") + toString(pmt.amount)) + " WAVES."))
124+ else {
125+ let wrc_issue_amount = fraction(pmt.amount, wavesReferencePrice_WRC_READ(), 100000000)
126+ let total_no_share_collateral = totalNoShareCollateralREAD()
127+ let total_issued = totalIssuedWRC_READ()
128+[IntegerEntry(totalNoShareCollateralKEY, (total_no_share_collateral + pmt.amount)), IntegerEntry(totalIssuedWRC_KEY, (total_issued + wrc_issue_amount)), ScriptTransfer(addressFromStringValue(account), wrc_issue_amount, fromBase58String(WRCId))]
129+ }
130+ }
131+ }
132+
133+
134+
135+@Callable(i)
136+func burn () = {
137+ let pmt = if ((size(i.payments) == 1))
138+ then i.payments[0]
139+ else throw("Attached payment is required")
140+ if ((pmt.assetId != fromBase58String(WRCId)))
141+ then throw("Only WRC is allowed.")
142+ else {
143+ let account = toString(i.caller)
144+ let max_burnable_wrc = getUserTMDU_WRC(account)
145+ if ((pmt.amount > max_burnable_wrc))
146+ then throw((("User burn limit: " + toString(max_burnable_wrc)) + " WRC"))
147+ else {
148+ let unlock_waves = fraction(pmt.amount, 100000000, wavesReferencePrice_WRC_READ())
149+ throw(toString(unlock_waves))
150+ }
151+ }
152+ }
153+
154+
155+
156+@Callable(i)
157+func test_get_tmdi () = throw(("Result: " + toString(getTMDI_WRC())))
158+
159+
160+
161+@Callable(i)
162+func test_get_user_tmdi (account) = throw(("Result: " + toString(getUserTMDI_WAVES(account))))
163+
164+
165+
166+@Callable(i)
167+func test_get_base_tmdu () = throw(("Result: " + toString(getMaxBaseTMDU_WAVES())))
168+
169+
170+
171+@Callable(i)
172+func test_get_tmdu () = throw(("Result: " + toString(getTMDU_WAVES())))
173+
174+
175+
176+@Callable(i)
177+func test_get_user_tmdu (account) = throw(("Result: " + toString(getUserTMDU_WRC(account))))
178+
179+

github/deemru/w8io/169f3d6 
35.71 ms