-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ability to add third party APRs & add Lido steth APR * 1.17.5
- Loading branch information
1 parent
f69dec2
commit 41a7c4b
Showing
10 changed files
with
129 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,53 @@ | ||
import { bnum } from '@/lib/utils'; | ||
import axios from 'axios'; | ||
import { Pool } from '../balancer/subgraph/types'; | ||
import ConfigService, { configService } from '../config/config.service'; | ||
|
||
type LidoAPRs = { | ||
eth: string; | ||
steth: string; | ||
}; | ||
|
||
type ApiResponse = { | ||
data: LidoAPRs; | ||
}; | ||
|
||
export default class LidoService { | ||
wethAddress: string; | ||
wstEthAddress: string; | ||
|
||
constructor(readonly config: ConfigService = configService) { | ||
this.wethAddress = config.network.addresses.weth; | ||
this.wstEthAddress = config.network.addresses.wstETH; | ||
} | ||
|
||
async getStEthAPR(): Promise<string> { | ||
try { | ||
const { | ||
data: { data: aprs } | ||
} = await axios.get<ApiResponse>('https://stake.lido.fi/api/apr'); | ||
return bnum(aprs.steth) | ||
.div(100) | ||
.toString(); | ||
} catch (error) { | ||
console.error('Failed to fetch stETH APR:', error); | ||
return '0'; | ||
} | ||
} | ||
|
||
async calcStEthAPRFor(pool: Pool): Promise<string> { | ||
const stethAPR = await this.getStEthAPR(); | ||
const wethBalance = | ||
pool.tokens.find(t => t.address === this.wethAddress)?.balance || '0'; | ||
const wstethBalance = | ||
pool.tokens.find(t => t.address === this.wstEthAddress)?.balance || '0'; | ||
const totalBalance = bnum(wethBalance).plus(wstethBalance); | ||
const wstethRatio = bnum(wstethBalance).div(totalBalance); | ||
|
||
return bnum(stethAPR) | ||
.times(wstethRatio) | ||
.toString(); | ||
} | ||
} | ||
|
||
export const lidoService = new LidoService(); |
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
41a7c4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kovan-app – ./
kovan-app-balancer.vercel.app
kovan-app-git-master-balancer.vercel.app
kovan.app.balancer.fi
kovan-app.vercel.app
kovan.balancer.fi
41a7c4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
arbitrum – ./
arbitrum.vercel.app
arbitrum-balancer.vercel.app
arbitrum.balancer.fi
arbitrum-git-master-balancer.vercel.app
41a7c4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
app – ./
app-balancer.vercel.app
app.balancer.fi
pm2.vercel.app
app-git-master-balancer.vercel.app
41a7c4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
polygon – ./
polygon-balancer.vercel.app
polygon-git-master-balancer.vercel.app
polygon.balancer.fi
polygon-alpha.vercel.app