tx · 5MSbWY94Aq4PgE3kZYpzi4mo16bXbkdhVTdikmX9Ztgq

3Mx4hQdkpvhhG7HV1sbK5PU6ZGVTEL8xKJj:  -0.00200000 Waves

2022.11.13 20:49 [2315692] smart account 3Mx4hQdkpvhhG7HV1sbK5PU6ZGVTEL8xKJj > SELF 0.00000000 Waves

{ "type": 13, "id": "5MSbWY94Aq4PgE3kZYpzi4mo16bXbkdhVTdikmX9Ztgq", "fee": 200000, "feeAssetId": null, "timestamp": 1668361844120, "version": 1, "sender": "3Mx4hQdkpvhhG7HV1sbK5PU6ZGVTEL8xKJj", "senderPublicKey": "3YimckwWYL7DWQ9tzoWi2S8SmGQouVXcruupS5Xdn32c", "proofs": [ "2eJbpk2Hsg4wh9KjN1iqDJ2U8VedjH4TxE2yqbEmbvF3TtQG68SNo8HG6626feMEBADtPYRPD1L2jkLLnJb5oTBn" ], "script": "base64:BgIHCAISAwoBCAoAAVMCAl9fAANERUMAwIQ9AAZ1c2RuSWQJANkEAQkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzAgtjZmdfX3VzZG5JZAIsSGV6c2RRdVJEdHprc0FZVXk5N2dmaEt5N1oxTlcydVhZU0hBM2JncWVuTloBDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBBmdldFN0cgMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAnQgCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBCmtleVRlYW1DYXABCHRlYW1Db2RlCQC5CQIJAMwIAgIYJXMlc19fdGVhbUNhcGl0YWxpemF0aW9uCQDMCAIFCHRlYW1Db2RlBQNuaWwFAVMBCmtleVRlYW1Ua24BCHRlYW1Db2RlCQC5CQIJAMwIAgIQJX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MJAQprZXlUZWFtVGtuAQUIdGVhbUNvZGUEBXByaWNlAwkBAiE9AgUHdGVhbVRrbgAACQBrAwUHdGVhbUNhcAUDREVDBQd0ZWFtVGtuBQNERUMEDnRlYW1Ua25Gb3JVc2VyCQBrAwUGcG10QW10BQNERUMFBXByaWNlCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbUNhcAEFCHRlYW1Db2RlCQBkAgUHdGVhbUNhcAUGcG10QW10CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEKa2V5VGVhbVRrbgEFCHRlYW1Db2RlCQBkAgUHdGVhbVRrbgUOdGVhbVRrbkZvclVzZXIJAMwIAgkBDnVwZGF0ZVVzZXJUZWFtAwkBC2tleVVzZXJUZWFtAgUEdXNlcgUIdGVhbUNvZGUFDnRlYW1Ua25Gb3JVc2VyBQZwbXRBbXQFA25pbAAMrfXT", "chainId": 84, "height": 2315692, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 5yxjT88zqcecnJaMoTWpm53tY3eJuauTre8VbS9Cgg7w Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let S = "__"
5+
6+let DEC = 1000000
7+
8+let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
9+
10+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined"))
11+
12+
13+func getStr (address,key,default) = valueOrElse(getString(address, key), default)
14+
15+
16+func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S)
17+
18+
19+func keyTeamTkn (teamCode) = makeString(["%s%s__teamTokens", teamCode], S)
20+
21+
22+func keyUserTeam (user,teamCode) = makeString(["%s%s%s__userTeam", teamCode, user], S)
23+
24+
25+func updateUserTeam (key,teamTknDiff,investDiff) = {
26+ let data = split(getStr(this, key, "%d%d__0__0"), S)
27+ let teamTknAmtNew = toString((parseIntValue(data[1]) + teamTknDiff))
28+ let investUsdnNew = toString((parseIntValue(data[2]) + investDiff))
29+ StringEntry(key, makeString(["%d%d", teamTknAmtNew, investUsdnNew], S))
30+ }
31+
32+
33+func score (round,matchNum,homeTeamGoals,awayTeamGoals) = nil
34+
35+
36+@Callable(i)
37+func buyTeam (teamCode) = {
38+ let user = toString(i.caller)
39+ let pmt = i.payments[0]
40+ let pmtAmt = pmt.amount
41+ let pmtAssetId = pmt.assetId
42+ if ((size(i.payments) != 1))
43+ then throw("1 payment is expected")
44+ else if ((pmtAssetId != usdnId))
45+ then throw("invalid payment asset id")
46+ else {
47+ let teamCap = getIntOrFail(this, keyTeamCap(teamCode))
48+ let teamTkn = getIntOrFail(this, keyTeamTkn(teamCode))
49+ let price = if ((teamTkn != 0))
50+ then fraction(teamCap, DEC, teamTkn)
51+ else DEC
52+ let teamTknForUser = fraction(pmtAmt, DEC, price)
53+[IntegerEntry(keyTeamCap(teamCode), (teamCap + pmtAmt)), IntegerEntry(keyTeamTkn(teamCode), (teamTkn + teamTknForUser)), updateUserTeam(keyUserTeam(user, teamCode), teamTknForUser, pmtAmt)]
54+ }
55+ }
56+
57+

github/deemru/w8io/169f3d6 
30.42 ms