What is a smart contract?
A smart contract is program code deployed to a blockchain. It can hold assets and execute rules when transactions call its functions.
A swap contract can receive tokens, calculate an exchange and send assets according to its programmed logic.