tx · 7KgSYbDidQ1pC6WWZLTPHFsv2oYMaLdLx6BcXrkuVCGN

3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq:  -0.01000000 Waves

2024.03.04 14:41 [3003219] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves

{ "type": 13, "id": "7KgSYbDidQ1pC6WWZLTPHFsv2oYMaLdLx6BcXrkuVCGN", "fee": 1000000, "feeAssetId": null, "timestamp": 1709552501522, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "7rxmtPxhctKR95HDaTVgWUvnmMF3aJu1mFBz5H1bma1vP1P96cV7sTwiKJAA5Z4RiRPpxwP4AnhBLxyTGUWYbE3" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQgOABBhbW91bnRBc3NldElkS2V5Ag1hbW91bnRBc3NldElkAA9wcmljZUFzc2V0SWRLZXkCDHByaWNlQXNzZXRJZAAKZmVlUmF0ZUtleQIHZmVlUmF0ZQEKZ2V0QXNzZXRJZAENYXNzZXRJZFN0cmluZwMJAAACBQ1hc3NldElkU3RyaW5nAgVXQVZFUwUEdW5pdAkA2QQBBQ1hc3NldElkU3RyaW5nAQ9nZXRBc3NldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCaWQFByRtYXRjaDAJAPAHAgUEdGhpcwUCaWQICQDvBwEFBHRoaXMJYXZhaWxhYmxlABNhbW91bnRBc3NldElkU3RyaW5nCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRBhbW91bnRBc3NldElkS2V5AA1hbW91bnRBc3NldElkCQEKZ2V0QXNzZXRJZAEFE2Ftb3VudEFzc2V0SWRTdHJpbmcAEnByaWNlQXNzZXRJZFN0cmluZwkBEUBleH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WVBbW91bnQAAAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDBQdhZGRyZXNzBQpzZW5kQW1vdW50BQtzZW5kQXNzZXRJZAUDbmlsCQACAQIRYW1vdW50IGlzIHRvbyBsb3cJAJQKAgULc2VuZEFjdGlvbnMJAJYKBAUKc2VuZEFtb3VudAUJZmVlQW1vdW50BQtzZW5kQXNzZXRJZAUNdXNlclJlYWxQcmljZQkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgMBaQEEc3dhcAAJAQxzd2FwSW50ZXJuYWwCCAUBaQZjYWxsZXIFAWkBaQEKc3dhcE5vTGVzcwEJbWluQW1vdW50BAskdDAyODIwMjg3MgkBDHN3YXBJbnRlcm5hbAIIBQFpBmNhbGxlcgUBaQQLc2VuZEFjdGlvbnMIBQskdDAyODIwMjg3MgJfMQQFdHVwbGUIBQskdDAyODIwMjg3MgJfMgQLJHQwMjg3NzI5NDAFBXR1cGxlBApzZW5kQW1vdW50CAULJHQwMjg3NzI5NDACXzEECWZlZUFtb3VudAgFCyR0MDI4NzcyOTQwAl8yBAtzZW5kQXNzZXRJZAgFCyR0MDI4NzcyOTQwAl8zBA11c2VyUmVhbFByaWNlCAULJHQwMjg3NzI5NDACXzQDCQBmAgUJbWluQW1vdW50BQpzZW5kQW1vdW50CQACAQkAuQkCCQDMCAICGlByaWNlIHNsaXBwZWQuIG1pbkFtb3VudDogCQDMCAIJAKQDAQUJbWluQW1vdW50CQDMCAICDSBzd2FwQW1vdW50OiAJAMwIAgkApAMBBQpzZW5kQW1vdW50BQNuaWwCAAkAlAoCBQtzZW5kQWN0aW9ucwUFdHVwbGUBaQEHc3dhcEZvcgEHYWRkcmVzcwkBDHN3YXBJbnRlcm5hbAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFB2FkZHJlc3MFAWkALRU0jQ==", "height": 3003219, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EuyqCcEoAAFYgX74pS5AhjzCd3TKhprbrZ2irLWfNr8z Next: 2TXNUoCatBrgcHKhwMQcQstCekjbmLRbzv2i4wygavVN Diff:
OldNewDifferences
8888
8989
9090 @Callable(i)
91+func swapNoLess (minAmount) = {
92+ let $t028202872 = swapInternal(i.caller, i)
93+ let sendActions = $t028202872._1
94+ let tuple = $t028202872._2
95+ let $t028772940 = tuple
96+ let sendAmount = $t028772940._1
97+ let feeAmount = $t028772940._2
98+ let sendAssetId = $t028772940._3
99+ let userRealPrice = $t028772940._4
100+ if ((minAmount > sendAmount))
101+ then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
102+ else $Tuple2(sendActions, tuple)
103+ }
104+
105+
106+
107+@Callable(i)
91108 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
92109
93110
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let amountAssetIdKey = "amountAssetId"
55
66 let priceAssetIdKey = "priceAssetId"
77
88 let feeRateKey = "feeRate"
99
1010 func getAssetId (assetIdString) = if ((assetIdString == "WAVES"))
1111 then unit
1212 else fromBase58String(assetIdString)
1313
1414
1515 func getAssetBalance (assetId) = match assetId {
1616 case id: ByteVector =>
1717 assetBalance(this, id)
1818 case _ =>
1919 wavesBalance(this).available
2020 }
2121
2222
2323 let amountAssetIdString = getStringValue(this, amountAssetIdKey)
2424
2525 let amountAssetId = getAssetId(amountAssetIdString)
2626
2727 let priceAssetIdString = getStringValue(this, priceAssetIdKey)
2828
2929 let priceAssetId = getAssetId(priceAssetIdString)
3030
3131 let SCALE8 = 100000000
3232
3333 let feeRate = valueOrElse(getInteger(this, feeRateKey), 200000)
3434
3535 func calcRawSendAmount (initAmBal,initPrBal,paymentAmount) = {
3636 let newPrBal = (initPrBal + paymentAmount)
3737 let newAmBal = fraction(initAmBal, initPrBal, newPrBal)
3838 let sendAmount = (initAmBal - newAmBal)
3939 sendAmount
4040 }
4141
4242
4343 func calcSendAmount (paymentAssetId,paymentAmount) = {
4444 let $t012301382 = if ((paymentAssetId == amountAssetId))
4545 then $Tuple2(priceAssetId, amountAssetId)
4646 else $Tuple2(amountAssetId, priceAssetId)
4747 let amAssetId = $t012301382._1
4848 let prAssetId = $t012301382._2
4949 let initAmBal = getAssetBalance(amAssetId)
5050 let initPrBal = (getAssetBalance(prAssetId) - paymentAmount)
5151 let rawSendAmount = calcRawSendAmount(initAmBal, initPrBal, paymentAmount)
5252 let feeAmount = fraction(rawSendAmount, feeRate, SCALE8)
5353 let sendAmount = (rawSendAmount - feeAmount)
5454 let userRealPrice = if ((paymentAssetId == amountAssetId))
5555 then fraction(sendAmount, SCALE8, paymentAmount)
5656 else fraction(paymentAmount, SCALE8, sendAmount)
5757 $Tuple4(sendAmount, feeAmount, amAssetId, userRealPrice)
5858 }
5959
6060
6161 func swapInternal (address,i) = {
6262 let checks = [if ((size(i.payments) > 0))
6363 then true
6464 else throw("should be with 1 payment"), if (containsElement([amountAssetId, priceAssetId], i.payments[0].assetId))
6565 then true
6666 else throw(makeString(["payment assetId should be", amountAssetIdString, "or", priceAssetIdString], " "))]
6767 if ((checks == checks))
6868 then {
6969 let paymentAssetId = i.payments[0].assetId
7070 let paymentAmount = i.payments[0].amount
7171 let $t023592462 = calcSendAmount(paymentAssetId, paymentAmount)
7272 let sendAmount = $t023592462._1
7373 let feeAmount = $t023592462._2
7474 let sendAssetId = $t023592462._3
7575 let userRealPrice = $t023592462._4
7676 let sendActions = if ((feeAmount > 0))
7777 then [ScriptTransfer(address, sendAmount, sendAssetId)]
7878 else throw("amount is too low")
7979 $Tuple2(sendActions, $Tuple4(sendAmount, feeAmount, sendAssetId, userRealPrice))
8080 }
8181 else throw("Strict value is not equal to itself.")
8282 }
8383
8484
8585 @Callable(i)
8686 func swap () = swapInternal(i.caller, i)
8787
8888
8989
9090 @Callable(i)
91+func swapNoLess (minAmount) = {
92+ let $t028202872 = swapInternal(i.caller, i)
93+ let sendActions = $t028202872._1
94+ let tuple = $t028202872._2
95+ let $t028772940 = tuple
96+ let sendAmount = $t028772940._1
97+ let feeAmount = $t028772940._2
98+ let sendAssetId = $t028772940._3
99+ let userRealPrice = $t028772940._4
100+ if ((minAmount > sendAmount))
101+ then throw(makeString(["Price slipped. minAmount: ", toString(minAmount), " swapAmount: ", toString(sendAmount)], ""))
102+ else $Tuple2(sendActions, tuple)
103+ }
104+
105+
106+
107+@Callable(i)
91108 func swapFor (address) = swapInternal(addressFromStringValue(address), i)
92109
93110

github/deemru/w8io/169f3d6 
23.47 ms