Skip to content

Commit

Permalink
Merge pull request #96 from 1inch/fix/curve-oracle-vyper
Browse files Browse the repository at this point in the history
[SC-928] Correcting Byte Count in Vyper Method Returns
  • Loading branch information
ZumZoom authored Oct 7, 2023
2 parents cfc8bf1 + 038891f commit 190079a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/oracles/CurveOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ contract CurveOracle is IOracle {
if (b0 != 0) {
uint256 b1;
(success, data) = pool.staticcall(abi.encodeWithSelector(info.dyFuncInt128Selector, srcTokenIndex, dstTokenIndex, b0));
if (success && data.length == 32) {
if (success && data.length >= 32) { // vyper could return redundant bytes
b1 = abi.decode(data, (uint256));
} else {
b1 = info.dyFuncUint256(uint128(srcTokenIndex), uint128(dstTokenIndex), b0);
Expand Down
2 changes: 2 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const tokens = {
yvWBTC: '0xA696a63cc78DfFa1a63E9E50587C197387FF6C7E',
crvUSD: '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
wstETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
BEAN: '0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab',
'3CRV': '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490',
base: {
DAI: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',
WETH: '0x4200000000000000000000000000000000000006',
Expand Down
6 changes: 6 additions & 0 deletions test/oracles/CurveOracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ describe('CurveOracle', function () {
assertRoughlyEqualValues(rate.rate.toString(), expectedRate.rate.toString(), '0.05');
});

it('should use correct `get_dy` selector when vyper return redundant bytes', async function () {
const { curveOracle } = await loadFixture(initContracts);
const rate = await curveOracle.getRate(tokens.BEAN, tokens['3CRV'], tokens.NONE, thresholdFilter);
expect(rate.rate).to.gt('0');
});

describe('doesn\'t ruin various registry with different selectors', function () {
it('Main Registry', async function () {
await testNotRuins(0, 2);
Expand Down

0 comments on commit 190079a

Please sign in to comment.