Skip to content

Commit

Permalink
Merge pull request #290 from 1inch/chore/SC-970-rename-minReturn-para…
Browse files Browse the repository at this point in the history
…m-to-threshold-in-buildTakerTraits

[SC-970] Rename minReturn param to threshold in buildTakerTraits
  • Loading branch information
ZumZoom authored Dec 5, 2023
2 parents 80eeeda + 303c254 commit c454e0f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions test/ChainLinkExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')]);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down
12 changes: 6 additions & 6 deletions test/DutchAuctionCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
26 changes: 13 additions & 13 deletions test/Interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand Down
42 changes: 21 additions & 21 deletions test/LimitOrderProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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'],
Expand Down Expand Up @@ -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,
});
Expand All @@ -534,7 +534,7 @@ describe('LimitOrderProtocol', function () {
await time.increaseTo(deadline + 1);

const takerTraits = buildTakerTraits({
minReturn: 1n,
threshold: 1n,
makingAmount: true,
extension: order.extension,
});
Expand All @@ -549,7 +549,7 @@ describe('LimitOrderProtocol', function () {
await time.increaseTo(deadline + 1);

const takerTraits = buildTakerTraits({
minReturn: 1n,
threshold: 1n,
makingAmount: true,
extension: order.extension,
});
Expand All @@ -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,
});
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
Loading

0 comments on commit c454e0f

Please sign in to comment.