The Elector smart contract:
https://github.com/ton-blockchain/ton/blob/040df63c9864f2f37ebe50c4cafcc01f2d5d2d5c/crypto/smartcont/elector-code.fc#L431-L457
hTON liquid staking protocol (disclosure: I'm the author):
https://github.com/HipoFinance/contract/blob/612e27fef6b641edfcc562ac9561c565ada8603d/contracts/treasury.fc#L1799-L1842
Follow some understanding and exploring, I think you can take a look in this: