I'm aware of this question How to interact with router for swap transaction?
but mine is different.
How to swap a token for SOL or vise versa from within a Solana program/smart contract? That is, on-chain. How to interract with a router of either Raydium or SolDex? I haven't found any example of this.