From 303c254dffda612d90e5889943ce5f1080600d1f Mon Sep 17 00:00:00 2001 From: byshape Date: Tue, 28 Nov 2023 16:54:11 +0000 Subject: [PATCH] Renamed minReturn => threshold --- test/ChainLinkExample.js | 8 +++---- test/DutchAuctionCalculator.js | 12 +++++----- test/Interactions.js | 26 ++++++++++----------- test/LimitOrderProtocol.js | 42 +++++++++++++++++----------------- test/PriorityFeeLimiter.js | 2 +- test/RangeLimitOrders.js | 8 +++---- test/helpers/orderUtils.js | 4 ++-- 7 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/ChainLinkExample.js b/test/ChainLinkExample.js index e1f6d96d..e790ac51 100644 --- a/test/ChainLinkExample.js +++ b/test/ChainLinkExample.js @@ -67,7 +67,7 @@ describe('ChainLinkExample', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: ether('4040.01'), + threshold: ether('4040.01'), }); const fillTx = swap.fillOrderArgs(order, r, vs, ether('1'), takerTraits.traits, takerTraits.args); await expect(fillTx).to.changeTokenBalances(dai, [addr, addr1], [ether('-4040'), ether('4040')]); @@ -102,7 +102,7 @@ describe('ChainLinkExample', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: takingAmount.add(ether('0.01')), + threshold: takingAmount.add(ether('0.01')), }); const fillTx = swap.fillOrderArgs(order, r, vs, makingAmount, takerTraits.traits, takerTraits.args); await expect(fillTx).to.changeTokenBalances(dai, [addr, addr1], [takingAmount.mul(-1), takingAmount]); @@ -134,7 +134,7 @@ describe('ChainLinkExample', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: takingAmount.add(ether('0.01')), + threshold: takingAmount.add(ether('0.01')), }); await expect( swap.fillOrderArgs(order, r, vs, makingAmount, takerTraits.traits, takerTraits.args), // taking threshold = exact taker amount + eps @@ -169,7 +169,7 @@ describe('ChainLinkExample', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: takingAmount, + threshold: takingAmount, }); const fillTx = swap.fillOrderArgs(order, r, vs, makingAmount, takerTraits.traits, takerTraits.args); await expect(fillTx).to.changeTokenBalances(dai, [addr, addr1], [takingAmount.mul(-1), takingAmount]); diff --git a/test/DutchAuctionCalculator.js b/test/DutchAuctionCalculator.js index 110d6f36..751ffb23 100644 --- a/test/DutchAuctionCalculator.js +++ b/test/DutchAuctionCalculator.js @@ -68,7 +68,7 @@ describe('Dutch auction', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: ether('0.08'), + threshold: ether('0.08'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('100'), takerTraits.traits, takerTraits.args); @@ -86,7 +86,7 @@ describe('Dutch auction', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ extension: order.extension, - minReturn: ether('100'), + threshold: ether('100'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('0.075'), takerTraits.traits, takerTraits.args); @@ -103,7 +103,7 @@ describe('Dutch auction', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: ether('0.1'), + threshold: ether('0.1'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('100'), takerTraits.traits, takerTraits.args); @@ -119,7 +119,7 @@ describe('Dutch auction', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ extension: order.extension, - minReturn: ether('100'), + threshold: ether('100'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('0.1'), takerTraits.traits, takerTraits.args); @@ -138,7 +138,7 @@ describe('Dutch auction', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: ether('0.05'), + threshold: ether('0.05'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('100'), takerTraits.traits, takerTraits.args); @@ -156,7 +156,7 @@ describe('Dutch auction', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ extension: order.extension, - minReturn: ether('100'), + threshold: ether('100'), }); await swap.connect(addr1).fillOrderArgs(order, r, vs, ether('0.05'), takerTraits.traits, takerTraits.args); diff --git a/test/Interactions.js b/test/Interactions.js index 7bb85fa7..18ba5a2e 100644 --- a/test/Interactions.js +++ b/test/Interactions.js @@ -80,7 +80,7 @@ describe('Interactions', function () { const takerTraits = buildTakerTraits({ interaction: matchingParams, makingAmount: true, - minReturn: ether('100'), + threshold: ether('100'), }); const interaction = matcher.address + '00' + swap.interface.encodeFunctionData('fillOrderArgs', [ backOrder, @@ -100,7 +100,7 @@ describe('Interactions', function () { const matcherTraits = buildTakerTraits({ interaction, makingAmount: true, - minReturn: ether('0.1'), + threshold: ether('0.1'), }); await matcher.matchOrders(swap.address, order, r, vs, ether('100'), matcherTraits.traits, matcherTraits.args); @@ -154,7 +154,7 @@ describe('Interactions', function () { const takerTraits = buildTakerTraits({ interaction: matchingParams, makingAmount: true, - minReturn: ether('0.015'), + threshold: ether('0.015'), }); const interaction = matcher.address + '00' + swap.interface.encodeFunctionData('fillOrderArgs', [ backOrder, @@ -175,7 +175,7 @@ describe('Interactions', function () { const matcherTraits = buildTakerTraits({ interaction, makingAmount: true, - minReturn: ether('0.01'), + threshold: ether('0.01'), }); await matcher.matchOrders(swap.address, order, r, vs, ether('10'), matcherTraits.traits, matcherTraits.args); @@ -237,7 +237,7 @@ describe('Interactions', function () { const internalTakerTraits = buildTakerTraits({ interaction: matchingParams, makingAmount: true, - minReturn: ether('25'), + threshold: ether('25'), }); const internalInteraction = matcher.address + '00' + swap.interface.encodeFunctionData('fillOrderArgs', [ backOrder, @@ -252,7 +252,7 @@ describe('Interactions', function () { const externalTakerTraits = buildTakerTraits({ interaction: internalInteraction, makingAmount: true, - minReturn: ether('25'), + threshold: ether('25'), }); const externalInteraction = matcher.address + '00' + swap.interface.encodeFunctionData('fillOrderArgs', [ order2, @@ -272,7 +272,7 @@ describe('Interactions', function () { const matcherTraits = buildTakerTraits({ interaction: externalInteraction, makingAmount: true, - minReturn: ether('0.01'), + threshold: ether('0.01'), }); await matcher.matchOrders(swap.address, order1, r, vs, ether('10'), matcherTraits.traits, matcherTraits.args); @@ -321,7 +321,7 @@ describe('Interactions', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); @@ -354,7 +354,7 @@ describe('Interactions', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); @@ -400,7 +400,7 @@ describe('Interactions', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); @@ -412,7 +412,7 @@ describe('Interactions', function () { expect(await dai.balanceOf(addr1.address)).to.equal(addr1dai.add(ether('50'))); const takerTraits2 = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); @@ -467,7 +467,7 @@ describe('Interactions', function () { const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); @@ -480,7 +480,7 @@ describe('Interactions', function () { const { r: r2, _vs: vs2 } = ethers.utils.splitSignature(signaturePartial); const takerTraits2 = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), makingAmount: true, extension: order.extension, }); diff --git a/test/LimitOrderProtocol.js b/test/LimitOrderProtocol.js index 0b8a7314..934f70d1 100644 --- a/test/LimitOrderProtocol.js +++ b/test/LimitOrderProtocol.js @@ -290,7 +290,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 10n, + threshold: 10n, makingAmount: true, extension: order.extension, }); @@ -421,7 +421,7 @@ describe('LimitOrderProtocol', function () { const permit = await getPermit(addr.address, addr, weth, '1', chainId, swap.address, '1'); const { r, _vs: vs } = ethers.utils.splitSignature(signature); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, makingAmount: true, }); const fillTx = swap.permitAndCall( @@ -445,7 +445,7 @@ describe('LimitOrderProtocol', function () { const permit = await getPermit(addr.address, addr, weth, '1', chainId, swap.address, '1', deadline); const { r, _vs: vs } = ethers.utils.splitSignature(signature); - const takerTraits = buildTakerTraits({ minReturn: 1n }); + const takerTraits = buildTakerTraits({ threshold: 1n }); const fillTx = swap.permitAndCall( ethers.utils.solidityPack( @@ -467,7 +467,7 @@ describe('LimitOrderProtocol', function () { const permit = await getPermit(addr.address, addr, weth, '1', chainId, swap.address, '1', deadline); const { r, _vs: vs } = ethers.utils.splitSignature(signature); - const takerTraits = buildTakerTraits({ minReturn: 1n }); + const takerTraits = buildTakerTraits({ threshold: 1n }); await expect(swap.permitAndCall( ethers.utils.solidityPack( ['address', 'bytes'], @@ -518,7 +518,7 @@ describe('LimitOrderProtocol', function () { const { dai, weth, swap, order, r, vs } = await loadFixture(deployContractsAndInitPermit); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, makingAmount: true, extension: order.extension, }); @@ -534,7 +534,7 @@ describe('LimitOrderProtocol', function () { await time.increaseTo(deadline + 1); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, makingAmount: true, extension: order.extension, }); @@ -549,7 +549,7 @@ describe('LimitOrderProtocol', function () { await time.increaseTo(deadline + 1); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, makingAmount: true, extension: order.extension, }); @@ -563,7 +563,7 @@ describe('LimitOrderProtocol', function () { await addr1.sendTransaction({ to: weth.address, data: '0xd505accf' + permit.substring(42) }); const takerTraits = buildTakerTraits({ - minReturn: 0n, + threshold: 0n, skipMakerPermit: true, extension: order.extension, }); @@ -697,7 +697,7 @@ describe('LimitOrderProtocol', function () { /// Partial fill const takerTraits1 = buildTakerTraits({ - minReturn: ether('0.2'), + threshold: ether('0.2'), extension: order.extension, }); const fillTx1 = swap.fillContractOrderArgs(order, signature, ether('200'), takerTraits1.traits, takerTraits1.args); @@ -706,7 +706,7 @@ describe('LimitOrderProtocol', function () { /// Remaining fill const takerTraits2 = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), extension: order.extension, }); const fillTx2 = swap.fillContractOrderArgs(order, signature, ether('100'), takerTraits2.traits, takerTraits2.args); @@ -743,7 +743,7 @@ describe('LimitOrderProtocol', function () { /// Partial fill const fillTakerTraits = buildTakerTraits({ - minReturn: ether('0.2'), + threshold: ether('0.2'), extension: order.extension, }); const fillTx = swap.fillContractOrderArgs(order, signature, ether('200'), fillTakerTraits.traits, fillTakerTraits.args); @@ -757,7 +757,7 @@ describe('LimitOrderProtocol', function () { /// Remaining fill failure const takerTraits = buildTakerTraits({ - minReturn: ether('0.1'), + threshold: ether('0.1'), extension: order.extension, }); await expect(swap.fillContractOrderArgs(order, signature, ether('100'), takerTraits.traits, takerTraits.args)) @@ -1127,7 +1127,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); const fillTx = swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args); @@ -1159,7 +1159,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) @@ -1194,7 +1194,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); const fillTx = swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args); @@ -1230,7 +1230,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) @@ -1265,7 +1265,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); const fillTx = swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args); @@ -1301,7 +1301,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension, }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) @@ -1332,7 +1332,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) .to.be.revertedWithCustomError(orderLibFactory, 'MissingOrderExtension'); @@ -1362,7 +1362,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: order.extension + '0011223344', }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) @@ -1384,7 +1384,7 @@ describe('LimitOrderProtocol', function () { const { r, _vs: vs } = ethers.utils.splitSignature(await signOrder(order, chainId, swap.address, addr1)); const takerTraits = buildTakerTraits({ - minReturn: 1n, + threshold: 1n, extension: '0xabacabac', }); await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args)) diff --git a/test/PriorityFeeLimiter.js b/test/PriorityFeeLimiter.js index 13c647f1..5c2a87c7 100644 --- a/test/PriorityFeeLimiter.js +++ b/test/PriorityFeeLimiter.js @@ -47,7 +47,7 @@ describe('PriorityFeeLimiter', function () { const takerTraits = buildTakerTraits({ makingAmount: true, extension: order.extension, - minReturn: order.takingAmount, + threshold: order.takingAmount, }); return { dai, weth, swap, order, r, vs, takerTraits }; diff --git a/test/RangeLimitOrders.js b/test/RangeLimitOrders.js index 701b07bb..e4c2443a 100644 --- a/test/RangeLimitOrders.js +++ b/test/RangeLimitOrders.js @@ -98,7 +98,7 @@ describe('RangeLimitOrders', function () { // first fill order const takerTraits = buildTakerTraits({ - minReturn: makerAsset.parseAmount(fillParams.firstFill.thresholdAmount), + threshold: makerAsset.parseAmount(fillParams.firstFill.thresholdAmount), extension: order.extension, }); let fillOrder = swap.fillOrderArgs( @@ -129,7 +129,7 @@ describe('RangeLimitOrders', function () { // second fill order const secondTakerTraits = buildTakerTraits({ - minReturn: makerAsset.parseAmount(fillParams.secondFill.thresholdAmount), + threshold: makerAsset.parseAmount(fillParams.secondFill.thresholdAmount), extension: order.extension, }); fillOrder = swap.fillOrderArgs( @@ -179,7 +179,7 @@ describe('RangeLimitOrders', function () { // first fill order const takerTraits = buildTakerTraits({ - minReturn: takerAsset.parseAmount(fillParams.firstFill.thresholdAmount), + threshold: takerAsset.parseAmount(fillParams.firstFill.thresholdAmount), makingAmount: true, extension: order.extension, }); @@ -211,7 +211,7 @@ describe('RangeLimitOrders', function () { // second fill order const secondTakerTraits = buildTakerTraits({ - minReturn: takerAsset.parseAmount(fillParams.secondFill.thresholdAmount), + threshold: takerAsset.parseAmount(fillParams.secondFill.thresholdAmount), makingAmount: true, extension: order.extension, }); diff --git a/test/helpers/orderUtils.js b/test/helpers/orderUtils.js index eb46361a..299fb995 100644 --- a/test/helpers/orderUtils.js +++ b/test/helpers/orderUtils.js @@ -54,10 +54,10 @@ function buildTakerTraits ({ target = '0x', extension = '0x', interaction = '0x', - minReturn = 0n, + threshold = 0n, } = {}) { return { - traits: BigInt(minReturn) | ( + traits: BigInt(threshold) | ( (makingAmount ? TakerTraitsConstants._MAKER_AMOUNT_FLAG : 0n) | (unwrapWeth ? TakerTraitsConstants._UNWRAP_WETH_FLAG : 0n) | (skipMakerPermit ? TakerTraitsConstants._SKIP_ORDER_PERMIT_FLAG : 0n) |