To buy cubeBTC (a long leveraged token), you deposit ETH into the pool. If the price of BTC goes up 1%, your pool share goes up 3%. If the price of BTC goes down 1%, your pool share goes down 3%. So as BTC moves, the value of your cubeBTC moves roughly 3x as much.
Inverse cube tokens like invBTC work the other way round, and move the opposite direction of cubeBTC. If the price of BTC goes up 1%, your pool share goes down 3%. If the price of BTC goes down 1%, your pool share goes up 3%. So as BTC moves, the value of your invBTC moves roughly 3x as much in the opposite direction.
After a deposit/withdrawal, the pool shares are all normalized so that they sum to 100%. This means the pool always contains exactly enough to pay everyone out.
The smart contract code can be found here: https://github.com/charmfinance/cube-protocol/
Alice thinks BTC will go up so spends 10 ETH on cubeBTC. Bob thinks ETH will go down so spends 20 ETH on invETH. So in total, there’s 30 ETH in the pool and the values of Alice and Bob’s cube tokens has to always sum to 30 ETH.
Let’s say BTC goes up by 5% and ETH goes up by 10%. Theoretically Alice’s cubeBTC increases in value from 10 → 11.58 ETH (= 10 x 1.05³) and Bob’s invETH loses value from 20 → 15.02 ETH (= 20 / 1.1³).
The problem is the pool would now be worth 11.58 + 15.02 = 26.6 ETH, which is different from the actual balance of the pool of 30 ETH. The values are therefore normalized so that they sum up to the balance. So the value of Alice’s cube token becomes 11.58 x 30 / 26.6 = 13.06 ETH and Bob’s cube token becomes 15.02 x 30 / 26.6 = 16.94 ETH
A spreadsheet showing cube price calculations can be found below. It demonstrates how underlying price moves and total supply of cubes tokens affect cube token prices.