tx · 2HihmDocLeyTiR7kShy6wCwEj4Ma5zHWuYAJBtp6FQiF 3MtC32eAy42jhwnHpfYCbUj11iUkXDQdYpt: -0.00400000 Waves 2022.11.18 18:06 [2322714] smart account 3MtC32eAy42jhwnHpfYCbUj11iUkXDQdYpt > SELF 0.00000000 Waves
{ "type": 13, "id": "2HihmDocLeyTiR7kShy6wCwEj4Ma5zHWuYAJBtp6FQiF", "fee": 400000, "feeAssetId": null, "timestamp": 1668784056086, "version": 1, "sender": "3MtC32eAy42jhwnHpfYCbUj11iUkXDQdYpt", "senderPublicKey": "3xUNfrYKuaZmnMzb6e9tKC4azGnvWZyLzeKdUgAeFFpV", "proofs": [ "2Ti9vKXPnNJj9WZqmVV7T6svMyqTYLVbe3M2tXzMCCxipNZvJX433eKtBEFNmto7jPPbxeManmyDnTPSVQQPtxpj" ], "script": "base64:BgIVCAISAwoBCBIDCgEIEgcKBQgICAEBEwABUwICX18AA0RFQwDAhD0BDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBDGdldFN0ck9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBBmdldEludAMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAmggCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBBmdldFN0cgMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAnQgCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBEmtleUNmZ1ByaWNlQXNzZXRJZ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rbgAACQBrAwUHdGVhbUNhcAUDREVDBQd0ZWFtVGtuBQNERUMEDnRlYW1Ua25Gb3JVc2VyCQBrAwUGcG10QW10BQNERUMFBXByaWNlCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbUNhcAEFCHRlYW1Db2RlCQBkAgUHdGVhbUNhcAUGcG10QW10CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbVRrbgEFCHRlYW1Db2RlCQBkAgUHdGVhbVRrbgUOdGVhbVRrbkZvclVzZXIJAMwIAgkBFXVwZGF0ZVVzZXJTaGFyZUluVGVhbQQFBHVzZXIFCHRlYW1Db2RlBQ50ZWFtVGtuRm9yVXNlcgUGcG10QW10CQDMCAIJARN1cGRhdGVUZWFtUmlza09uQnV5AgUIdGVhbUNvZGUFBnBtdEFtdAUDbmlsAWkBBXNjb3JlBQVyb3VuZAxob21lVGVhbUNvZGUMYXdheVRlYW1Db2RlDWhvbWVUZWFtR29hbHMNYXdheVRlYW1Hb2FscwUDbmlsABV3hto=", "chainId": 84, "height": 2322714, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BL8eoWqZtiChsm5EpinXgLTFJnGa6HHgSXe14uEPLJmX Next: 6z9Cgr8TuTMgUjKTpFiE9G5FZTvs8NxdokNtxJLcx5xA Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let S = "__" | |
5 | 5 | ||
6 | 6 | let DEC = 1000000 | |
7 | - | ||
8 | - | let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ")) | |
9 | 7 | ||
10 | 8 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined")) | |
11 | 9 | ||
18 | 16 | ||
19 | 17 | func getStr (address,key,default) = valueOrElse(getString(address, key), default) | |
20 | 18 | ||
19 | + | ||
20 | + | func keyCfgPriceAssetId () = "%s%s__cfg__priceAsset" | |
21 | + | ||
22 | + | ||
23 | + | let usdnId = fromBase58String(getStr(this, keyCfgPriceAssetId(), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ")) | |
21 | 24 | ||
22 | 25 | func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S) | |
23 | 26 | ||
38 | 41 | ||
39 | 42 | ||
40 | 43 | func readTeamRnd (teamCode) = getInt(this, keyTeamRnd(teamCode), 1) | |
44 | + | ||
45 | + | ||
46 | + | func checkSelfSender (i) = if ((this != i.caller)) | |
47 | + | then throw("not allowed") | |
48 | + | else true | |
41 | 49 | ||
42 | 50 | ||
43 | 51 | func calcRisks (round,pmt) = if ((round == 1)) | |
73 | 81 | ||
74 | 82 | ||
75 | 83 | @Callable(i) | |
84 | + | func init (priceAssetId) = { | |
85 | + | let checks = [checkSelfSender(i)] | |
86 | + | if ((checks == checks)) | |
87 | + | then [StringEntry("cfg__priceAsset", priceAssetId)] | |
88 | + | else throw("Strict value is not equal to itself.") | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | ||
93 | + | @Callable(i) | |
76 | 94 | func buyTeam (teamCode) = { | |
77 | 95 | let user = toString(i.caller) | |
78 | 96 | let pmt = i.payments[0] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let S = "__" | |
5 | 5 | ||
6 | 6 | let DEC = 1000000 | |
7 | - | ||
8 | - | let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ")) | |
9 | 7 | ||
10 | 8 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined")) | |
11 | 9 | ||
12 | 10 | ||
13 | 11 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((toString(address) + ".") + key) + " is not defined")) | |
14 | 12 | ||
15 | 13 | ||
16 | 14 | func getInt (address,key,default) = valueOrElse(getInteger(address, key), default) | |
17 | 15 | ||
18 | 16 | ||
19 | 17 | func getStr (address,key,default) = valueOrElse(getString(address, key), default) | |
20 | 18 | ||
19 | + | ||
20 | + | func keyCfgPriceAssetId () = "%s%s__cfg__priceAsset" | |
21 | + | ||
22 | + | ||
23 | + | let usdnId = fromBase58String(getStr(this, keyCfgPriceAssetId(), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ")) | |
21 | 24 | ||
22 | 25 | func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S) | |
23 | 26 | ||
24 | 27 | ||
25 | 28 | func keyTeamTkn (teamCode) = makeString(["%s%s__teamTokens", teamCode], S) | |
26 | 29 | ||
27 | 30 | ||
28 | 31 | func keyTeamRnd (teamCode) = makeString(["%s%s__teamRound", teamCode], S) | |
29 | 32 | ||
30 | 33 | ||
31 | 34 | func keyTeamRisks (teamCode) = makeString(["%s%s__teamRisks", teamCode], S) | |
32 | 35 | ||
33 | 36 | ||
34 | 37 | func keyUserTeam (user,teamCode) = makeString(["%s%s%s__userTeam", teamCode, user], S) | |
35 | 38 | ||
36 | 39 | ||
37 | 40 | func dataTeamRisks (risk1,risk2,risk3,risk4) = makeString(["%d%d%d%d", risk1, risk2, risk3, risk4], S) | |
38 | 41 | ||
39 | 42 | ||
40 | 43 | func readTeamRnd (teamCode) = getInt(this, keyTeamRnd(teamCode), 1) | |
44 | + | ||
45 | + | ||
46 | + | func checkSelfSender (i) = if ((this != i.caller)) | |
47 | + | then throw("not allowed") | |
48 | + | else true | |
41 | 49 | ||
42 | 50 | ||
43 | 51 | func calcRisks (round,pmt) = if ((round == 1)) | |
44 | 52 | then $Tuple4((pmt / 3), (pmt / 3), (pmt / 3), 0) | |
45 | 53 | else if ((round == 2)) | |
46 | 54 | then $Tuple4(0, (pmt / 2), (pmt / 2), 0) | |
47 | 55 | else if ((round == 3)) | |
48 | 56 | then $Tuple4(0, 0, pmt, 0) | |
49 | 57 | else $Tuple4(0, 0, 0, pmt) | |
50 | 58 | ||
51 | 59 | ||
52 | 60 | func updateTeamRiskOnBuy (teamCode,pmt) = { | |
53 | 61 | let risksKey = keyTeamRisks(teamCode) | |
54 | 62 | let risksStr = getStr(this, risksKey, dataTeamRisks("0", "0", "0", "0")) | |
55 | 63 | let risksDat = split(risksStr, S) | |
56 | 64 | let teamRound = readTeamRnd(teamCode) | |
57 | 65 | let plusRisk = calcRisks(teamRound, pmt) | |
58 | 66 | let risk1 = toString((parseIntValue(risksDat[1]) + plusRisk._1)) | |
59 | 67 | let risk2 = toString((parseIntValue(risksDat[2]) + plusRisk._2)) | |
60 | 68 | let risk3 = toString((parseIntValue(risksDat[3]) + plusRisk._3)) | |
61 | 69 | let risk4 = toString((parseIntValue(risksDat[4]) + plusRisk._4)) | |
62 | 70 | StringEntry(risksKey, dataTeamRisks(risk1, risk2, risk3, risk4)) | |
63 | 71 | } | |
64 | 72 | ||
65 | 73 | ||
66 | 74 | func updateUserShareInTeam (userAddress,teamCode,teamTknDiff,pmt) = { | |
67 | 75 | let key = keyUserTeam(userAddress, teamCode) | |
68 | 76 | let data = split(getStr(this, key, "%d%d__0__0"), S) | |
69 | 77 | let teamTknAmtNew = toString((parseIntValue(data[1]) + teamTknDiff)) | |
70 | 78 | let investUsdnNew = toString((parseIntValue(data[2]) + pmt)) | |
71 | 79 | StringEntry(key, makeString(["%d%d", teamTknAmtNew, investUsdnNew], S)) | |
72 | 80 | } | |
73 | 81 | ||
74 | 82 | ||
75 | 83 | @Callable(i) | |
84 | + | func init (priceAssetId) = { | |
85 | + | let checks = [checkSelfSender(i)] | |
86 | + | if ((checks == checks)) | |
87 | + | then [StringEntry("cfg__priceAsset", priceAssetId)] | |
88 | + | else throw("Strict value is not equal to itself.") | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | ||
93 | + | @Callable(i) | |
76 | 94 | func buyTeam (teamCode) = { | |
77 | 95 | let user = toString(i.caller) | |
78 | 96 | let pmt = i.payments[0] | |
79 | 97 | let pmtAmt = pmt.amount | |
80 | 98 | let pmtAssetId = pmt.assetId | |
81 | 99 | if ((size(i.payments) != 1)) | |
82 | 100 | then throw("1 payment is expected") | |
83 | 101 | else if ((pmtAssetId != usdnId)) | |
84 | 102 | then throw("invalid payment asset id") | |
85 | 103 | else { | |
86 | 104 | let teamCap = getIntOrFail(this, keyTeamCap(teamCode)) | |
87 | 105 | let teamTkn = getIntOrFail(this, keyTeamTkn(teamCode)) | |
88 | 106 | let price = if ((teamTkn != 0)) | |
89 | 107 | then fraction(teamCap, DEC, teamTkn) | |
90 | 108 | else DEC | |
91 | 109 | let teamTknForUser = fraction(pmtAmt, DEC, price) | |
92 | 110 | [IntegerEntry(keyTeamCap(teamCode), (teamCap + pmtAmt)), IntegerEntry(keyTeamTkn(teamCode), (teamTkn + teamTknForUser)), updateUserShareInTeam(user, teamCode, teamTknForUser, pmtAmt), updateTeamRiskOnBuy(teamCode, pmtAmt)] | |
93 | 111 | } | |
94 | 112 | } | |
95 | 113 | ||
96 | 114 | ||
97 | 115 | ||
98 | 116 | @Callable(i) | |
99 | 117 | func score (round,homeTeamCode,awayTeamCode,homeTeamGoals,awayTeamGoals) = nil | |
100 | 118 | ||
101 | 119 |
github/deemru/w8io/169f3d6 29.48 ms ◑