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