tx · 2jEweJXuiYX5zdXrsxjPp6Y7ub6HcqHtev8tiaS7QgoR

3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b:  -0.03700000 Waves

2023.05.27 12:13 [2596170] smart account 3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b > SELF 0.00000000 Waves

{ "type": 13, "id": "2jEweJXuiYX5zdXrsxjPp6Y7ub6HcqHtev8tiaS7QgoR", "fee": 3700000, "feeAssetId": null, "timestamp": 1685178829999, "version": 2, "chainId": 84, "sender": "3N7psESThHV5T7gjWF2DLjztWtrhTF6FR3b", "senderPublicKey": "AgUKubvVDHDimcoQ6a6GnnzKdymyp2NYJRnjDFhiyM4e", "proofs": [ "3MWqZ3AfmNiGEmDz9fkP1zAYAi7cHPHxc8ZYGQXZwwWptdZD3C9qLfgNnVqwcozxq1gfZ98FgRjCjeNgHVgKeHv5" ], "script": "base64:BgIdCAISBgoECAgICBIECgIIARIFCgMICAgSBAoCCAgKAA1rX2luaXRpYWxpemVkAg1rX2luaXRpYWxpemVkABRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIUa19jb29yZGluYXRvckFkZHJlc3MAD2tfYWRtaW5fYWRkcmVzcwIPa19hZG1pbl9hZGRyZXNzAAhrX21hcmtldAIIa19tYXJrZXQBDGdldE1hcmtldEtleQIFX2Zyb20DX3RvCQCsAgIJAKwCAgkArAICCQCsAgIFCGtfbWFya2V0AgFfBQVfZnJvbQIBXwUDX3RvAQtjb29yZGluYXRvcgAJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkApggBCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUUa19jb29yZGluYXRvckFkZHJlc3MCGENvb3JkaW5hdG9yIG5vdCBzZXQgU3dhcAIbQ29vcmRpbmF0b3IgYWRkcmVzcyBpbnZhbGlkAQxhZG1pbkFkZHJlc3MACQCmCAEJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCCQELY29vcmRpbmF0b3IABQ9rX2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CAgkArAICCQCsAgICB3N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleVns/ug=", "height": 2596170, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DdEJRFzxpRx4tA46mbGapGbrcLHV3GEs8wYpADiackLa Next: none Diff:
OldNewDifferences
2121 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
2222
2323
24+func assetName (_asset) = if ((_asset == "WAVES"))
25+ then "WAVES"
26+ else value(assetInfo(fromBase58String(_asset))).name
27+
28+
2429 func getMarket (_from,_to) = {
2530 let key = getMarketKey(_from, _to)
26- let fromName = value(assetInfo(fromBase58String(_from))).name
27- let toName = value(assetInfo(fromBase58String(_to))).name
31+ let fromName = assetName(_from)
32+ let toName = assetName(_to)
2833 let errorDesc = (((((((_from + " [") + fromName) + "] -> ") + _to) + " [") + toName) + "]")
2934 let addressStr = valueOrErrorMessage(getString(this, key), ("No market for swap: " + errorDesc))
3035 valueOrErrorMessage(addressFromString(addressStr), ("Invalid market address for swap: " + errorDesc))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_initialized = "k_initialized"
55
66 let k_coordinatorAddress = "k_coordinatorAddress"
77
88 let k_admin_address = "k_admin_address"
99
1010 let k_market = "k_market"
1111
1212 func getMarketKey (_from,_to) = ((((k_market + "_") + _from) + "_") + _to)
1313
1414
1515 func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set Swap")), "Coordinator address invalid")
1616
1717
1818 func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
1919
2020
2121 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
2222
2323
24+func assetName (_asset) = if ((_asset == "WAVES"))
25+ then "WAVES"
26+ else value(assetInfo(fromBase58String(_asset))).name
27+
28+
2429 func getMarket (_from,_to) = {
2530 let key = getMarketKey(_from, _to)
26- let fromName = value(assetInfo(fromBase58String(_from))).name
27- let toName = value(assetInfo(fromBase58String(_to))).name
31+ let fromName = assetName(_from)
32+ let toName = assetName(_to)
2833 let errorDesc = (((((((_from + " [") + fromName) + "] -> ") + _to) + " [") + toName) + "]")
2934 let addressStr = valueOrErrorMessage(getString(this, key), ("No market for swap: " + errorDesc))
3035 valueOrErrorMessage(addressFromString(addressStr), ("Invalid market address for swap: " + errorDesc))
3136 }
3237
3338
3439 @Callable(i)
3540 func initialize (_coordinator,_fromAssets,_toAssets,_markets) = if (if (initialized())
3641 then true
3742 else (i.caller != this))
3843 then throw("Unable to initialize")
3944 else {
4045 let fromAssets = split(_fromAssets, ",")
4146 let toAssets = split(_toAssets, ",")
4247 let markets = split(_markets, ",")
4348 if (if (if ((size(fromAssets) != size(toAssets)))
4449 then true
4550 else (size(fromAssets) != size(markets)))
4651 then true
4752 else (size(fromAssets) > 5))
4853 then throw("Unable to initialize: invalid assets / markets")
4954 else {
5055 func handle (_acc,_idx) = if ((_idx >= size(fromAssets)))
5156 then _acc
5257 else {
5358 let from = fromAssets[_idx]
5459 let to = toAssets[_idx]
5560 let market = markets[_idx]
5661 if (if (if ((from == ""))
5762 then true
5863 else (to == ""))
5964 then true
6065 else !(isDefined(addressFromString(market))))
6166 then throw(("Invalid market at index: " + toString(_idx)))
6267 else (_acc ++ [StringEntry(getMarketKey(from, to), market)])
6368 }
6469
6570 let doAddAllMarkets = {
6671 let $l = [0, 1, 2, 3, 4]
6772 let $s = size($l)
6873 let $acc0 = nil
6974 func $f0_1 ($a,$i) = if (($i >= $s))
7075 then $a
7176 else handle($a, $l[$i])
7277
7378 func $f0_2 ($a,$i) = if (($i >= $s))
7479 then $a
7580 else throw("List size exceeds 5")
7681
7782 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
7883 }
7984 ([StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), BooleanEntry(k_initialized, true)] ++ doAddAllMarkets)
8085 }
8186 }
8287
8388
8489
8590 @Callable(i)
8691 func swap (_to,_expected) = if (if (if (!(initialized()))
8792 then true
8893 else (size(i.payments) != 1))
8994 then true
9095 else (0 > _expected))
9196 then throw("Invalid swap params: payment count")
9297 else {
9398 let assetId = i.payments[0].assetId
9499 let from = if (isDefined(assetId))
95100 then toBase58String(value(assetId))
96101 else "WAVES"
97102 let market = getMarket(from, _to)
98103 let amountBeforeSwap = assetBalance(this, fromBase58String(_to))
99104 if ((amountBeforeSwap == amountBeforeSwap))
100105 then {
101106 let doSwap = invoke(market, "swap", [_to, _expected], i.payments)
102107 if ((doSwap == doSwap))
103108 then {
104109 let amountAfterSwap = assetBalance(this, fromBase58String(_to))
105110 if ((amountAfterSwap == amountAfterSwap))
106111 then {
107112 let delta = (amountAfterSwap - amountBeforeSwap)
108113 if ((delta == delta))
109114 then $Tuple2([ScriptTransfer(i.caller, delta, fromBase58String(_to))], delta)
110115 else throw("Strict value is not equal to itself.")
111116 }
112117 else throw("Strict value is not equal to itself.")
113118 }
114119 else throw("Strict value is not equal to itself.")
115120 }
116121 else throw("Strict value is not equal to itself.")
117122 }
118123
119124
120125
121126 @Callable(i)
122127 func addMarket (_from,_to,_market) = if (if (if (if (if (if ((i.caller != adminAddress()))
123128 then (i.caller != this)
124129 else false)
125130 then true
126131 else !(initialized()))
127132 then true
128133 else (_from == ""))
129134 then true
130135 else (_to == ""))
131136 then true
132137 else !(isDefined(addressFromString(_market))))
133138 then throw("Invalid addMarket params")
134139 else [StringEntry(getMarketKey(_from, _to), _market)]
135140
136141
137142
138143 @Callable(i)
139144 func removeMarket (_from,_to) = if (if (if (if ((i.caller != adminAddress()))
140145 then true
141146 else !(initialized()))
142147 then true
143148 else (_from == ""))
144149 then true
145150 else (_to == ""))
146151 then throw("Invalid addMarket params")
147152 else [DeleteEntry(getMarketKey(_from, _to))]
148153
149154
150155 @Verifier(tx)
151156 func verify () = {
152157 let coordinatorStr = getString(this, k_coordinatorAddress)
153158 if (isDefined(coordinatorStr))
154159 then {
155160 let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
156161 if (isDefined(admin))
157162 then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
158163 else throw("unable to verify: admin not set in coordinator")
159164 }
160165 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
161166 }
162167

github/deemru/w8io/026f985 
38.41 ms