This Deno program queries MARS Redbank and Incentives contracts to calculate incentives yield percentage for the given asset denom.
Note that passed denom should already be enabled in the contracts in order to program to be complete.
In default, program works with osmosis mainnet network contracts. Network and contracts can be changed by updating RPC_URL
and CONTRACT_ADDRESS
in the constants.ts
.
Also, asset denom set to uosmo
which can be altered in the main.ts
file.
-
Install Deno: https://deno.com/[email protected]/getting_started/installation
curl -fsSL https://deno.land/x/install/install.sh | sh
-
Run the program
deno run --allow-read --allow-net main.ts
Depositing into a OSMO market that has:
- base liquidity rate of 10% (what borrowers are paying depositors)
- incentive scheme setup where MARS is issued at 100000 umars per second
- total liquidity in pool of 2,000,000 OSMO
Step 1: Calculate the normal returns on osmo = 2m OSMO * 0.1 = 200k OSMO
Step 2: Calculate the incentive returns in MARS = (31,540,000 seconds * 100000 umars) / 1e6 = 3,154,000 MARS a year
Step 3: Convert incentives rewards to base asset = MARS/OSMO rate currently is ~ 0.13. 3,154,000 MARS * 0.13 = 410,020 OSMO
Step 4: Determine return
200K OSMO + 410.02K OSMO = 610.02K OSMO
610,020 / 2,000,000 * 100 = 30.501% APY