Yes!
If you want to get into the deepest detail there are several decentralised perpetual futures exchanges.
Here are some open source codebases on Github:
https://github.com/vegaprotocol/vega
https://github.com/dydxprotocol/v4-chain/
https://github.com/gmx-io/gmx-synthetics
https://github.com/0xOstium/smart-contracts-public/
Vega is a stalled project, but they have good documentation: