tx · JAkUNAc9ajxpH4av6EmcMe5nmjxv7VRLuD8KbrD8kNBa 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8: -0.00200000 Waves 2023.01.16 16:37 [2407570] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves
{ "type": 13, "id": "JAkUNAc9ajxpH4av6EmcMe5nmjxv7VRLuD8KbrD8kNBa", "fee": 200000, "feeAssetId": null, "timestamp": 1673876344316, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "4P41PfHi9bn45HjSbNQS3XwugYhvmCJ89U3kbVFxq52X4qfgz6ScXoGXT7SSDygKH4L1KCGWbY6Te7QBmK1nJmT3" ], "script": "base64:BgIJCAISABIDCgEIDwAFd2NkSWQCLDVXRTZIQlZzbUFiYXBUbVRLcG15V21VUjY3ZmMxNnliRnJOanh6bURCdFBhAAt3Y2REZWNpbWFscwACARN0b3RhbFNoYXJlQnlVc2VyS0VZAQVvd25lcgkAuQkCCQDMCAICBnNoYXJlcwkAzAgCBQVvd25lcgUDbmlsAgFfARR0b3RhbFNoYXJlQnlVc2VyUkVBRAEFb3duZXIJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwkBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBQVvd25lcgAAABJ0b3RhbElzc3VlZFdDRF9LRVkCEHRvdGFsX2lzc3VlZF9XQ0QBE3RvdGFsSXNzdWVkV0NEX1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFEnRvdGFsSXNzdWVkV0NEX0tFWQAAAA50b3RhbFNoYXJlc0tFWQIMdG90YWxfc2hhcmVzAQ90b3RhbFNoYXJlc1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFDnRvdGFsU2hhcmVzS0VZAAABEXVzZXJTaGFy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Y2NvdW50BAt0b3RhbFNoYXJlcwkBD3RvdGFsU2hhcmVzUkVBRAAJAMwIAgkBDEludGVnZXJFbnRyeQIJARN0b3RhbFNoYXJlQnlVc2VyS0VZAQUHYWNjb3VudAkAZAIFEHRvdGFsU2hhcmVCeVVzZXIIBQNwbXQGYW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCBQ50b3RhbFNoYXJlc0tFWQkAZAIFC3RvdGFsU2hhcmVzCAUDcG10BmFtb3VudAUDbmlsAWkBBHRlc3QBB2FjY291bnQJAAIBCQCsAgICCFJlc3VsdDogCQCkAwEJAQtnZXRVc2VyVE1ESQEFB2FjY291bnQA24VvZw==", "height": 2407570, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 26B55LK7guRV5gm2apmEAnEmnnihYWJUa88HNGsq9PoS Next: FBVd4PENSumhkVFNBJeFef4YhihRZbYyfiERu7Qc9cSg Diff:
Old | New | Differences | |
---|---|---|---|
48 | 48 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
49 | 49 | ||
50 | 50 | ||
51 | + | func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000) | |
52 | + | ||
53 | + | ||
51 | 54 | @Callable(i) | |
52 | 55 | func deposit_share () = { | |
53 | 56 | let pmt = if ((size(i.payments) == 1)) | |
66 | 69 | ||
67 | 70 | ||
68 | 71 | @Callable(i) | |
69 | - | func test (account) = throw(("Result: " + toString( | |
72 | + | func test (account) = throw(("Result: " + toString(getUserTMDI(account)))) | |
70 | 73 | ||
71 | 74 |
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 | func userShareFraction (owner) = { | |
25 | 25 | let totalShares = totalSharesREAD() | |
26 | 26 | if ((totalShares > 0)) | |
27 | 27 | then { | |
28 | 28 | let totalUserShare = totalShareByUserREAD(owner) | |
29 | 29 | fraction(100000000, totalUserShare, totalShares) | |
30 | 30 | } | |
31 | 31 | else 0 | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | let paramA_KEY = "A" | |
36 | 36 | ||
37 | 37 | func paramA_READ () = valueOrElse(getInteger(this, "A"), 100) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func computeLogTMDIR (issued_wcd,A) = (500000000 - (log(issued_wcd, wcdDecimals, 10, 0, 6, HALFUP) * A)) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000)) | |
44 | 44 | then fraction(issued_wcd, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000) | |
45 | 45 | else 10000000 | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
49 | 49 | ||
50 | 50 | ||
51 | + | func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000) | |
52 | + | ||
53 | + | ||
51 | 54 | @Callable(i) | |
52 | 55 | func deposit_share () = { | |
53 | 56 | let pmt = if ((size(i.payments) == 1)) | |
54 | 57 | then i.payments[0] | |
55 | 58 | else throw("Attached payment is required") | |
56 | 59 | if (isDefined(pmt.assetId)) | |
57 | 60 | then throw("Only WAVES is allowed.") | |
58 | 61 | else { | |
59 | 62 | let account = toString(i.caller) | |
60 | 63 | let totalShareByUser = totalShareByUserREAD(account) | |
61 | 64 | let totalShares = totalSharesREAD() | |
62 | 65 | [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount))] | |
63 | 66 | } | |
64 | 67 | } | |
65 | 68 | ||
66 | 69 | ||
67 | 70 | ||
68 | 71 | @Callable(i) | |
69 | - | func test (account) = throw(("Result: " + toString( | |
72 | + | func test (account) = throw(("Result: " + toString(getUserTMDI(account)))) | |
70 | 73 | ||
71 | 74 |
github/deemru/w8io/026f985 60.86 ms ◑