Phoenix-Protocol-Group / phoenix-contracts

Source code of the smart contracts of the Phoenix DeFi hub DEX protocol
GNU General Public License v3.0
10 stars 7 forks source link

Multihop: Add transaction chain validation #156

Closed ueco-jb closed 1 year ago

ueco-jb commented 1 year ago

When providing operations, we assume that client is sending them in format Token1->Token2, Token2->Token3, etc. We take next_offer_amount = simulate_swap.ask_amount blindly.

Add validation, that offer/ask asset of subsequent operation is a ask/offer of a previous one.

Valid:

[{
    "offer_asset": "token1",
    "ask_asset": "token2"
},
{
    "offer_asset": "token2",
    "ask_asset": "token3"
}]

Invalid:

[{
    "offer_asset": "token1",
    "ask_asset": "token2"
},
{
    "offer_asset": "token3",
    "ask_asset": "token2"
}]