-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getFactoGaugesCrvRewards to retrieve crv rewards from sidechain f…
…acto gauges
- Loading branch information
1 parent
3780b08
commit 2a33eb6
Showing
6 changed files
with
150 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_crv_token","type":"address"},{"name":"_gauge_controller","type":"address"},{"name":"_minter","type":"address"}],"outputs":[]},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"nonpayable","type":"function","name":"transmit_emissions","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"integrate_fraction","inputs":[{"name":"_user","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"user_checkpoint","inputs":[{"name":"_user","type":"address"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"set_killed","inputs":[{"name":"_is_killed","type":"bool"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"update_bridger","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"initialize","inputs":[{"name":"_bridger","type":"address"},{"name":"_chain_id","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"chain_id","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"bridger","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"factory","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"inflation_params","inputs":[],"outputs":[{"name":"","type":"tuple","components":[{"name":"rate","type":"uint256"},{"name":"finish_time","type":"uint256"}]}]},{"stateMutability":"view","type":"function","name":"last_period","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"total_emissions","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"is_killed","inputs":[],"outputs":[{"name":"","type":"bool"}]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { fn } from 'utils/api'; | ||
import getFactoGaugesCrvRewardsApiFn from './index'; | ||
|
||
export default fn(async ({ blockchainId }) => ( | ||
getFactoGaugesCrvRewardsApiFn.straightCall({ blockchainId }) | ||
), { | ||
maxAge: 60, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Returns unboosted CRV APRs for sidechain facto gauges. | ||
*/ | ||
|
||
import { fn } from 'utils/api'; | ||
import getAssetsPrices from 'utils/data/assets-prices'; | ||
|
||
import getFactoGauges from 'pages/api/getFactoGauges'; | ||
import getPools from 'pages/api/getPools'; | ||
import configs from 'constants/configs'; | ||
|
||
export default fn(async ({ blockchainId }) => { | ||
if (typeof blockchainId === 'undefined') blockchainId = 'ethereum'; // Default value | ||
|
||
const config = configs[blockchainId]; | ||
|
||
const { gauges } = await getFactoGauges.straightCall({ blockchainId }); | ||
const { poolData: mainPoolData } = await getPools.straightCall({ blockchainId, registryId: 'factory' }); | ||
const { poolData: cryptoPoolData } = ( | ||
config.getFactoryCryptoRegistryAddress ? | ||
await getPools.straightCall({ blockchainId, registryId: 'factory-crypto' }) : | ||
{ poolData: [] } | ||
); | ||
const poolData = [...mainPoolData, ...cryptoPoolData]; | ||
|
||
const sideChainGauges = gauges.filter(({ | ||
side_chain: isSideChain, | ||
name, | ||
is_killed: isKilled, | ||
}) => ( | ||
isSideChain && | ||
// name.startsWith(`${blockchainId}-`) && | ||
!isKilled | ||
)); | ||
|
||
if (sideChainGauges.length === 0) { | ||
throw new Error(`No side gauges data for blockchainId "${blockchainId}"`); | ||
} | ||
|
||
const { 'curve-dao-token': crvPrice } = await getAssetsPrices(['curve-dao-token']); | ||
|
||
const sideChainGaugesApys = sideChainGauges.map(({ | ||
swap, | ||
name, | ||
gauge_data: { | ||
gauge_relative_weight: weight, | ||
inflation_rate: rate, | ||
}, | ||
}) => { | ||
const lcAddress = swap.toLowerCase(); | ||
const pool = poolData.find(({ address }) => address.toLowerCase() === lcAddress); | ||
if (!pool) throw new Error(`Can't find pool data for swap address "${swap}"`); | ||
|
||
const apy = (rate / 1e18) * (weight / 1e18) * (86400 * 365) / pool.usdTotal * 0.4 * crvPrice * 100; | ||
|
||
return { | ||
address: lcAddress, | ||
name, | ||
apy, | ||
}; | ||
}); | ||
|
||
return { sideChainGaugesApys }; | ||
}, { | ||
maxAge: 60, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters