-
Notifications
You must be signed in to change notification settings - Fork 39
Sdai adapter and substream #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
53ef2a0
b64b4fd
c51a089
25bb3ef
f31ccc0
ee40c1a
de19314
55a2668
d95f31a
b496753
3057903
f7e94a6
956f969
2ddf310
6aa6a5b
cd6e75e
79486a9
8bf2274
1f4fac5
28eaf8e
acee96c
7f25064
b68a8a4
16b4311
9eded50
9134f73
1201499
6aa9c40
e700fff
089a4c8
0bce026
5b0204c
3e62843
c222887
7b04a72
144f7d3
c7aaa59
6dc5eae
d70ce84
5499156
a84cf6e
1edf12e
3bd4584
37eca48
bdb8368
cb21eb0
2e49ad9
d519a4e
33abc5f
c1e8c5f
1db1509
6bdee6a
92fb797
fec555c
8edc192
ebf51fa
7d8ab1c
76755eb
be3ab7f
67a3d84
048a846
d0caec1
c7048ac
b9d25f3
0ec28ec
628cd92
629ca7d
3880c6e
29fb2e1
a1784b0
b758f64
8a04998
17145cd
be7803b
a8128bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,9 @@ contract sDaiSwapAdapter is ISwapAdapter { | |
| ISavingsDai immutable savingsDai; | ||
| IERC20 immutable dai; | ||
|
|
||
| constructor(address savingsDai_) { | ||
| constructor(address savingsDai_, address dai_) { | ||
| savingsDai = ISavingsDai(savingsDai_); | ||
| dai = IERC20(address(0x6B175474E89094C44Da98b954EedeAC495271d0F)); | ||
| dai = IERC20(dai_); | ||
| } | ||
|
|
||
| /// @dev Check if swap between provided sellToken and buyToken are supported | ||
|
|
@@ -86,9 +86,6 @@ contract sDaiSwapAdapter is ISwapAdapter { | |
| } | ||
|
|
||
| /// @inheritdoc ISwapAdapter | ||
| /// @dev Limits are underestimated to 90% of totalSupply as both Dai and | ||
| /// sDai | ||
| // have no limits but revert in some cases | ||
| function getLimits( | ||
| bytes32, | ||
| address sellToken, | ||
|
|
@@ -97,14 +94,12 @@ contract sDaiSwapAdapter is ISwapAdapter { | |
| limits = new uint256[](2); | ||
|
|
||
| if (sellToken == address(dai)) { | ||
| limits[0] = | ||
| ((dai.totalSupply() - dai.balanceOf(address(savingsDai))) * | ||
| 90) / | ||
| 100; | ||
| limits[1] = savingsDai.previewDeposit(limits[0]); | ||
| limits[0] = 3 * (10 ** 24); | ||
| limits[1] = limits[0]; | ||
| } else { | ||
| limits[0] = (savingsDai.totalSupply() * 90) / 100; | ||
| limits[1] = savingsDai.previewRedeem(limits[0]); | ||
| uint256 totalAssets = savingsDai.totalAssets(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kayibal I think this is not possible with the current Simulation module, as we override the tokens, right? |
||
| limits[0] = savingsDai.previewWithdraw(totalAssets); | ||
| limits[1] = totalAssets; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -213,6 +208,8 @@ interface ISavingsDai is IERC20 { | |
|
|
||
| function previewRedeem(uint256 shares) external view returns (uint256); | ||
|
|
||
| function totalAssets() external view returns (uint256); | ||
|
|
||
| function totalSupply() external pure returns (uint256); | ||
|
|
||
| function deposit( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,7 @@ fn find_deployed_underlying_address(vault_address: &[u8]) -> Option<[u8; 20]> { | |
| // sDai | ||
| hex!("83F20F44975D03b1b09e64809B757c47f942BEeA") => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded address - it won't work on other chains. I think you can get this value from the constructor? |
||
| // Dai | ||
| Some(hex!("6b175474e89094c44da98b954eedeac495271d0f")) | ||
| Some(hex!("6B175474E89094C44Da98b954EedeAC495271d0F")) | ||
| } | ||
| _ => None, | ||
| } | ||
|
|
||
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.
Can you explain this value it seems very arbitrary.
Uh oh!
There was an error while loading. Please reload this page.
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.
@kayibal It is the DAI total supply value approx., and we need to use static values due to the incompatibility issue between substreams and external calls
Uh oh!
There was an error while loading. Please reload this page.
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.
We can overwrite the token's
totalSupplyso ideally we should track this via attributesCurrently, DAI supply is 1000 times bigger than this number.