Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 840c065

Browse files
authored
Update tests for new TWAPLiquidator deploy interface. (#378)
1 parent a954660 commit 840c065

File tree

7 files changed

+106
-62
lines changed

7 files changed

+106
-62
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"lodash": "^4.17.4",
6868
"lodash.compact": "^3.0.1",
6969
"moment": "^2.22.2",
70-
"set-protocol-contracts": "1.4.9-beta",
70+
"set-protocol-contracts": "1.4.11-beta",
7171
"set-protocol-oracles": "^1.0.16",
7272
"set-protocol-strategies": "^1.1.39",
7373
"set-protocol-viewers": "^1.0.13",

test/helpers/coreHelpers.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,24 +415,17 @@ export const deployTWAPLiquidatorAsync = async (
415415
auctionPeriod: BigNumber,
416416
rangeStart: BigNumber,
417417
rangeEnd: BigNumber,
418-
assetPairHashes: string[],
419418
assetPairBounds: {}[],
420419
name: string
421420
): Promise<TWAPLiquidatorContract> => {
422-
const assetPairBoundsStr = [];
423-
for (let i = 0; i < assetPairBounds.length; i++) {
424-
assetPairBoundsStr.push(assetPairBounds[i]);
425-
}
426-
427421
const truffleLiquidator = setDefaultTruffleContract(web3, TWAPLiquidator);
428422
const deployedTWAPLiquidator = await truffleLiquidator.new(
429423
core,
430424
oracleWhiteList,
431425
auctionPeriod,
432426
rangeStart,
433427
rangeEnd,
434-
assetPairHashes,
435-
assetPairBoundsStr,
428+
assetPairBounds,
436429
name,
437430
);
438431

test/integration/api/RebalancingAPI.spec.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,13 +3930,15 @@ describe('RebalancingAPI', () => {
39303930
nextSetToken = set2;
39313931

39323932
const auctionPeriod = ONE_HOUR_IN_SECONDS;
3933-
const rangeStart = new BigNumber(3);
3934-
const rangeEnd = new BigNumber(21);
3935-
const assetPairHashes = [
3936-
liquidatorHelper.generateAssetPairHashes(weth.address, usdc.address),
3937-
];
3933+
const rangeStart = ether(.01);
3934+
const rangeEnd = ether(.23);
3935+
const name = 'liquidator';
39383936
const assetPairBounds = [
3939-
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
3937+
{
3938+
assetOne: weth.address,
3939+
assetTwo: usdc.address,
3940+
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
3941+
},
39403942
];
39413943
liquidator = await deployTWAPLiquidatorAsync(
39423944
web3,
@@ -3945,9 +3947,8 @@ describe('RebalancingAPI', () => {
39453947
auctionPeriod,
39463948
rangeStart,
39473949
rangeEnd,
3948-
assetPairHashes,
39493950
assetPairBounds,
3950-
'TWAPLiquidator'
3951+
name
39513952
);
39523953

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

39853986
describe('fetchRBSetTWAPRebalanceDetailsAsync', async () => {
39863987
const chunkAuctionPeriod: BigNumber = ONE_HOUR_IN_SECONDS;
3987-
let rebalanceTimestamp: BigNumber;
39883988

39893989
let subjectRebalancingSetTokenAddress: Address;
39903990

@@ -4006,8 +4006,6 @@ describe('RebalancingAPI', () => {
40064006
nextSetToken.address,
40074007
liquidatorData
40084008
);
4009-
const lastBlock = await web3.eth.getBlock('latest');
4010-
rebalanceTimestamp = new BigNumber(lastBlock.timestamp);
40114009

40124010
subjectRebalancingSetTokenAddress = rebalancingSetTokenV3.address;
40134011
});
@@ -4038,7 +4036,7 @@ describe('RebalancingAPI', () => {
40384036
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
40394037
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
40404038
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
4041-
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
4039+
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
40424040
expect(JSON.stringify(rbSetData.nextSetInfo.components)).to.equal(JSON.stringify(set2Components));
40434041
expect(JSON.stringify(rbSetData.nextSetInfo.units)).to.equal(JSON.stringify(set2Units));
40444042
expect(rbSetData.nextSetInfo.naturalUnit).to.be.bignumber.equal(collateralNaturalUnit);

test/integration/api/SocialTradingAPI.spec.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,26 @@ describe('SocialTradingAPI', () => {
248248
rangeStart,
249249
rangeEnd
250250
);
251-
const assetPairHashes = [
252-
liquidatorHelper.generateAssetPairHashes(wrappedETH.address, wrappedBTC.address),
253-
];
251+
252+
const twapName = 'TWAPLiquidator';
254253
const assetPairBounds = [
255-
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
254+
{
255+
assetOne: wrappedETH.address,
256+
assetTwo: wrappedBTC.address,
257+
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
258+
},
256259
];
260+
const twapRangeStart = ether(.01);
261+
const twapRangeEnd = ether(.23);
257262
twapLiquidator = await deployTWAPLiquidatorAsync(
258263
web3,
259264
core.address,
260265
oracleWhiteList.address,
261266
auctionPeriod,
262-
rangeStart,
263-
rangeEnd,
264-
assetPairHashes,
267+
twapRangeStart,
268+
twapRangeEnd,
265269
assetPairBounds,
266-
'TWAPLiquidator'
270+
twapName
267271
);
268272
liquidatorWhiteList = await deployWhiteListContract(web3, [liquidator.address, twapLiquidator.address]);
269273

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

17621766
let newAllocation: BigNumber;
1763-
let rebalanceTimestamp: BigNumber;
17641767
const chunkAuctionPeriod: BigNumber = ONE_HOUR_IN_SECONDS;
17651768

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

18591860
const newFormattedLogs = await getFormattedLogsFromTxHash(web3, newTxHash);
18601861
const newCollateralAddress = extractNewSetTokenAddressFromLogs(newFormattedLogs, 2);
@@ -1918,7 +1919,7 @@ describe('SocialTradingAPI', () => {
19181919
expect(poolRebalanceInfo.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
19191920
expect(poolRebalanceInfo.chunkSize).to.be.bignumber.equal(startingCurrentSets);
19201921
expect(poolRebalanceInfo.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
1921-
expect(poolRebalanceInfo.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
1922+
expect(poolRebalanceInfo.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
19221923
expect(poolRebalanceInfo.rebalanceState).to.be.bignumber.equal(new BigNumber(2));
19231924
});
19241925
});

test/integration/wrappers/set_protocol/ProtocolViewerWrapper.spec.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ describe('ProtocolViewer', () => {
970970
let auctionPeriod: BigNumber;
971971
let rangeStart: BigNumber;
972972
let rangeEnd: BigNumber;
973+
let twapRangeStart: BigNumber;
974+
let twapRangeEnd: BigNumber;
973975
let failPeriod: BigNumber;
974976
let oracleWhiteList: OracleWhiteListContract;
975977

@@ -1067,21 +1069,23 @@ describe('ProtocolViewer', () => {
10671069
name,
10681070
);
10691071

1070-
const assetPairHashes = [
1071-
liquidatorHelper.generateAssetPairHashes(component1.address, component2.address),
1072-
];
1072+
const twapName = 'TWAPLiquidator';
10731073
const assetPairBounds = [
1074-
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
1074+
{
1075+
assetOne: component1.address,
1076+
assetTwo: component2.address,
1077+
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
1078+
},
10751079
];
1076-
const twapName = 'TWAPLiquidator';
1080+
twapRangeStart = ether(.01);
1081+
twapRangeEnd = ether(.23);
10771082
twapLiquidator = await deployTWAPLiquidatorAsync(
10781083
web3,
10791084
core.address,
10801085
oracleWhiteList.address,
10811086
auctionPeriod,
1082-
rangeStart,
1083-
rangeEnd,
1084-
assetPairHashes,
1087+
twapRangeStart,
1088+
twapRangeEnd,
10851089
assetPairBounds,
10861090
twapName
10871091
);
@@ -1323,7 +1327,6 @@ describe('ProtocolViewer', () => {
13231327
let subjectTradingPool: Address;
13241328

13251329
let newAllocation: BigNumber;
1326-
let rebalanceTimestamp: BigNumber;
13271330

13281331
beforeEach(async () => {
13291332
twapRebalancingSetToken.setManager.sendTransactionAsync(setManager.address);
@@ -1359,8 +1362,6 @@ describe('ProtocolViewer', () => {
13591362
newAllocation,
13601363
liquidatorData
13611364
);
1362-
const block = await web3.eth.getBlock('latest');
1363-
rebalanceTimestamp = new BigNumber(block.timestamp);
13641365

13651366
subjectTradingPool = twapRebalancingSetToken.address;
13661367
});
@@ -1401,7 +1402,7 @@ describe('ProtocolViewer', () => {
14011402
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
14021403
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
14031404
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
1404-
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
1405+
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
14051406
});
14061407

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

1421-
let rebalanceTimestamp: BigNumber;
1422-
14231422
beforeEach(async () => {
14241423
// Issue currentSetToken
14251424
await core.issue.sendTransactionAsync(
@@ -1441,8 +1440,6 @@ describe('ProtocolViewer', () => {
14411440
nextSetTokenV3.address,
14421441
liquidatorData
14431442
);
1444-
const block = await web3.eth.getBlock('latest');
1445-
rebalanceTimestamp = new BigNumber(block.timestamp);
14461443

14471444
subjectTradingPool = twapRebalancingSetToken.address;
14481445
});
@@ -1475,7 +1472,7 @@ describe('ProtocolViewer', () => {
14751472
expect(rbSetData.totalSetsRemaining).to.be.bignumber.equal(startingCurrentSets);
14761473
expect(rbSetData.chunkSize).to.be.bignumber.equal(startingCurrentSets);
14771474
expect(rbSetData.chunkAuctionPeriod).to.be.bignumber.equal(chunkAuctionPeriod);
1478-
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(rebalanceTimestamp.sub(chunkAuctionPeriod));
1475+
expect(rbSetData.lastChunkAuctionEnd).to.be.bignumber.equal(ZERO);
14791476
});
14801477

14811478
it('fetches the correct CollateralSet data', async () => {

test/integration/wrappers/set_protocol/TWAPLiquidatorWrapper.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,15 @@ describe('TWAPLiquidatorWrapper', () => {
159159
);
160160

161161
const auctionPeriod = ONE_HOUR_IN_SECONDS;
162-
const rangeStart = new BigNumber(10); // 10% above fair value
163-
const rangeEnd = new BigNumber(10); // 10% below fair value
162+
const rangeStart = ether(.01);
163+
const rangeEnd = ether(.23);
164164
const name = 'liquidator';
165-
const assetPairHashes = [
166-
liquidatorHelper.generateAssetPairHashes(wrappedETH.address, wrappedBTC.address),
167-
];
168165
const assetPairBounds = [
169-
{min: ether(10 ** 4).toString(), max: ether(10 ** 6).toString()},
166+
{
167+
assetOne: wrappedETH.address,
168+
assetTwo: wrappedBTC.address,
169+
bounds: {lower: ether(10 ** 4).toString(), upper: ether(10 ** 6).toString()},
170+
},
170171
];
171172
liquidator = await deployTWAPLiquidatorAsync(
172173
web3,
@@ -175,7 +176,6 @@ describe('TWAPLiquidatorWrapper', () => {
175176
auctionPeriod,
176177
rangeStart,
177178
rangeEnd,
178-
assetPairHashes,
179179
assetPairBounds,
180180
name
181181
);

yarn.lock

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6594,10 +6594,36 @@ set-protocol-contract-utils@^1.0.3:
65946594
web3-utils "1.0.0-beta.36"
65956595
zos-lib "^2.4.2"
65966596

6597-
[email protected], set-protocol-contracts@^1.4.9-beta:
6598-
version "1.4.9-beta"
6599-
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.9-beta.tgz#7907185d61451552916efa606b4a25e1d8df9ca6"
6600-
integrity sha512-D186K1DhlhRmIDRyHMmok/NtKZZqA2CSkkjTKYA0JDzuwgiASR5s4+LwRyRSZ7qJS+wnSRVMSUxOSo//c6kPNw==
6597+
set-protocol-contract-utils@^1.0.4:
6598+
version "1.0.4"
6599+
resolved "https://registry.yarnpkg.com/set-protocol-contract-utils/-/set-protocol-contract-utils-1.0.4.tgz#ed70ce3b4fa187d6cde83f618100772ee7a854bd"
6600+
integrity sha512-+nqc/+OEbMFgq4f1l11Vvfq2ax9GT81xoyyr6owwAsf0p4uRGHEdrFKujlIBEDoEUCnkLzF3yvsU1j7VTTEnLA==
6601+
dependencies:
6602+
bn-chai "^1.0.1"
6603+
canonical-weth "^1.3.1"
6604+
dotenv "^6.2.0"
6605+
eth-gas-reporter "^0.1.10"
6606+
ethlint "^1.2.3"
6607+
expect "^24.1.0"
6608+
fs-extra "^5.0.0"
6609+
husky "^0.14.3"
6610+
lint-staged "^7.2.0"
6611+
module-alias "^2.1.0"
6612+
openzeppelin-solidity "^2.2"
6613+
set-protocol-utils "^1.0.0-beta.45"
6614+
tiny-promisify "^1.0.0"
6615+
truffle-flattener "^1.4.2"
6616+
ts-mocha "^6.0.0"
6617+
ts-node "^8.0.2"
6618+
tslint-eslint-rules "^5.3.1"
6619+
web3 "1.0.0-beta.36"
6620+
web3-utils "1.0.0-beta.36"
6621+
zos-lib "^2.4.2"
6622+
6623+
6624+
version "1.4.11-beta"
6625+
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.11-beta.tgz#d7620308ba6b2d44b5bb4d7fa959445085f8db6e"
6626+
integrity sha512-irCc6hf37b24BlLNPCTCzkH1nwjGipITdw7w7QAr85lg45FJVYwd1LGsZ7hibd5JiPHz432fhPzhCZlQXuWm2w==
66016627
dependencies:
66026628
bn-chai "^1.0.1"
66036629
canonical-weth "^1.3.1"
@@ -6611,7 +6637,7 @@ [email protected], set-protocol-contracts@^1.4.9-beta:
66116637
minify-all "^1.2.2"
66126638
module-alias "^2.1.0"
66136639
openzeppelin-solidity "^2.2"
6614-
set-protocol-contract-utils "^1.0.3"
6640+
set-protocol-contract-utils "^1.0.4"
66156641
set-protocol-oracles "^1.0.16"
66166642
set-protocol-utils "^1.1.2"
66176643
tiny-promisify "^1.0.0"
@@ -6652,6 +6678,35 @@ set-protocol-contracts@^1.4.5-beta:
66526678
web3-utils "1.0.0-beta.36"
66536679
zos-lib "^2.4.2"
66546680

6681+
set-protocol-contracts@^1.4.9-beta:
6682+
version "1.4.9-beta"
6683+
resolved "https://registry.yarnpkg.com/set-protocol-contracts/-/set-protocol-contracts-1.4.9-beta.tgz#7907185d61451552916efa606b4a25e1d8df9ca6"
6684+
integrity sha512-D186K1DhlhRmIDRyHMmok/NtKZZqA2CSkkjTKYA0JDzuwgiASR5s4+LwRyRSZ7qJS+wnSRVMSUxOSo//c6kPNw==
6685+
dependencies:
6686+
bn-chai "^1.0.1"
6687+
canonical-weth "^1.3.1"
6688+
dotenv "^6.2.0"
6689+
eth-gas-reporter "^0.1.10"
6690+
ethlint "^1.2.3"
6691+
expect "^24.1.0"
6692+
fs-extra "^5.0.0"
6693+
husky "^0.14.3"
6694+
lint-staged "^7.2.0"
6695+
minify-all "^1.2.2"
6696+
module-alias "^2.1.0"
6697+
openzeppelin-solidity "^2.2"
6698+
set-protocol-contract-utils "^1.0.3"
6699+
set-protocol-oracles "^1.0.16"
6700+
set-protocol-utils "^1.1.2"
6701+
tiny-promisify "^1.0.0"
6702+
truffle-flattener "^1.4.0"
6703+
ts-mocha "^6.0.0"
6704+
ts-node "^8.0.2"
6705+
tslint-eslint-rules "^5.3.1"
6706+
web3 "1.0.0-beta.36"
6707+
web3-utils "1.0.0-beta.36"
6708+
zos-lib "^2.4.2"
6709+
66556710
set-protocol-oracles@^1.0.16:
66566711
version "1.0.16"
66576712
resolved "https://registry.yarnpkg.com/set-protocol-oracles/-/set-protocol-oracles-1.0.16.tgz#15f1cb497feadc10673eb9193406bdd9c33ee3d6"

0 commit comments

Comments
 (0)