tx · 7ehU1KsYqto7anEu4X7kGxQcbVkfUYazDoL3rnH2RFh2 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8: -0.00400000 Waves 2023.01.19 18:48 [2412010] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves
{ "type": 13, "id": "7ehU1KsYqto7anEu4X7kGxQcbVkfUYazDoL3rnH2RFh2", "fee": 400000, "feeAssetId": null, "timestamp": 1674143295952, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "35WTB2KYP8Q6QeHuhzXhhu5EXuKhZ3aN7sPgqyMEbEZS8MgMHwEvQ4ap5KBfN9aF1jnstB5dnPwuTFFRokypuqZx" ], "script": "base64:BgINCAISABIAEgMKAQgSABcABXdjZElkAiw1V0U2SEJWc21BYmFwVG1US3BteVdtVVI2N2ZjMTZ5YkZyTmp4em1EQnRQYQALd2NkRGVjaW1hbHMAAgETdG90YWxTaGFyZUJ5VXNlcktFWQEFb3duZXIJALkJAgkAzAgCAgZzaGFyZXMJAMwIAgUFb3duZXIFA25pbAIBXwEUdG90YWxTaGFyZUJ5VXNlclJFQUQBBW93bmVyCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARN0b3RhbFNoYXJlQnlVc2VyS0VZAQUFb3duZXIAAAASdG90YWxJc3N1ZWRXQ0RfS0VZAhB0b3RhbF9pc3N1ZWRfV0NEARN0b3RhbElzc3VlZFdDRF9SRUFEAAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBRJ0b3RhbElzc3VlZFdDRF9LRVkAAAAOdG90YWxTaGFyZXNLRVkCDHRvdGFsX3NoYXJlcwEPdG90YWxTaGFyZXNSRUFEAAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQ50b3RhbFNoYXJlc0tFWQAAABJ0b3Rh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YXRlcmFsS0VZCQBkAgUPdG90YWxDb2xsYXRlcmFsCAUDcG10BmFtb3VudAkAzAgCCQEMSW50ZWdlckVudHJ5AgUSdG90YWxJc3N1ZWRXQ0RfS0VZCQBkAgUMdG90YWxfaXNzdWVkBRB3Y2RfaXNzdWVfYW1vdW50CQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMJARFAZXh0ck5hdGl2ZSgxMDYyKQEFB2FjY291bnQFEHdjZF9pc3N1ZV9hbW91bnQJANkEAQUFd2NkSWQFA25pbAFpAQR0ZXN0AQdhY2NvdW50CQACAQkArAICAghSZXN1bHQ6IAkApAMBCQEPZ2V0VXNlclRNRFVfV0NEAQUHYWNjb3VudAFpAQd0ZXN0X2lpAAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBB2dldFRNRFUAAKUOXdo=", "height": 2412010, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ECDEmTEo5h1WjHTG2tNTRLrCQQ6orgDkoxgLHkLya1K9 Next: 7fu5kEaMSS29FR5mmZzKkLZGoex4MUgh7ZguvrPv2Nof Diff:
Old | New | Differences | |
---|---|---|---|
66 | 66 | func getTMDU () = { | |
67 | 67 | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | 68 | if ((diff > 0)) | |
69 | - | then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
69 | + | then { | |
70 | + | let max_theorical_unlockable_waves = TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
71 | + | if ((diff > max_theorical_unlockable_waves)) | |
72 | + | then max_theorical_unlockable_waves | |
73 | + | else diff | |
74 | + | } | |
70 | 75 | else 0 | |
71 | 76 | } | |
72 | 77 |
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 | 66 | func getTMDU () = { | |
67 | 67 | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
68 | 68 | if ((diff > 0)) | |
69 | - | then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
69 | + | then { | |
70 | + | let max_theorical_unlockable_waves = TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
71 | + | if ((diff > max_theorical_unlockable_waves)) | |
72 | + | then max_theorical_unlockable_waves | |
73 | + | else diff | |
74 | + | } | |
70 | 75 | else 0 | |
71 | 76 | } | |
72 | 77 | ||
73 | 78 | ||
74 | 79 | func getUserTMDI_WAVES (owner) = (1000000 * fraction(getTMDI(), userShareFraction(owner), wavesReferencePrice_READ())) | |
75 | 80 | ||
76 | 81 | ||
77 | 82 | func getUserTMDU_WCD (owner) = fraction(fraction(getTMDU(), userShareFraction(owner), 100000000), wavesReferencePrice_READ(), 100000000) | |
78 | 83 | ||
79 | 84 | ||
80 | 85 | @Callable(i) | |
81 | 86 | func deposit_share () = { | |
82 | 87 | let pmt = if ((size(i.payments) == 1)) | |
83 | 88 | then i.payments[0] | |
84 | 89 | else throw("Attached payment is required") | |
85 | 90 | if (isDefined(pmt.assetId)) | |
86 | 91 | then throw("Only WAVES is allowed.") | |
87 | 92 | else { | |
88 | 93 | let account = toString(i.caller) | |
89 | 94 | let totalShareByUser = totalShareByUserREAD(account) | |
90 | 95 | let totalShares = totalSharesREAD() | |
91 | 96 | let totalCollateral = totalCollateralREAD() | |
92 | 97 | [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))] | |
93 | 98 | } | |
94 | 99 | } | |
95 | 100 | ||
96 | 101 | ||
97 | 102 | ||
98 | 103 | @Callable(i) | |
99 | 104 | func issue () = { | |
100 | 105 | let pmt = if ((size(i.payments) == 1)) | |
101 | 106 | then i.payments[0] | |
102 | 107 | else throw("Attached payment is required") | |
103 | 108 | if (isDefined(pmt.assetId)) | |
104 | 109 | then throw("Only WAVES is allowed.") | |
105 | 110 | else { | |
106 | 111 | let account = toString(i.caller) | |
107 | 112 | let max_waves = getUserTMDI_WAVES(account) | |
108 | 113 | if ((pmt.amount > max_waves)) | |
109 | 114 | then throw((((("User lock limit is " + toString(max_waves)) + " WAVES. Sent ") + toString(pmt.amount)) + " WAVES.")) | |
110 | 115 | else { | |
111 | 116 | let wcd_issue_amount = fraction(pmt.amount, wavesReferencePrice_READ(), 100000000000000) | |
112 | 117 | let totalCollateral = totalCollateralREAD() | |
113 | 118 | let total_issued = totalIssuedWCD_READ() | |
114 | 119 | [IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount)), IntegerEntry(totalIssuedWCD_KEY, (total_issued + wcd_issue_amount)), ScriptTransfer(addressFromStringValue(account), wcd_issue_amount, fromBase58String(wcdId))] | |
115 | 120 | } | |
116 | 121 | } | |
117 | 122 | } | |
118 | 123 | ||
119 | 124 | ||
120 | 125 | ||
121 | 126 | @Callable(i) | |
122 | 127 | func test (account) = throw(("Result: " + toString(getUserTMDU_WCD(account)))) | |
123 | 128 | ||
124 | 129 | ||
125 | 130 | ||
126 | 131 | @Callable(i) | |
127 | 132 | func test_ii () = throw(("Result: " + toString(getTMDU()))) | |
128 | 133 | ||
129 | 134 |
github/deemru/w8io/169f3d6 109.21 ms ◑