Skip to content

Commit

Permalink
Add Dracula (#1203)
Browse files Browse the repository at this point in the history
* Add Dracula

* Adjust APY calculation

* Adjust decimals
  • Loading branch information
shatterproof authored Aug 10, 2023
1 parent 278f849 commit 8bebd34
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"kava:equilibre:add": "ts-node scripts/add-solidly.ts --network kava --project equilibre --newFee true --lp",
"zksync:velocore:add": "ts-node scripts/add-solidly.ts --network zksync --project velocore --newFee true --lp",
"zksync:vesync:add": "ts-node scripts/add-solidly.ts --network zksync --project vesync --newFee true --lp",
"zksync:dracula:add": "ts-node scripts/add-solidly.ts --network zksync --project dracula --newFee true --lp",
"zkevm:quick:add": "ts-node scripts/add-sushi.ts --network zkevm --project quickZkevm --newFee true --pool",
"base:baseSwap:add": "ts-node scripts/add-farm.ts --network base --project baseSwap --newFee true",
"gen-abi-types": "abi-types-generator ./src/abis/StableSwap.json --output='./src/abis/StableSwap/types'"
Expand Down
2 changes: 2 additions & 0 deletions packages/address-book/address-book/zksync/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { beefyfinance } from './platforms/beefyfinance';
import { velocore } from './platforms/velocore';
import { vesync } from './platforms/vesync';
import { dracula } from './platforms/dracula';
import { tokens } from './tokens/tokens';
import { convertSymbolTokenMapToAddressTokenMap } from '../../util/convertSymbolTokenMapToAddressTokenMap';
import Chain from '../../types/chain';
Expand All @@ -11,6 +12,7 @@ const _zksync = {
beefyfinance,
velocore,
vesync,
dracula,
},
tokens,
tokenAddressMap: convertSymbolTokenMapToAddressTokenMap(tokens),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const dracula = {
router: '0x4D88434eDc8B7fFe215ec598C2290CdC6f58d12D',
voter: '0x56A209955df2C74bFde45b335D4C46148652791d',
} as const;
14 changes: 13 additions & 1 deletion packages/address-book/address-book/zksync/tokens/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ETH = {
chainId: 324,
website: 'https://weth.io/',
description: 'Ether or ETH is the native currency built on the Ethereum blockchain.',
bridge: 'zksync-canonical',
bridge: 'zksync-canonical',
logoURI: '',
documentation: 'https://ethereum.org/en/developers/docs/',
} as const;
Expand Down Expand Up @@ -120,6 +120,18 @@ const _tokens = {
'Wrapped Bitcoin (WBTC) is the first ERC20 token backed 1:1 with Bitcoin. Completely transparent. 100% verifiable. Community led.',
bridge: 'zksync-canonical',
},
FANG: {
name: 'Dracula',
symbol: 'FANG',
address: '0x160e07e42ADbC1FCE92D505B579Bcd8a3fBEa77d',
chainId: 324,
decimals: 18,
logoURI: '',
website: 'https://draculafi.xyz/',
description:
'DraculaFi is a cutting-edge DeFi protocol built on zkSync Era with a proven ve(3,3) model and game-changing mechanisms that aim to provide increased rewards and stability for users.',
documentation: 'https://draculafi.gitbook.io/draculafi/',
},
} as const;

export const tokens: ConstRecord<typeof _tokens, Token> = _tokens;
8 changes: 7 additions & 1 deletion scripts/add-solidly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const {
platforms: { equilibre },
},
zksync: {
platforms: { velocore, vesync },
platforms: { velocore, vesync, dracula },
},
avax: {
platforms: { solisnek },
Expand Down Expand Up @@ -133,6 +133,12 @@ const projects = {
volatileFile: '../src/data/zksync/veSyncLpPools.json',
voter: vesync.voter,
},
dracula: {
prefix: 'dracula',
stableFile: '../src/data/zksync/draculaStableLpPools.json',
volatileFile: '../src/data/zksync/draculaLpPools.json',
voter: dracula.voter,
},
solisnek: {
prefix: 'solisnek',
stableFile: '../src/data/avax/soliSnekStableLpPools.json',
Expand Down
12 changes: 5 additions & 7 deletions src/api/stats/common/getSolidlyGaugeApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ const getFarmApys = async params => {
let yearlyRewards = 0;
if (params.boosted) {
if (boost) {
if (gaugeDeposit.gt(derived.plus(adjusted))) {
yearlyRewards = rewardRates[i]
.times(secondsPerYear)
.times(derived.plus(adjusted).dividedBy(gaugeDeposit));
} else {
yearlyRewards = rewardRates[i].times(secondsPerYear);
}
yearlyRewards = gaugeDeposit.gt(derived.plus(adjusted))
? rewardRates[i]
.times(secondsPerYear)
.times(derived.plus(adjusted).dividedBy(gaugeDeposit))
: rewardRates[i].times(secondsPerYear);
} else if (params.spirit) {
yearlyRewards = rewardRates[i]
.times(secondsPerYear)
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getAmmPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ import bvmPools from '../../data/base/bvmLpPools.json';
import cvmPools from '../../data/canto/cvmLpPools.json';
import baseSwapPools from '../../data/base/baseSwapLpPools.json';
import ooeV2Pools from '../../data/bsc/ooeV2LpPools.json';
import draculaPools from '../../data/zksync/draculaLpPools.json';
import { fetchVaultPrices } from '../../utils/fetchVaultPrices';
import { addressBookByChainId } from '../../../packages/address-book/address-book';
import { sleep } from '../../utils/time';
Expand All @@ -292,6 +293,7 @@ const REFRESH_INTERVAL = 5 * 60 * 1000;
// FIXME: if this list grows too big we might hit the ratelimit on initialization everytime
// Implement in case of emergency -> https://github.com/beefyfinance/beefy-api/issues/103
const pools = normalizePoolOracleIds([
...draculaPools,
...ooeV2Pools,
...baseSwapPools,
...fvmPools,
Expand Down
24 changes: 24 additions & 0 deletions src/api/stats/zksync/getDraculaApys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { ZKSYNC_CHAIN_ID: chainId } = require('../../../constants');
const { getSolidlyGaugeApys } = require('../common/getSolidlyGaugeApys');

const volatilePools = require('../../../data/zksync/draculaLpPools.json');
import { addressBook } from '../../../../packages/address-book/address-book';
const {
zksync: {
tokens: { FANG },
},
} = addressBook;

const pools = [...volatilePools];
const getDraculaApys = async () =>
getSolidlyGaugeApys({
chainId: chainId,
pools: pools,
oracleId: 'FANG',
oracle: 'tokens',
decimals: '1e36',
reward: FANG.address,
// log: true,
});

module.exports = getDraculaApys;
3 changes: 2 additions & 1 deletion src/api/stats/zksync/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const getVelocoreApys = require('./getVelocoreApys');
const getveSyncApys = require('./getveSyncApys');
const getDraculaApys = require('./getDraculaApys');

const getApys = [getVelocoreApys, getveSyncApys];
const getApys = [getVelocoreApys, getveSyncApys, getDraculaApys];

const getZksyncApys = async () => {
const start = Date.now();
Expand Down
42 changes: 42 additions & 0 deletions src/data/zksync/draculaLpPools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "dracula-usdc-weth",
"address": "0xB51E60f61c48d8329843F86d861AbF50E4DC918d",
"gauge": "0xaD07E210F9DA6eBaC3fe2fe7765a7850C438A04f",
"decimals": "1e18",
"chainId": 324,
"beefyFee": 0.095,
"lp0": {
"address": "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4",
"oracle": "tokens",
"oracleId": "USDC",
"decimals": "1e6"
},
"lp1": {
"address": "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
"oracle": "tokens",
"oracleId": "WETH",
"decimals": "1e18"
}
},
{
"name": "dracula-fang-usdc",
"address": "0x0F62837f7d37638210F94fa8005D0a89be083922",
"gauge": "0xeed9Ec94676bbb8f51C4EB8809b447C9cB8a21Cd",
"decimals": "1e18",
"chainId": 324,
"beefyFee": 0.095,
"lp0": {
"address": "0x160e07e42ADbC1FCE92D505B579Bcd8a3fBEa77d",
"oracle": "tokens",
"oracleId": "FANG",
"decimals": "1e18"
},
"lp1": {
"address": "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4",
"oracle": "tokens",
"oracleId": "USDC",
"decimals": "1e6"
}
}
]

0 comments on commit 8bebd34

Please sign in to comment.