FixedFi is a DeFi protocol built using CosmWasm contracts that lets anyone access to fixed yield on their assets.
Split a yield bearing asset into principle token (pToken) and yield token (yToken) and yToken can be sold at a fixed price to fix the future yield and to get it now.
Users can even buy the pToken at discount w.r.t. undelying asset to get fixed yield without holding a yield bearing asset or having exposure to the yield or source of yield (the protocol).
Name | Description |
---|---|
mars-adapter |
Deposits asset into red bank and issues ybToken |
splitter |
Splits ybToken into pToken and yToken and vice-versa |
market |
Market contract (uses stableswap) |
Name | Description |
---|---|
native-stake |
Rewards accured to each user |
native-stake-external-rewards |
Stakes external rewards (yield earned) |
- User holds a native token (eg.
osmo
), and deposits it into a yield generating protocol (eg. mars-adapter). - Yield Bearing Token (ybT) is issued against the "deposited" native token
osmo
. Eg.ybOsmoMars
- Then yield bearing token is deposited into the splitter contract.
- Splitter splits the ybT into
principleToken
(pT
) andyieldToken
(yT
). Eg.pOsmoMars
+yOsmoMars
.
(yield accumulation + distribution flow)
- Yield Token (
yT
) is deposited into the stake-native contracts. This contract keeps track of yT against each user. - Also, over time, yield (rewards) will be accumulated against the yield bearing token. These rewards are deposited into the "native stake external" contract every epoch (set to 24 hrs).
- To distribute these accumulated rewards, they're deposited into the stake-native contract.
- Finally, user can claim the rewards (original yield + accumulated rewards overtime) by interacting with the
stake-native
contract.
(market making)
- Yield Bearing Token ybT (step 2), and Principal Token pT (step 4) are deposited into the Market contract which creates a pool of
pT + ybT
. - User can swap b/w Principle Token, Yield Token and Yield Bearing Token (
pT
<->yT
<->ybT
) by interacting (deposit, withdraw) with the market contract. - The market contract internally uses stableswap contract to factilitate the swaps. This is explained in the below sections in more detail.
- A ybToken got from depositing Token to a yield generating DeFi protocol.
- Deposit ybToken into FixedFi to get pToken and yToken for fixed duration (example: 6 months).
- yToken represents the yield for the next 6 months which is variable.
- pToken represents the underlying asset locked up for 6 months.
- Sell the yToken at current market price through the AMM and fix the amount of yield for next 6 months.
- After 6 months unlock the underlying token from pToken.
- Instead of buying the asset, buy the pToken of that asset.
- pToken in the AMM is always at a dicount from underlying asset.
- The discount is due to lockup period (example 6 months) and separation of yield for that period.
- Directly buying pToken fixes the discount, hence fixing the yield on that asset for next 6 months.
- After 6 months, unlock the asset from the pToken.
- As time progresses, the price of pToken will steadily increase and will match the underlying at expiry.
- The amount of discount is proportional to the expected yield which is seprated using yToken.
- yToken is selling at a fixed price at a time through the AMM.
- The price represents the average yield over lock time that market expects.
- If user belives that the yield can go up in future that buying the yToken can give a positive APR.
- Buying more of yToken gives higher exposure to the future variable yield.
Use this command to compile your contracts:
$ wasmkit compile
$ wasmkit run scripts/sample-script.ts
In scripts/
directory:
First of all you need to create an instance of your contract using contract name.
const contract = new Contract('sample-project');
// To deploy your contract
const deploy_response = await contract.deploy(account);
// To initialize your contract
await contract.instantiate({"count": 102}, "deploy test", account);
Note: You can check out your contract information in deploy_response
.
wasmkit
will load functions using schema, you can call contract functions using contract.tx
(to execute transactions) and contract.query
(to query from contract).
// To interact with your contract
// Execute contract function
await contract.tx.increment(account);
// View count in contract
await contract.query.get_count();