Skip to content

Commit

Permalink
feat: moved some files into a utils file, wrote tests, moved mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SissonJ committed Apr 4, 2024
1 parent 5b2d1a8 commit 6e1a58c
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 552 deletions.
29 changes: 1 addition & 28 deletions docs/calculations/apy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Calculates the apy expected for the stkd-SCRT token
* Will calculate APY for the stkd secret derivative contract
*
* returns a number that is the decimal form of the percent APY
* @param lcdEndpoint is not optional due to the requirement of the secretChainQueries() function
*/
function calculateDerivativeScrtApy({
queryRouterContractAddress,
Expand All @@ -26,31 +27,3 @@ function calculateDerivativeScrtApy({
chainId?: string,
}): Promise<number>
```

### dSHD APY
Calculates the apy expected for the stkd-SCRT token
```ts
/**
* Calculates the dSHD expected APY by querying the staking contract
* TESTNET ONLY NOT READY FOR PRODUCTION
*
* returns a number that is the decimal form of the percent APY
*/
async function calculateDerivativeShdApy({
shadeTokenContractAddress,
shadeStakingContractAddress,
shadeStakingCodeHash,
decimals,
price,
lcdEndpoint,
chainId,
}:{
shadeTokenContractAddress: string,
shadeStakingContractAddress: string,
shadeStakingCodeHash?: string,
decimals: number,
price: string,
lcdEndpoint?: string,
chainId?: string,
}): Promise<number>
```
4 changes: 3 additions & 1 deletion src/contracts/services/shadeStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
StakingInfoServiceModel,
} from '~/types/contracts/shadeStaking/index';

const NORMALIZATION_FACTOR = 18;

/**
* parses the response from the shade staking contract into a model
*/
Expand All @@ -30,7 +32,7 @@ function parseStakingOpportunity(data: StakingInfoServiceResponse): StakingInfoS
tokenAddress: reward.token.address,
// data returned from the contract in normalized form with
// 18 decimals, in addition to any decimals on the individual token
rateRaw: convertCoinFromUDenom(reward.rate, 18).toString(),
rateRaw: convertCoinFromUDenom(reward.rate, NORMALIZATION_FACTOR).toString(),
}));
return {
stakeTokenAddress,
Expand Down
Loading

0 comments on commit 6e1a58c

Please sign in to comment.