To calculate price differences on-chain one could generalize the first example to make a psuedo-exchange.
That is, have a bunch of coins on the BTC blockchain that are only spendable if coins go to a specific address on a separate chain.
That way the BTC/LTC price would simply be how low someone is willing to sell their BTC for in exchange for LTC.
I do however see a problem with divisibility here... I have to do some more thinking to figure that out.