NeptuneService is a straightforward tool that interacts with the Neptune CosmWasm smart contracts on Injective. It allows you to fetch asset prices, calculate exchange ratios, create deposit and withdraw messages, and retrieve lending rates.
Below are examples of how to use each method in the NeptuneService class.
Initialize NeptuneService
Before using the service, create an instance ofNeptuneService.
Fetch Prices
- Get the prices of specific assets from the Neptune Price Oracle contract. Use native_token for bank denoms and token with contract_addr for CW20 tokens.
Fetch Redemption Ratio
- Calculate the redemption ratio between nUSDT (CW20 token) and USDT (bank token).
Convert CW20 nUSDT to Bank USDT
- Calculate the amount in bank USDT from a given amount of CW20 nUSDT using the redemption ratio.
Convert Bank USDT to CW20 nUSDT
- Calculate the amount in CW20 nUSDT from a given amount of bank USDT using the redemption ratio.
Fetch Lending Rates
- Retrieve lending rates for the different lending markets in neptune’s lending market smart contract
Fetch Lending Rate by Denomination
- Get the lending rate for USDT for example
Calculate Annual Percentage Yield (APY)
- Convert the annual percentage rate (APR) to the continuously compounded annual percentage yield (APY). Make sure to use the lending rate retried from neptuneService.getLendingRateByDenom to use as the apr.
Create and Broadcast a Deposit Message
- Create a message to deposit USDT into the Neptune USDT lending market and broadcast it to the network.
Create and Broadcast a Withdraw Message
- Create a message to withdraw USDT from the Neptune USDT lending market and broadcast it to the network