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:BgIVCAISAwoBCBIDCgEIEgcKBQgICAEBEwABUwICX18AA0RFQwDAhD0BDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBDGdldFN0ck9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBBmdldEludAMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAmggCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBBmdldFN0cgMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAnQgCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBEmtleUNmZ1ByaWNlQXNzZXRJ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RrbgAACQBrAwUHdGVhbUNhcAUDREVDBQd0ZWFtVGtuBQNERUMEDnRlYW1Ua25Gb3JVc2VyCQBrAwUGcG10QW10BQNERUMFBXByaWNlCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbUNhcAEFCHRlYW1Db2RlCQBkAgUHdGVhbUNhcAUGcG10QW10CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbVRrbgEFCHRlYW1Db2RlCQBkAgUHdGVhbVRrbgUOdGVhbVRrbkZvclVzZXIJAMwIAgkBFXVwZGF0ZVVzZXJTaGFyZUluVGVhbQQFBHVzZXIFCHRlYW1Db2RlBQ50ZWFtVGtuRm9yVXNlcgUGcG10QW10CQDMCAIJARN1cGRhdGVUZWFtUmlza09uQnV5AgUIdGVhbUNvZGUFBnBtdEFtdAUDbmlsAWkBBXNjb3JlBQVyb3VuZAxob21lVGVhbUNvZGUMYXdheVRlYW1Db2RlDWhvbWVUZWFtR29hbHMNYXdheVRlYW1Hb2FscwUDbmlsABV3hto=", "chainId": 84, "height": 2322714, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BL8eoWqZtiChsm5EpinXgLTFJnGa6HHgSXe14uEPLJmX Next: 6z9Cgr8TuTMgUjKTpFiE9G5FZTvs8NxdokNtxJLcx5xA Diff:
OldNewDifferences
44 let S = "__"
55
66 let DEC = 1000000
7-
8-let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
97
108 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined"))
119
1816
1917 func getStr (address,key,default) = valueOrElse(getString(address, key), default)
2018
19+
20+func keyCfgPriceAssetId () = "%s%s__cfg__priceAsset"
21+
22+
23+let usdnId = fromBase58String(getStr(this, keyCfgPriceAssetId(), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
2124
2225 func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S)
2326
3841
3942
4043 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
4149
4250
4351 func calcRisks (round,pmt) = if ((round == 1))
7381
7482
7583 @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)
7694 func buyTeam (teamCode) = {
7795 let user = toString(i.caller)
7896 let pmt = i.payments[0]
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let S = "__"
55
66 let DEC = 1000000
7-
8-let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
97
108 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined"))
119
1210
1311 func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((toString(address) + ".") + key) + " is not defined"))
1412
1513
1614 func getInt (address,key,default) = valueOrElse(getInteger(address, key), default)
1715
1816
1917 func getStr (address,key,default) = valueOrElse(getString(address, key), default)
2018
19+
20+func keyCfgPriceAssetId () = "%s%s__cfg__priceAsset"
21+
22+
23+let usdnId = fromBase58String(getStr(this, keyCfgPriceAssetId(), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
2124
2225 func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S)
2326
2427
2528 func keyTeamTkn (teamCode) = makeString(["%s%s__teamTokens", teamCode], S)
2629
2730
2831 func keyTeamRnd (teamCode) = makeString(["%s%s__teamRound", teamCode], S)
2932
3033
3134 func keyTeamRisks (teamCode) = makeString(["%s%s__teamRisks", teamCode], S)
3235
3336
3437 func keyUserTeam (user,teamCode) = makeString(["%s%s%s__userTeam", teamCode, user], S)
3538
3639
3740 func dataTeamRisks (risk1,risk2,risk3,risk4) = makeString(["%d%d%d%d", risk1, risk2, risk3, risk4], S)
3841
3942
4043 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
4149
4250
4351 func calcRisks (round,pmt) = if ((round == 1))
4452 then $Tuple4((pmt / 3), (pmt / 3), (pmt / 3), 0)
4553 else if ((round == 2))
4654 then $Tuple4(0, (pmt / 2), (pmt / 2), 0)
4755 else if ((round == 3))
4856 then $Tuple4(0, 0, pmt, 0)
4957 else $Tuple4(0, 0, 0, pmt)
5058
5159
5260 func updateTeamRiskOnBuy (teamCode,pmt) = {
5361 let risksKey = keyTeamRisks(teamCode)
5462 let risksStr = getStr(this, risksKey, dataTeamRisks("0", "0", "0", "0"))
5563 let risksDat = split(risksStr, S)
5664 let teamRound = readTeamRnd(teamCode)
5765 let plusRisk = calcRisks(teamRound, pmt)
5866 let risk1 = toString((parseIntValue(risksDat[1]) + plusRisk._1))
5967 let risk2 = toString((parseIntValue(risksDat[2]) + plusRisk._2))
6068 let risk3 = toString((parseIntValue(risksDat[3]) + plusRisk._3))
6169 let risk4 = toString((parseIntValue(risksDat[4]) + plusRisk._4))
6270 StringEntry(risksKey, dataTeamRisks(risk1, risk2, risk3, risk4))
6371 }
6472
6573
6674 func updateUserShareInTeam (userAddress,teamCode,teamTknDiff,pmt) = {
6775 let key = keyUserTeam(userAddress, teamCode)
6876 let data = split(getStr(this, key, "%d%d__0__0"), S)
6977 let teamTknAmtNew = toString((parseIntValue(data[1]) + teamTknDiff))
7078 let investUsdnNew = toString((parseIntValue(data[2]) + pmt))
7179 StringEntry(key, makeString(["%d%d", teamTknAmtNew, investUsdnNew], S))
7280 }
7381
7482
7583 @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)
7694 func buyTeam (teamCode) = {
7795 let user = toString(i.caller)
7896 let pmt = i.payments[0]
7997 let pmtAmt = pmt.amount
8098 let pmtAssetId = pmt.assetId
8199 if ((size(i.payments) != 1))
82100 then throw("1 payment is expected")
83101 else if ((pmtAssetId != usdnId))
84102 then throw("invalid payment asset id")
85103 else {
86104 let teamCap = getIntOrFail(this, keyTeamCap(teamCode))
87105 let teamTkn = getIntOrFail(this, keyTeamTkn(teamCode))
88106 let price = if ((teamTkn != 0))
89107 then fraction(teamCap, DEC, teamTkn)
90108 else DEC
91109 let teamTknForUser = fraction(pmtAmt, DEC, price)
92110 [IntegerEntry(keyTeamCap(teamCode), (teamCap + pmtAmt)), IntegerEntry(keyTeamTkn(teamCode), (teamTkn + teamTknForUser)), updateUserShareInTeam(user, teamCode, teamTknForUser, pmtAmt), updateTeamRiskOnBuy(teamCode, pmtAmt)]
93111 }
94112 }
95113
96114
97115
98116 @Callable(i)
99117 func score (round,homeTeamCode,awayTeamCode,homeTeamGoals,awayTeamGoals) = nil
100118
101119

github/deemru/w8io/169f3d6 
29.48 ms