Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"lodash": "^4.17.4",
"lodash.compact": "^3.0.1",
"moment": "^2.22.2",
"set-protocol-contracts": "1.4.9-beta",
"set-protocol-contracts": "1.4.11-beta",
"set-protocol-oracles": "^1.0.16",
"set-protocol-strategies": "^1.1.39",
"set-protocol-viewers": "^1.0.13",
Expand Down
9 changes: 1 addition & 8 deletions test/helpers/coreHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,17 @@ export const deployTWAPLiquidatorAsync = async (
auctionPeriod: BigNumber,
rangeStart: BigNumber,
rangeEnd: BigNumber,
assetPairHashes: string[],
assetPairBounds: {}[],
name: string
): Promise<TWAPLiquidatorContract> => {
const assetPairBoundsStr = [];
for (let i = 0; i < assetPairBounds.length; i++) {
assetPairBoundsStr.push(assetPairBounds[i]);
}

const truffleLiquidator = setDefaultTruffleContract(web3, TWAPLiquidator);
const deployedTWAPLiquidator = await truffleLiquidator.new(
core,
oracleWhiteList,
auctionPeriod,
rangeStart,
rangeEnd,
assetPairHashes,
assetPairBoundsStr,
assetPairBounds,
name,
);

Expand Down
22 changes: 10 additions & 12 deletions test/integration/api/RebalancingAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3930,13 +3930,15 @@ describe('RebalancingAPI', () => {
nextSetToken = set2;

const auctionPeriod = ONE_HOUR_IN_SECONDS;
const rangeStart = new BigNumber(3);
const rangeEnd = new BigNumber(21);
const assetPairHashes = [
liquidatorHelper.generateAssetPairHashes(weth.address, usdc.address),
];
const rangeStart = ether(.01);
const rangeEnd = ether(.23);
const name = 'liquidator';
const assetPairBounds = [
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
{
assetOne: weth.address,
assetTwo: usdc.address,
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
},
];
liquidator = await deployTWAPLiquidatorAsync(
web3,
Expand All @@ -3945,9 +3947,8 @@ describe('RebalancingAPI', () => {
auctionPeriod,
rangeStart,
rangeEnd,
assetPairHashes,
assetPairBounds,
'TWAPLiquidator'
name
);

feeCalculator = await feeCalculatorHelper.deployPerformanceFeeCalculatorAsync(
Expand Down Expand Up @@ -3984,7 +3985,6 @@ describe('RebalancingAPI', () => {

describe('fetchRBSetTWAPRebalanceDetailsAsync', async () => {
const chunkAuctionPeriod: BigNumber = ONE_HOUR_IN_SECONDS;
let rebalanceTimestamp: BigNumber;

let subjectRebalancingSetTokenAddress: Address;

Expand All @@ -4006,8 +4006,6 @@ describe('RebalancingAPI', () => {
nextSetToken.address,
liquidatorData
);
const lastBlock = await web3.eth.getBlock('latest');
rebalanceTimestamp = new BigNumber(lastBlock.timestamp);

subjectRebalancingSetTokenAddress = rebalancingSetTokenV3.address;
});
Expand Down Expand Up @@ -4038,7 +4036,7 @@ describe('RebalancingAPI', () => {
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
expect(JSON.stringify(rbSetData.nextSetInfo.components)).to.equal(JSON.stringify(set2Components));
expect(JSON.stringify(rbSetData.nextSetInfo.units)).to.equal(JSON.stringify(set2Units));
expect(rbSetData.nextSetInfo.naturalUnit).to.be.bignumber.equal(collateralNaturalUnit);
Expand Down
25 changes: 13 additions & 12 deletions test/integration/api/SocialTradingAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,26 @@ describe('SocialTradingAPI', () => {
rangeStart,
rangeEnd
);
const assetPairHashes = [
liquidatorHelper.generateAssetPairHashes(wrappedETH.address, wrappedBTC.address),
];

const twapName = 'TWAPLiquidator';
const assetPairBounds = [
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
{
assetOne: wrappedETH.address,
assetTwo: wrappedBTC.address,
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
},
];
const twapRangeStart = ether(.01);
const twapRangeEnd = ether(.23);
twapLiquidator = await deployTWAPLiquidatorAsync(
web3,
core.address,
oracleWhiteList.address,
auctionPeriod,
rangeStart,
rangeEnd,
assetPairHashes,
twapRangeStart,
twapRangeEnd,
assetPairBounds,
'TWAPLiquidator'
twapName
);
liquidatorWhiteList = await deployWhiteListContract(web3, [liquidator.address, twapLiquidator.address]);

Expand Down Expand Up @@ -1760,7 +1764,6 @@ describe('SocialTradingAPI', () => {
let subjectTradingPool: Address;

let newAllocation: BigNumber;
let rebalanceTimestamp: BigNumber;
const chunkAuctionPeriod: BigNumber = ONE_HOUR_IN_SECONDS;

let newCollateralInstance: SetTokenContract;
Expand Down Expand Up @@ -1853,8 +1856,6 @@ describe('SocialTradingAPI', () => {
liquidatorData,
{ from: DEFAULT_ACCOUNT }
);
const block = await web3.eth.getBlock('latest');
rebalanceTimestamp = new BigNumber(block.timestamp);

const newFormattedLogs = await getFormattedLogsFromTxHash(web3, newTxHash);
const newCollateralAddress = extractNewSetTokenAddressFromLogs(newFormattedLogs, 2);
Expand Down Expand Up @@ -1918,7 +1919,7 @@ describe('SocialTradingAPI', () => {
expect(poolRebalanceInfo.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
expect(poolRebalanceInfo.chunkSize).to.be.bignumber.equal(startingCurrentSets);
expect(poolRebalanceInfo.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
expect(poolRebalanceInfo.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
expect(poolRebalanceInfo.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
expect(poolRebalanceInfo.rebalanceState).to.be.bignumber.equal(new BigNumber(2));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ describe('ProtocolViewer', () => {
let auctionPeriod: BigNumber;
let rangeStart: BigNumber;
let rangeEnd: BigNumber;
let twapRangeStart: BigNumber;
let twapRangeEnd: BigNumber;
let failPeriod: BigNumber;
let oracleWhiteList: OracleWhiteListContract;

Expand Down Expand Up @@ -1067,21 +1069,23 @@ describe('ProtocolViewer', () => {
name,
);

const assetPairHashes = [
liquidatorHelper.generateAssetPairHashes(component1.address, component2.address),
];
const twapName = 'TWAPLiquidator';
const assetPairBounds = [
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
{
assetOne: component1.address,
assetTwo: component2.address,
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
},
];
const twapName = 'TWAPLiquidator';
twapRangeStart = ether(.01);
twapRangeEnd = ether(.23);
twapLiquidator = await deployTWAPLiquidatorAsync(
web3,
core.address,
oracleWhiteList.address,
auctionPeriod,
rangeStart,
rangeEnd,
assetPairHashes,
twapRangeStart,
twapRangeEnd,
assetPairBounds,
twapName
);
Expand Down Expand Up @@ -1323,7 +1327,6 @@ describe('ProtocolViewer', () => {
let subjectTradingPool: Address;

let newAllocation: BigNumber;
let rebalanceTimestamp: BigNumber;

beforeEach(async () => {
twapRebalancingSetToken.setManager.sendTransactionAsync(setManager.address);
Expand Down Expand Up @@ -1359,8 +1362,6 @@ describe('ProtocolViewer', () => {
newAllocation,
liquidatorData
);
const block = await web3.eth.getBlock('latest');
rebalanceTimestamp = new BigNumber(block.timestamp);

subjectTradingPool = twapRebalancingSetToken.address;
});
Expand Down Expand Up @@ -1401,7 +1402,7 @@ describe('ProtocolViewer', () => {
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
});

it('fetches the correct CollateralSet data', async () => {
Expand All @@ -1418,8 +1419,6 @@ describe('ProtocolViewer', () => {
describe('#fetchRBSetTWAPRebalanceDetails', async () => {
let subjectTradingPool: Address;

let rebalanceTimestamp: BigNumber;

beforeEach(async () => {
// Issue currentSetToken
await core.issue.sendTransactionAsync(
Expand All @@ -1441,8 +1440,6 @@ describe('ProtocolViewer', () => {
nextSetTokenV3.address,
liquidatorData
);
const block = await web3.eth.getBlock('latest');
rebalanceTimestamp = new BigNumber(block.timestamp);

subjectTradingPool = twapRebalancingSetToken.address;
});
Expand Down Expand Up @@ -1475,7 +1472,7 @@ describe('ProtocolViewer', () => {
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
});

it('fetches the correct CollateralSet data', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ describe('TWAPLiquidatorWrapper', () => {
);

const auctionPeriod = ONE_HOUR_IN_SECONDS;
const rangeStart = new BigNumber(10); // 10% above fair value
const rangeEnd = new BigNumber(10); // 10% below fair value
const rangeStart = ether(.01);
const rangeEnd = ether(.23);
const name = 'liquidator';
const assetPairHashes = [
liquidatorHelper.generateAssetPairHashes(wrappedETH.address, wrappedBTC.address),
];
const assetPairBounds = [
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
{
assetOne: wrappedETH.address,
assetTwo: wrappedBTC.address,
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
},
];
liquidator = await deployTWAPLiquidatorAsync(
web3,
Expand All @@ -175,7 +176,6 @@ describe('TWAPLiquidatorWrapper', () => {
auctionPeriod,
rangeStart,
rangeEnd,
assetPairHashes,
assetPairBounds,
name
);
Expand Down
65 changes: 60 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6594,10 +6594,36 @@ set-protocol-contract-utils@^1.0.3:
web3-utils "1.0.0-beta.36"
zos-lib "^2.4.2"

set-protocol-contracts@1.4.9-beta, set-protocol-contracts@^1.4.9-beta:
version "1.4.9-beta"
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.9-beta.tgz#7907185d61451552916efa606b4a25e1d8df9ca6"
integrity sha512-D186K1DhlhRmIDRyHMmok/NtKZZqA2CSkkjTKYA0JDzuwgiASR5s4+LwRyRSZ7qJS+wnSRVMSUxOSo//c6kPNw==
set-protocol-contract-utils@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/set-protocol-contract-utils/-/set-protocol-contract-utils-1.0.4.tgz#ed70ce3b4fa187d6cde83f618100772ee7a854bd"
integrity sha512-+nqc/+OEbMFgq4f1l11Vvfq2ax9GT81xoyyr6owwAsf0p4uRGHEdrFKujlIBEDoEUCnkLzF3yvsU1j7VTTEnLA==
dependencies:
bn-chai "^1.0.1"
canonical-weth "^1.3.1"
dotenv "^6.2.0"
eth-gas-reporter "^0.1.10"
ethlint "^1.2.3"
expect "^24.1.0"
fs-extra "^5.0.0"
husky "^0.14.3"
lint-staged "^7.2.0"
module-alias "^2.1.0"
openzeppelin-solidity "^2.2"
set-protocol-utils "^1.0.0-beta.45"
tiny-promisify "^1.0.0"
truffle-flattener "^1.4.2"
ts-mocha "^6.0.0"
ts-node "^8.0.2"
tslint-eslint-rules "^5.3.1"
web3 "1.0.0-beta.36"
web3-utils "1.0.0-beta.36"
zos-lib "^2.4.2"

set-protocol-contracts@1.4.11-beta:
version "1.4.11-beta"
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.11-beta.tgz#d7620308ba6b2d44b5bb4d7fa959445085f8db6e"
integrity sha512-irCc6hf37b24BlLNPCTCzkH1nwjGipITdw7w7QAr85lg45FJVYwd1LGsZ7hibd5JiPHz432fhPzhCZlQXuWm2w==
dependencies:
bn-chai "^1.0.1"
canonical-weth "^1.3.1"
Expand All @@ -6611,7 +6637,7 @@ set-protocol-contracts@1.4.9-beta, set-protocol-contracts@^1.4.9-beta:
minify-all "^1.2.2"
module-alias "^2.1.0"
openzeppelin-solidity "^2.2"
set-protocol-contract-utils "^1.0.3"
set-protocol-contract-utils "^1.0.4"
set-protocol-oracles "^1.0.16"
set-protocol-utils "^1.1.2"
tiny-promisify "^1.0.0"
Expand Down Expand Up @@ -6652,6 +6678,35 @@ set-protocol-contracts@^1.4.5-beta:
web3-utils "1.0.0-beta.36"
zos-lib "^2.4.2"

set-protocol-contracts@^1.4.9-beta:
version "1.4.9-beta"
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.9-beta.tgz#7907185d61451552916efa606b4a25e1d8df9ca6"
integrity sha512-D186K1DhlhRmIDRyHMmok/NtKZZqA2CSkkjTKYA0JDzuwgiASR5s4+LwRyRSZ7qJS+wnSRVMSUxOSo//c6kPNw==
dependencies:
bn-chai "^1.0.1"
canonical-weth "^1.3.1"
dotenv "^6.2.0"
eth-gas-reporter "^0.1.10"
ethlint "^1.2.3"
expect "^24.1.0"
fs-extra "^5.0.0"
husky "^0.14.3"
lint-staged "^7.2.0"
minify-all "^1.2.2"
module-alias "^2.1.0"
openzeppelin-solidity "^2.2"
set-protocol-contract-utils "^1.0.3"
set-protocol-oracles "^1.0.16"
set-protocol-utils "^1.1.2"
tiny-promisify "^1.0.0"
truffle-flattener "^1.4.0"
ts-mocha "^6.0.0"
ts-node "^8.0.2"
tslint-eslint-rules "^5.3.1"
web3 "1.0.0-beta.36"
web3-utils "1.0.0-beta.36"
zos-lib "^2.4.2"

set-protocol-oracles@^1.0.16:
version "1.0.16"
resolved "https://registry.yarnpkg.com/set-protocol-oracles/-/set-protocol-oracles-1.0.16.tgz#15f1cb497feadc10673eb9193406bdd9c33ee3d6"
Expand Down