-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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,14 @@ | ||
# @version 0.3.7 | ||
|
||
interface EtherFiLiquidityPool: | ||
def amountForShare(_shares: uint256) -> uint256: view | ||
|
||
ASSET: constant(address) = 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee # weETH | ||
LIQUIDITY_POOL: constant(address) = 0x308861A430be4cce5502d0A12724771Fc6DaF216 | ||
UNIT: constant(uint256) = 1_000_000_000_000_000_000 | ||
|
||
@external | ||
@view | ||
def rate(_asset: address) -> uint256: | ||
assert _asset == ASSET | ||
return EtherFiLiquidityPool(LIQUIDITY_POOL).amountForShare(UNIT) |
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,19 @@ | ||
from ape import Contract | ||
import pytest | ||
|
||
ASSET = '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee' | ||
UNDERLYING = '0x35fA164735182de50811E8e2E824cFb9B6118ac2' | ||
UNIT = 1_000_000_000_000_000_000 | ||
|
||
@pytest.fixture | ||
def provider(project, deployer): | ||
return project.EtherFiRateProvider.deploy(sender=deployer) | ||
|
||
def test_rate_provider(provider, accounts): | ||
asset = Contract(ASSET) | ||
account = accounts['0x2b0024ecee0626E9cFB5F0195F69DCaC5b759Dc9'] | ||
underlying = Contract(UNDERLYING) | ||
rate = provider.rate(ASSET) | ||
asset.unwrap(UNIT, sender=account) | ||
assert rate > UNIT and rate < UNIT * 12 // 10 | ||
assert abs(underlying.balanceOf(account) - rate) <= 1 # rounding difference due to rebase mechanism |