This repository was archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Update Constant Update gas-price TimeSeriesFeed #58
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
/* | ||
Copyright 2019 Set Labs Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity 0.5.7; | ||
pragma experimental "ABIEncoderV2"; | ||
|
||
import { LinkedListLibraryV2 } from "./LinkedListLibraryV2.sol"; | ||
|
||
|
||
/** | ||
* @title LinkedListHelper | ||
* @author Set Protocol | ||
* | ||
* Convenience methods for the LinkedListLibrary | ||
*/ | ||
library LinkedListHelper { | ||
using LinkedListLibraryV2 for LinkedListLibraryV2.LinkedList; | ||
|
||
/* ============ Structs ============ */ | ||
|
||
function getLatestValue( | ||
LinkedListLibraryV2.LinkedList memory _self | ||
) | ||
internal | ||
view | ||
returns (uint256) | ||
{ | ||
uint256[] memory currentTimeSeriesValues = _self.readListMemory(1); | ||
return currentTimeSeriesValues[0]; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
pragma solidity 0.5.7; | ||
pragma experimental "ABIEncoderV2"; | ||
import { LinkedListLibraryV2 } from "./LinkedListLibraryV2.sol"; | ||
|
||
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. Remove extra space |
||
|
||
/** | ||
|
@@ -28,6 +29,6 @@ library TimeSeriesStateLibrary { | |
struct State { | ||
uint256 nextEarliestUpdate; | ||
uint256 updateInterval; | ||
uint256[] timeSeriesDataArray; | ||
LinkedListLibraryV2.LinkedList timeSeriesData; | ||
} | ||
} |
This file contains hidden or 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,42 @@ | ||
/* | ||
Copyright 2019 Set Labs Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity 0.5.7; | ||
pragma experimental "ABIEncoderV2"; | ||
|
||
import { LinkedListLibraryV2 } from "../../../meta-oracles/lib/LinkedListLibraryV2.sol"; | ||
import { LinkedListHelper } from "../../../meta-oracles/lib/LinkedListHelper.sol"; | ||
|
||
/** | ||
* @title LinkedListHelperMock | ||
* @author Set Protocol | ||
* | ||
* Convenience methods for the LinkedListLibrary | ||
*/ | ||
contract LinkedListHelperMock { | ||
|
||
/* ============ Public Function ============ */ | ||
|
||
function getLatestValueMock( | ||
LinkedListLibraryV2.LinkedList memory _self | ||
) | ||
public | ||
view | ||
returns (uint256) | ||
{ | ||
return LinkedListHelper.getLatestValue(_self); | ||
} | ||
} |
This file contains hidden or 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
85 changes: 85 additions & 0 deletions
85
test/contracts/meta-oracles/lib/linkedListHelperMock.spec.ts
This file contains hidden or 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,85 @@ | ||
require('module-alias/register'); | ||
|
||
import * as _ from 'lodash'; | ||
import * as chai from 'chai'; | ||
import { BigNumber } from 'bignumber.js'; | ||
|
||
import ChaiSetup from '@utils/chaiSetup'; | ||
import { BigNumberSetup } from '@utils/bigNumberSetup'; | ||
import { | ||
LinkedListHelperMockContract, | ||
} from '@utils/contracts'; | ||
import { Blockchain } from '@utils/blockchain'; | ||
import { ether } from '@utils/units'; | ||
import { | ||
DEFAULT_GAS | ||
} from '@utils/constants'; | ||
import { getWeb3 } from '@utils/web3Helper'; | ||
|
||
import { LibraryMockWrapper } from '@utils/wrappers/libraryMockWrapper'; | ||
|
||
BigNumberSetup.configure(); | ||
ChaiSetup.configure(); | ||
const web3 = getWeb3(); | ||
const { expect } = chai; | ||
const blockchain = new Blockchain(web3); | ||
|
||
contract('LinkedListHelper', accounts => { | ||
const [ | ||
deployerAccount, | ||
] = accounts; | ||
|
||
let linkedListLibraryMock: LinkedListHelperMockContract; | ||
|
||
const libraryMockWrapper = new LibraryMockWrapper(deployerAccount); | ||
|
||
beforeEach(async () => { | ||
blockchain.saveSnapshotAsync(); | ||
|
||
linkedListLibraryMock = await libraryMockWrapper.deployLinkedListHelperMockAsync(); | ||
}); | ||
|
||
afterEach(async () => { | ||
blockchain.revertAsync(); | ||
}); | ||
|
||
describe('#getLatestValue', async () => { | ||
let lastUpdatedIndex: BigNumber; | ||
let dataArray: BigNumber[]; | ||
let dataSizeLimit: BigNumber; | ||
|
||
let subjectLinkedList: any; | ||
|
||
beforeEach(async () => { | ||
lastUpdatedIndex = new BigNumber(4); | ||
dataSizeLimit = new BigNumber(5); | ||
|
||
dataArray = [ | ||
ether(160), | ||
ether(175), | ||
ether(157), | ||
ether(162), | ||
ether(173), | ||
]; | ||
|
||
subjectLinkedList = { | ||
dataSizeLimit, | ||
lastUpdatedIndex, | ||
dataArray, | ||
}; | ||
}); | ||
|
||
async function subject(): Promise<BigNumber> { | ||
return linkedListLibraryMock.getLatestValueMock.callAsync( | ||
subjectLinkedList, | ||
{ gas: DEFAULT_GAS } | ||
); | ||
} | ||
|
||
it('gets the correct last value', async () => { | ||
const latestValue = await subject(); | ||
|
||
expect(latestValue).to.bignumber.equal(dataArray[lastUpdatedIndex.toNumber()]); | ||
}); | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove extra space