-
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
3 changed files
with
35 additions
and
1 deletion.
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,12 @@ | ||
# @version 0.3.7 | ||
|
||
from vyper.interfaces import ERC4626 | ||
|
||
ASSET: constant(address) = 0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6 # apxETH | ||
UNIT: constant(uint256) = 1_000_000_000_000_000_000 | ||
|
||
@external | ||
@view | ||
def rate(_asset: address) -> uint256: | ||
assert _asset == ASSET | ||
return ERC4626(ASSET).convertToAssets(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
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,20 @@ | ||
from ape import Contract | ||
import pytest | ||
|
||
ASSET = '0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6' | ||
UNDERLYING = '0x04C154b66CB340F3Ae24111CC767e0184Ed00Cc6' | ||
UNIT = 1_000_000_000_000_000_000 | ||
|
||
@pytest.fixture | ||
def provider(project, deployer): | ||
return project.PirexRateProvider.deploy(sender=deployer) | ||
|
||
def test_rate_provider(provider, accounts): | ||
asset = Contract(ASSET) | ||
account = accounts['0x3A8EAF3fE0082e478293917F2E81F4fEED97ace2'] | ||
underlying = Contract(UNDERLYING) | ||
asset.redeem(UNIT, accounts[0], account, sender=account) | ||
|
||
rate = provider.rate(ASSET) | ||
assert rate > UNIT and rate < UNIT * 12 // 10 | ||
assert underlying.balanceOf(accounts[0]) == rate |