Closed roman-khimov closed 1 year ago
The entry script calls CCMS here (0x5ba6c543c5a86a85e9ab3f028a4ad849b924fab9) which unwraps its data, checks signatures and then calls the O3 bridge contract (0xcd2f899412624ffa90fba6c277d05de3f9e0ac0c) this way (bridgeIn
):
[
{
"type": "Array",
"value": [
{
"type": "Buffer",
"value": "FNX/YdBRitR9clw0xZQz0D9jpxRHFNYkvPrvlvofgiHEWcODRYwtyV5cPTiMjwvNIjoBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD9CwEDARTM26ZRQDnewpWIIhhWt1ZSD7veohSchGfG0lmfmf5Nf76YZrVZfRePRyS6VgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABRTV/2HQUYrUfXJcNMWUM9A/Y6cURxQg8L6kUK2nuQO4l0nXybvBYLFIzRQoqxh02keq2Cycs1GIVSeBUh8V8BQqTJpNQCJniwPvG74INPlmRg3ESBTPduKL0AYsSkeO41VhARMZ88+k0kQVXjMAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFNYkvPrvlvofgiHEWcODRYwtyV5ceJij+IgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
{
"type": "Buffer",
"value": "X4UX1gZYDTDDvyEPoBa4kWxoW+g="
},
{
"type": "Buffer",
"value": "EQAAAAAAAAA="
}
]
},
{
"type": "Integer",
"value": "15"
},
{
"type": "ByteString",
"value": "YnJpZGdlSW4="
},
{
"type": "ByteString",
"value": "DKzg+eNd0HfCpvuQ+k9iEpSJL80="
}
]
Bridge mints some O3-pegged fUSDT:
[
{
"type": "ByteString",
"value": "bWludCBwdG9rZW4gdG8gdXNlciBmYWlsZWQ="
},
{
"type": "Array",
"value": [
{
"type": "ByteString",
"value": "DKzg+eNd0HfCpvuQ+k9iEpSJL80="
},
{
"type": "ByteString",
"value": "D6LTRyrv/ARa0268Z0AS26eSmzo="
},
{
"type": "Integer",
"value": "22635880126654199869"
}
]
},
{
"type": "Integer",
"value": "15"
},
{
"type": "ByteString",
"value": "bWludA=="
},
{
"type": "ByteString",
"value": "1f9h0FGK1H1yXDTFlDPQP2OnFEc="
}
]
It goes to D6LTRyrv/ARa0268Z0AS26eSmzo=
/3a9b92a7db124067bc6ed35a04fcef2a47d3a20f
/NMLeNw7vzSLqR5Bbegsgj9wZ8qgV588XqH
:
{
"contract": "0x4714a7633fd03394c5345c727dd48a51d061ffd5",
"eventname": "Transfer",
"state": {
"type": "Array",
"value": [
{
"type": "Any"
},
{
"type": "ByteString",
"value": "D6LTRyrv/ARa0268Z0AS26eSmzo="
},
{
"type": "Integer",
"value": "22635880126654199869"
}
]
}
}
And executes the proxy contract (0x3a9b92a7db124067bc6ed35a04fcef2a47d3a20f/proxyCall):
[
{
"type": "ByteString",
"value": "ZXhlY3V0ZSBjYWxsRGF0YSB2aWEgY2FsbFByb3h5IGZhaWxlZA=="
},
{
"type": "Array",
"value": [
{
"type": "ByteString",
"value": "1f9h0FGK1H1yXDTFlDPQP2OnFEc="
},
{
"type": "ByteString",
"value": "1iS8+u+W+h+CIcRZw4NFjC3JXlw="
},
{
"type": "Integer",
"value": "22635880126654199869"
},
{
"type": "Buffer",
"value": "AwEUzNumUUA53sKViCIYVrdWUg+73qIUnIRnxtJZn5n+TX++mGa1WX0Xj0ckulYBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUU1f9h0FGK1H1yXDTFlDPQP2OnFEcUIPC+pFCtp7kDuJdJ18m7wWCxSM0UKKsYdNpHqtgsnLNRiFUngVIfFfAUKkyaTUAiZ4sD7xu+CDT5ZkYNxEgUz3bii9AGLEpHjuNVYQETGfPPpNJEFV4zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABTWJLz675b6H4IhxFnDg0WMLcleXHiYo/iIAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AA"
}
]
},
{
"type": "Integer",
"value": "15"
},
{
"type": "ByteString",
"value": "cHJveHlDYWxs"
},
{
"type": "ByteString",
"value": "D6LTRyrv/ARa0268Z0AS26eSmzo="
}
]
{
"returntype" : "Boolean",
"safe" : false,
"parameters" : [
{
"type" : "Hash160",
"name" : "ptoken"
},
{
"type" : "Hash160",
"name" : "receiver"
},
{
"name" : "amount",
"type" : "Integer"
},
{
"name" : "callData",
"type" : "ByteArray"
}
],
"name" : "proxyCall",
"offset" : 1821
},
Interesting... You've been invited to the relevant repo, hope it helps to find out the answer.
swapPToken
call of O3FlamingoAggregator
(0xa2debb0f5256b75618228895c2de394051a6dbcc
):
{
"type": "Array",
"value": [
{
"type": "Integer",
"value": "22635880126654199869"
},
{
"type": "ByteString",
"value": "nIRnxtJZn5n+TX++mGa1WX0Xj0c="
},
{
"type": "Integer",
"value": "22460964"
},
{
"type": "Array",
"value": [
{
"type": "ByteString",
"value": "1f9h0FGK1H1yXDTFlDPQP2OnFEc="
},
{
"type": "ByteString",
"value": "IPC+pFCtp7kDuJdJ18m7wWCxSM0="
},
{
"type": "ByteString",
"value": "KKsYdNpHqtgsnLNRiFUngVIfFfA="
},
{
"type": "ByteString",
"value": "KkyaTUAiZ4sD7xu+CDT5ZkYNxEg="
},
{
"type": "ByteString",
"value": "z3bii9AGLEpHjuNVYQETGfPPpNI="
}
]
},
{
"type": "Integer",
"value": "861803844"
},
{
"type": "ByteString",
"value": "1iS8+u+W+h+CIcRZw4NFjC3JXlw="
},
{
"type": "Integer",
"value": "1687798651000"
}
]
},
{
"type": "Integer",
"value": "15"
},
{
"type": "ByteString",
"value": "c3dhcFBUb2tlbg=="
},
{
"type": "ByteString",
"value": "zNumUUA53sKViCIYVrdWUg+73qI="
}
OK, there is an "Insufficient AmountOut" happening here, but it happens pretty late in the execution flow.
39799485 234fd7258cc35d7721b83237b665d7ecccf470f9 247 THROW
[
{
"type": "ByteString",
"value": "SW5zdWZmaWNpZW50IEFtb3VudE91dA=="
}
]
[
{
"Script": "5534853448628c89acfdba573cbd68abd7a38843",
"IP": 1222,
"NextIP": 1227,
"Caller": "0000000000000000000000000000000000000000"
},
{
"Script": "5ba6c543c5a86a85e9ab3f028a4ad849b924fab9",
"IP": 3810,
"NextIP": 3815,
"Caller": "5534853448628c89acfdba573cbd68abd7a38843"
},
{
"Script": "5ba6c543c5a86a85e9ab3f028a4ad849b924fab9",
"IP": 4623,
"NextIP": 4628,
"Caller": "5534853448628c89acfdba573cbd68abd7a38843"
},
{
"Script": "cd2f899412624ffa90fba6c277d05de3f9e0ac0c",
"IP": 4160,
"NextIP": 4165,
"Caller": "5ba6c543c5a86a85e9ab3f028a4ad849b924fab9"
},
{
"Script": "cd2f899412624ffa90fba6c277d05de3f9e0ac0c",
"IP": 4997,
"NextIP": 5002,
"Caller": "5ba6c543c5a86a85e9ab3f028a4ad849b924fab9"
},
{
"Script": "3a9b92a7db124067bc6ed35a04fcef2a47d3a20f",
"IP": 2257,
"NextIP": 2262,
"Caller": "cd2f899412624ffa90fba6c277d05de3f9e0ac0c"
},
{
"Script": "3a9b92a7db124067bc6ed35a04fcef2a47d3a20f",
"IP": 2929,
"NextIP": 2934,
"Caller": "cd2f899412624ffa90fba6c277d05de3f9e0ac0c"
},
{
"Script": "a2debb0f5256b75618228895c2de394051a6dbcc",
"IP": 1366,
"NextIP": 1371,
"Caller": "3a9b92a7db124067bc6ed35a04fcef2a47d3a20f"
},
{
"Script": "a2debb0f5256b75618228895c2de394051a6dbcc",
"IP": 1931,
"NextIP": 1936,
"Caller": "3a9b92a7db124067bc6ed35a04fcef2a47d3a20f"
},
{
"Script": "a2debb0f5256b75618228895c2de394051a6dbcc",
"IP": 118,
"NextIP": 123,
"Caller": "3a9b92a7db124067bc6ed35a04fcef2a47d3a20f"
},
{
"Script": "f970f4ccecd765b63732b821775dc38c25d74f23",
"IP": 3823,
"NextIP": 3828,
"Caller": "a2debb0f5256b75618228895c2de394051a6dbcc"
},
{
"Script": "f970f4ccecd765b63732b821775dc38c25d74f23",
"IP": 247,
"NextIP": 248,
"Caller": "a2debb0f5256b75618228895c2de394051a6dbcc"
}
]
It's an incorrect NeoGo behavior related to exception handling, confirmed now.
Regarding the application logic, as you can see we have some transfers still happening and the overall transaction result is HALT
(even though the swap failed in the end), can't say if this is a correct behavior here. But maybe it is, since bridge has to save its data and it mints/transfers things correctly.
It's an incorrect NeoGo behavior related to exception handling, confirmed now.
Regarding the application logic, as you can see we have some transfers still happening and the overall transaction result is
HALT
(even though the swap failed in the end), can't say if this is a correct behavior here. But maybe it is, since bridge has to save its data and it mints/transfers things correctly.
Yes this is expected behavior: ptoken minted on the destination chain, then sent to dex to do swap via aggregator, no matter if the swap reverted or not, it should not affect the cross-chain process, so it was wrapped in try cache logic, if failed, users got ptoken, if succeed, users got the swapped token.