tx · 3z1v5LtRkNZpftPpgWANmAEStmqdNx3YZ1AjTUCtgWfX

3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7:  -0.00200000 Waves

2023.08.19 19:28 [2717725] smart account 3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7 > SELF 0.00000000 Waves

{ "type": 13, "id": "3z1v5LtRkNZpftPpgWANmAEStmqdNx3YZ1AjTUCtgWfX", "fee": 200000, "feeAssetId": null, "timestamp": 1692462594617, "version": 2, "chainId": 84, "sender": "3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7", "senderPublicKey": "4oVxBvsmoAhMaT1WhgSLcKFKX1NzwYxDaR89cAdGRGky", "proofs": [ "3MPL4p6bwUxSZ4zQzH5SYRkBkcDABJ5SBUHkKrvDTjEvsS2QJK5EYxorUjjwPEqYprj5ZgX3EwH9ZSBUufMFe9Wr" ], "script": "base64:BgIOCAISABIECgIIARIAEgAGAAVjaGFpbgkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkdEFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDABIITaerIIAz9O0bvKju6Lk7zJgt0LXfoHlqjUI/moD/+5AwkAAAIBAVQFByRtYXRjaDABIFWx2J9yh4Lv5eNbjawFq2XemkOhLxa7BfMat4el8cUYCQACAQINVW5rbm93biBjaGFpbgEKZml4ZWRQb2ludAIDdmFsCGRlY2ltYWxzBAZ0ZW5Qb3cJAGwGAAoAAAUIZGVjaW1hbHMAAAAABQRET1dOBAdsb3dQYXJ0CQCkAwEJAGoCBQN2YWwFBnRlblBvdwQGemVyb2VzCQCwAgIJAKQDAQUGdGVuUG93CQBkAgABCQCxAgEFB2xvd1BhcnQJAKwCAgkArAICCQCsAgIJAKQDAQkAaQIFA3ZhbAUGdGVuUG93AgEuBQZ6ZXJvZXMFB2xvd1BhcnQAD3piaWxsQXNzZXRJZEtleQINemJpbGxfYXNzZXRJZAAMemJpbGxBc3NldElkCQETdm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UIZGVzdEFkZHIFBmFtb3VudAULdXNkdEFzc2V0SWQFA25pbAFpAQpyZXR1cm5Vc2R0AAMJAQIhPQIJAJADAQgFAWkIcGF5bWVudHMAAQkAAgECImV4YWN0bHkgMSBwYXltZW50IG11c3QgYmUgYXR0YWNoZWQEA3BtdAkAkQMCCAUBaQhwYXltZW50cwAABANhbXQIBQNwbXQGYW1vdW50BApwbXRBc3NldElkCQETdmFsdWVPckVycm9yTWVzc2FnZQIIBQNwbXQHYXNzZXRJZAITVVNEVCBwYXltZW50cyBvbmx5IQMJAQIhPQIFCnBtdEFzc2V0SWQFC3VzZHRBc3NldElkCQACAQITVVNEVCBwYXltZW50cyBvbmx5IQQMaXNzdWVkQW1vdW50CQERQGV4dHJOYXRpdmUoMTA1NSkBBRR6YmlsbElzc3VlZEFtb3VudEtleQMJAGYCBQNhbXQFDGlzc3VlZEFtb3VudAkAAgEJAKwCAgkArAICCQCsAgIJAKwCAgIYQ2FuJ3QgcmV0dXJuIG1vcmUgVVNEVCAoCQEKZml4ZWRQb2ludAIFA2FtdAAGAhYpLCB0aGFuIGlzc3VlZCBaQklMTCAoCQEKZml4ZWRQb2ludAIFDGlzc3VlZEFtb3VudAAGAgEpCQDMCAIJAQRCdXJuAgUMemJpbGxBc3NldElkBQNhbXQJAMwIAgkBDEludGVnZXJFbnRyeQIFFHpiaWxsSXNzdWVkQW1vdW50S2V5CQBlAgUMaXNzdWVkQW1vdW50BQNhbXQFA25pbAFpARBnZXRGdW5kc1JFQURPTkxZAAMJAQIhPQIJAJADAQgFAWkIcGF5bWVudHMAAAkAAgECE05vIHBheW1lbnRzIGFsbG93ZWQEB2Z1bmRTdW0JAGQCCQDwBwIFBHRoaXMFC3VzZHRBc3NldElkCQDwBwIFBHRoaXMFDHpiaWxsQXNzZXRJZAkAlAoCBQNuaWwFB2Z1bmRTdW0AmTQtRQ==", "height": 2717725, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ehsc7HL5umkMKkM4FH3DM1VW1BYwDgCjXbndH7UMMMtY Next: GcvBRrUTjnLiYHkiPeMEyaCS57bPXLYYPa6bzfgW2Es4 Diff:
OldNewDifferences
1111 then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63'
1212 else throw("Unknown chain")
1313 }
14+
15+func fixedPoint (val,decimals) = {
16+ let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
17+ let lowPart = toString((val % tenPow))
18+ let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
19+ (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
20+ }
21+
1422
1523 let zbillAssetIdKey = "zbill_assetId"
1624
5563 then throw("USDT payments only!")
5664 else {
5765 let issuedAmount = getIntegerValue(zbillIssuedAmountKey)
58-[Burn(zbillAssetId, amt), IntegerEntry(zbillIssuedAmountKey, (issuedAmount - amt))]
66+ if ((amt > issuedAmount))
67+ then throw((((("Can't return more USDT (" + fixedPoint(amt, 6)) + "), than issued ZBILL (") + fixedPoint(issuedAmount, 6)) + ")"))
68+ else [Burn(zbillAssetId, amt), IntegerEntry(zbillIssuedAmountKey, (issuedAmount - amt))]
5969 }
6070 }
6171
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let chain = take(drop(this.bytes, 1), 1)
55
66 let usdtAssetId = match chain {
77 case _ =>
88 if ((base58'2W' == $match0))
99 then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi'
1010 else if ((base58'2T' == $match0))
1111 then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63'
1212 else throw("Unknown chain")
1313 }
14+
15+func fixedPoint (val,decimals) = {
16+ let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
17+ let lowPart = toString((val % tenPow))
18+ let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
19+ (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
20+ }
21+
1422
1523 let zbillAssetIdKey = "zbill_assetId"
1624
1725 let zbillAssetId = valueOrErrorMessage(getBinary(this, zbillAssetIdKey), "Not initialized yet")
1826
1927 let zbillIssuedAmountKey = "zbill_issuedAmount"
2028
2129 @Callable(i)
2230 func constructorV1 () = if ((i.caller != this))
2331 then throw("Permission denied")
2432 else if (isDefined(getBinary(zbillAssetIdKey)))
2533 then throw("Already initialized")
2634 else {
2735 let issuedAmount = 0
2836 let issue = Issue("ZBILL", "USDT Bill of Exchange token", issuedAmount, 6, true, unit, 0)
2937 let assetId = calculateAssetId(issue)
3038 [issue, IntegerEntry(zbillIssuedAmountKey, issuedAmount), BinaryEntry(zbillAssetIdKey, assetId)]
3139 }
3240
3341
3442
3543 @Callable(i)
3644 func takeUsdt (destAddr,amount) = if ((i.caller != this))
3745 then throw("permission denied")
3846 else if ((size(i.payments) != 0))
3947 then throw("No payments allowed")
4048 else {
4149 let issuedAmount = getIntegerValue(zbillIssuedAmountKey)
4250 [Reissue(zbillAssetId, amount, true), IntegerEntry(zbillIssuedAmountKey, (issuedAmount + amount)), ScriptTransfer(addressFromStringValue(destAddr), amount, usdtAssetId)]
4351 }
4452
4553
4654
4755 @Callable(i)
4856 func returnUsdt () = if ((size(i.payments) != 1))
4957 then throw("exactly 1 payment must be attached")
5058 else {
5159 let pmt = i.payments[0]
5260 let amt = pmt.amount
5361 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "USDT payments only!")
5462 if ((pmtAssetId != usdtAssetId))
5563 then throw("USDT payments only!")
5664 else {
5765 let issuedAmount = getIntegerValue(zbillIssuedAmountKey)
58-[Burn(zbillAssetId, amt), IntegerEntry(zbillIssuedAmountKey, (issuedAmount - amt))]
66+ if ((amt > issuedAmount))
67+ then throw((((("Can't return more USDT (" + fixedPoint(amt, 6)) + "), than issued ZBILL (") + fixedPoint(issuedAmount, 6)) + ")"))
68+ else [Burn(zbillAssetId, amt), IntegerEntry(zbillIssuedAmountKey, (issuedAmount - amt))]
5969 }
6070 }
6171
6272
6373
6474 @Callable(i)
6575 func getFundsREADONLY () = if ((size(i.payments) != 0))
6676 then throw("No payments allowed")
6777 else {
6878 let fundSum = (assetBalance(this, usdtAssetId) + assetBalance(this, zbillAssetId))
6979 $Tuple2(nil, fundSum)
7080 }
7181
7282

github/deemru/w8io/026f985 
21.30 ms