tx · Cn5Vz8MkuM4fVutgyYi8guu2yAYMoDSgMCZex1Csy8yh 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8: -0.00300000 Waves 2023.01.16 23:34 [2407981] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves
{ "type": 13, "id": "Cn5Vz8MkuM4fVutgyYi8guu2yAYMoDSgMCZex1Csy8yh", "fee": 300000, "feeAssetId": null, "timestamp": 1673901264386, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "SgGLMjDSiVw5rNA6wEMTdwarubAg2raidckNbzM3E9r8TF7vk6UNQPSrvzMXFm6DGurZ9atpx8SJmxDxvT2VFGz" ], "script": "base64:BgILCAISABIDCgEIEgAUAAV3Y2RJZAIsNVdFNkhCVnNtQWJhcFRtVEtwbXlXbVVSNjdmYzE2eWJGck5qeHptREJ0UGEAC3djZERlY2ltYWxzAAIBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBW93bmVyCQC5CQIJAMwIAgIGc2hhcmVzCQDMCAIFBW93bmVyBQNuaWwCAV8BFHRvdGFsU2hhcmVCeVVzZXJSRUFEAQVvd25lcgkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzCQETdG90YWxTaGFyZUJ5VXNlcktFWQEFBW93bmVyAAAAEnRvdGFsSXNzdWVkV0NEX0tFWQIQdG90YWxfaXNzdWVkX1dDRAETdG90YWxJc3N1ZWRXQ0RfUkVBRAAJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUSdG90YWxJc3N1ZWRXQ0RfS0VZAAAADnRvdGFsU2hhcmVzS0VZAgx0b3RhbF9zaGFyZXMBD3RvdGFsU2hhcmVzUkVBRAAJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUOdG90YWxTaGFyZXNLRVkAAAAS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CQCkAwEJAQdnZXRUTURVAADm0O2m", "height": 2407981, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3K9Li9Aa78jsBpLA96h865KrXmT6S8wSvRK8J95qezgZ Next: 9KdqPcwAza4QYSE1EYk4xvA1XXvfT7jxiyHANixsGPGV Diff:
Old | New | Differences | |
---|---|---|---|
56 | 56 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
57 | 57 | ||
58 | 58 | ||
59 | + | func getTMDU () = { | |
60 | + | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
61 | + | if ((diff > 0)) | |
62 | + | then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
63 | + | else 0 | |
64 | + | } | |
65 | + | ||
66 | + | ||
59 | 67 | func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000) | |
68 | + | ||
69 | + | ||
70 | + | func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000) | |
60 | 71 | ||
61 | 72 | ||
62 | 73 | @Callable(i) | |
83 | 94 | ||
84 | 95 | ||
85 | 96 | @Callable(i) | |
86 | - | func test_ii ( | |
97 | + | func test_ii () = throw(("Result: " + toString(getTMDU()))) | |
87 | 98 | ||
88 | 99 |
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 | 48 | func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000)) | |
52 | 52 | then TMDIRmultiply(issued_wcd, issued_wcd, A) | |
53 | 53 | else 10000000 | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ()) | |
57 | 57 | ||
58 | 58 | ||
59 | + | func getTMDU () = { | |
60 | + | let diff = (totalCollateralREAD() - totalSharesREAD()) | |
61 | + | if ((diff > 0)) | |
62 | + | then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ()) | |
63 | + | else 0 | |
64 | + | } | |
65 | + | ||
66 | + | ||
59 | 67 | func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000) | |
68 | + | ||
69 | + | ||
70 | + | func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000) | |
60 | 71 | ||
61 | 72 | ||
62 | 73 | @Callable(i) | |
63 | 74 | func deposit_share () = { | |
64 | 75 | let pmt = if ((size(i.payments) == 1)) | |
65 | 76 | then i.payments[0] | |
66 | 77 | else throw("Attached payment is required") | |
67 | 78 | if (isDefined(pmt.assetId)) | |
68 | 79 | then throw("Only WAVES is allowed.") | |
69 | 80 | else { | |
70 | 81 | let account = toString(i.caller) | |
71 | 82 | let totalShareByUser = totalShareByUserREAD(account) | |
72 | 83 | let totalShares = totalSharesREAD() | |
73 | 84 | let totalCollateral = totalCollateralREAD() | |
74 | 85 | [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))] | |
75 | 86 | } | |
76 | 87 | } | |
77 | 88 | ||
78 | 89 | ||
79 | 90 | ||
80 | 91 | @Callable(i) | |
81 | 92 | func test (account) = throw(("Result: " + toString(getUserTMDI(account)))) | |
82 | 93 | ||
83 | 94 | ||
84 | 95 | ||
85 | 96 | @Callable(i) | |
86 | - | func test_ii ( | |
97 | + | func test_ii () = throw(("Result: " + toString(getTMDU()))) | |
87 | 98 | ||
88 | 99 |
github/deemru/w8io/169f3d6 30.94 ms ◑