Since the Unlocking Consumer Choice and Wireless Competition Law in 2014, carriers have made unlocking phones fair. Nowadays, when you sell your iPhone online, you will find your unlocked device is worth more than that locked with a carrier. Thus, there is no universal cost to unlock an iPhon...
OnePlus, Google and others will sell you a phone unlocked, and may even offer a discount if you have another device to trade in. It is worth mentioning that these discounts are often much lower than what a carrier might offer.