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