@1inch/fusion-sdk 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/api/fusion-api.d.ts +25 -16
  2. package/api/fusion-api.js +36 -26
  3. package/api/index.d.ts +4 -4
  4. package/api/index.js +8 -8
  5. package/api/orders/index.d.ts +3 -3
  6. package/api/orders/index.js +7 -7
  7. package/api/orders/order-api.spec.d.ts +1 -1
  8. package/api/orders/order-api.spec.js +479 -395
  9. package/api/orders/order-api.spec.js.map +1 -1
  10. package/api/orders/orders.api.d.ts +24 -10
  11. package/api/orders/orders.api.js +30 -28
  12. package/api/orders/orders.request.d.ts +22 -18
  13. package/api/orders/orders.request.js +40 -31
  14. package/api/orders/types.d.ts +59 -57
  15. package/api/orders/types.js +17 -16
  16. package/api/orders/types.js.map +1 -1
  17. package/api/pagination.d.ts +7 -7
  18. package/api/pagination.js +10 -10
  19. package/api/pagination.spec.d.ts +1 -1
  20. package/api/pagination.spec.js +28 -21
  21. package/api/params.d.ts +3 -1
  22. package/api/params.js +25 -19
  23. package/api/quoter/index.d.ts +5 -5
  24. package/api/quoter/index.js +9 -9
  25. package/api/quoter/preset.d.ts +13 -13
  26. package/api/quoter/preset.js +19 -17
  27. package/api/quoter/quote/index.d.ts +3 -3
  28. package/api/quoter/quote/index.js +7 -7
  29. package/api/quoter/quote/order-params.d.ts +6 -6
  30. package/api/quoter/quote/order-params.js +12 -12
  31. package/api/quoter/quote/quote.d.ts +26 -21
  32. package/api/quoter/quote/quote.js +85 -52
  33. package/api/quoter/quote/quote.js.map +1 -1
  34. package/api/quoter/quote/types.d.ts +4 -4
  35. package/api/quoter/quote/types.js +3 -3
  36. package/api/quoter/quoter.api.d.ts +12 -9
  37. package/api/quoter/quoter.api.js +19 -19
  38. package/api/quoter/quoter.api.spec.d.ts +1 -1
  39. package/api/quoter/quoter.api.spec.js +32 -23
  40. package/api/quoter/quoter.api.spec.js.map +1 -1
  41. package/api/quoter/quoter.request.d.ts +11 -11
  42. package/api/quoter/quoter.request.js +28 -26
  43. package/api/quoter/types.d.ts +45 -44
  44. package/api/quoter/types.js +10 -10
  45. package/api/quoter/types.js.map +1 -1
  46. package/api/relayer/index.d.ts +3 -3
  47. package/api/relayer/index.js +7 -7
  48. package/api/relayer/relayer.api.d.ts +12 -9
  49. package/api/relayer/relayer.api.js +13 -13
  50. package/api/relayer/relayer.api.spec.d.ts +1 -1
  51. package/api/relayer/relayer.api.spec.js +96 -79
  52. package/api/relayer/relayer.request.d.ts +8 -8
  53. package/api/relayer/relayer.request.js +10 -10
  54. package/api/relayer/types.d.ts +9 -9
  55. package/api/relayer/types.js +3 -3
  56. package/api/types.d.ts +17 -15
  57. package/api/types.js +3 -3
  58. package/auction-calculator/auction-calculator.d.ts +22 -13
  59. package/auction-calculator/auction-calculator.js +70 -45
  60. package/auction-calculator/auction-calculator.spec.d.ts +1 -1
  61. package/auction-calculator/auction-calculator.spec.js +45 -32
  62. package/auction-calculator/calc.d.ts +8 -2
  63. package/auction-calculator/calc.js +12 -12
  64. package/auction-calculator/constants.d.ts +1 -1
  65. package/auction-calculator/constants.js +5 -5
  66. package/auction-calculator/index.d.ts +3 -3
  67. package/auction-calculator/index.js +7 -7
  68. package/auction-salt/auction-salt.d.ts +9 -9
  69. package/auction-salt/auction-salt.js +34 -23
  70. package/auction-salt/auction.salt.spec.d.ts +1 -1
  71. package/auction-salt/auction.salt.spec.js +38 -27
  72. package/auction-salt/index.d.ts +3 -3
  73. package/auction-salt/index.js +7 -7
  74. package/auction-salt/parser/constants.d.ts +9 -9
  75. package/auction-salt/parser/constants.js +33 -14
  76. package/auction-salt/parser/index.d.ts +2 -2
  77. package/auction-salt/parser/index.js +6 -6
  78. package/auction-salt/parser/parser.d.ts +6 -6
  79. package/auction-salt/parser/parser.js +33 -22
  80. package/auction-salt/types.d.ts +6 -6
  81. package/auction-salt/types.js +3 -3
  82. package/auction-suffix/auction-suffix.d.ts +9 -9
  83. package/auction-suffix/auction-suffix.js +36 -23
  84. package/auction-suffix/auction-suffix.spec.d.ts +1 -1
  85. package/auction-suffix/auction-suffix.spec.js +20 -15
  86. package/auction-suffix/constants.d.ts +1 -1
  87. package/auction-suffix/constants.js +5 -5
  88. package/auction-suffix/encoder.d.ts +15 -6
  89. package/auction-suffix/encoder.js +45 -28
  90. package/auction-suffix/index.d.ts +5 -5
  91. package/auction-suffix/index.js +9 -9
  92. package/auction-suffix/parser/constants.d.ts +13 -13
  93. package/auction-suffix/parser/constants.js +30 -17
  94. package/auction-suffix/parser/errors.d.ts +1 -2
  95. package/auction-suffix/parser/errors.js +6 -7
  96. package/auction-suffix/parser/index.d.ts +4 -4
  97. package/auction-suffix/parser/index.js +8 -8
  98. package/auction-suffix/parser/parser.d.ts +28 -8
  99. package/auction-suffix/parser/parser.js +162 -81
  100. package/auction-suffix/parser/types.d.ts +22 -22
  101. package/auction-suffix/parser/types.js +3 -3
  102. package/auction-suffix/types.d.ts +12 -12
  103. package/auction-suffix/types.js +3 -3
  104. package/connector/blockchain/blockchain-provider.connector.d.ts +6 -3
  105. package/connector/blockchain/blockchain-provider.connector.js +3 -3
  106. package/connector/blockchain/index.d.ts +3 -3
  107. package/connector/blockchain/index.js +7 -7
  108. package/connector/blockchain/private-key-provider.connector.d.ts +15 -10
  109. package/connector/blockchain/private-key-provider.connector.js +12 -12
  110. package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
  111. package/connector/blockchain/private-key-provider.connector.spec.js +36 -23
  112. package/connector/blockchain/web3-provider-connector.d.ts +13 -8
  113. package/connector/blockchain/web3-provider-connector.js +12 -9
  114. package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
  115. package/connector/blockchain/web3-provider.connector.spec.js +37 -26
  116. package/connector/http/axios-provider.connector.d.ts +3 -3
  117. package/connector/http/axios-provider.connector.js +13 -13
  118. package/connector/http/axios-provider.connector.spec.d.ts +1 -1
  119. package/connector/http/axios-provider.connector.spec.js +37 -31
  120. package/connector/http/http-provider.connector.d.ts +2 -2
  121. package/connector/http/http-provider.connector.js +3 -3
  122. package/connector/http/index.d.ts +2 -2
  123. package/connector/http/index.js +6 -6
  124. package/connector/index.d.ts +2 -2
  125. package/connector/index.js +6 -6
  126. package/constants.d.ts +10 -6
  127. package/constants.js +23 -16
  128. package/fusion-order/fusion-order.d.ts +17 -7
  129. package/fusion-order/fusion-order.js +14 -12
  130. package/fusion-order/fusion-order.spec.d.ts +1 -1
  131. package/fusion-order/fusion-order.spec.js +27 -22
  132. package/fusion-order/index.d.ts +1 -1
  133. package/fusion-order/index.js +5 -5
  134. package/index.d.ts +11 -11
  135. package/index.js +15 -15
  136. package/limit-order/eip712/domain.d.ts +10 -9
  137. package/limit-order/eip712/domain.js +28 -23
  138. package/limit-order/eip712/eip712.types.d.ts +19 -15
  139. package/limit-order/eip712/eip712.types.js +3 -3
  140. package/limit-order/eip712/index.d.ts +3 -3
  141. package/limit-order/eip712/index.js +7 -7
  142. package/limit-order/eip712/order-typed-data-builder.d.ts +17 -6
  143. package/limit-order/eip712/order-typed-data-builder.js +34 -19
  144. package/limit-order/index.d.ts +4 -4
  145. package/limit-order/index.js +8 -8
  146. package/limit-order/interactions-factory.d.ts +1 -1
  147. package/limit-order/interactions-factory.js +6 -6
  148. package/limit-order/limit-order.d.ts +31 -25
  149. package/limit-order/limit-order.js +103 -50
  150. package/limit-order/limit-order.spec.d.ts +1 -1
  151. package/limit-order/limit-order.spec.js +75 -51
  152. package/limit-order/parser/constants.d.ts +9 -9
  153. package/limit-order/parser/constants.js +5 -5
  154. package/limit-order/parser/index.d.ts +3 -3
  155. package/limit-order/parser/index.js +7 -7
  156. package/limit-order/parser/parser.d.ts +5 -2
  157. package/limit-order/parser/parser.js +23 -18
  158. package/limit-order/parser/types.d.ts +3 -3
  159. package/limit-order/parser/types.js +3 -3
  160. package/limit-order/predicate-factory.d.ts +9 -5
  161. package/limit-order/predicate-factory.js +40 -24
  162. package/limit-order/predicate-factory.spec.d.ts +1 -1
  163. package/limit-order/predicate-factory.spec.js +44 -29
  164. package/limit-order/types.d.ts +29 -29
  165. package/limit-order/types.js +3 -3
  166. package/limit-order/utils.d.ts +1 -1
  167. package/limit-order/utils.js +6 -6
  168. package/package.json +2 -3
  169. package/sdk/index.d.ts +2 -2
  170. package/sdk/index.js +6 -6
  171. package/sdk/sdk.d.ts +29 -11
  172. package/sdk/sdk.js +48 -38
  173. package/sdk/types.d.ts +27 -27
  174. package/sdk/types.js +3 -3
  175. package/settlement/encoders/constants.d.ts +1 -1
  176. package/settlement/encoders/constants.js +5 -5
  177. package/settlement/encoders/fill-order.encoder.d.ts +2 -2
  178. package/settlement/encoders/fill-order.encoder.js +26 -12
  179. package/settlement/encoders/index.d.ts +3 -3
  180. package/settlement/encoders/index.js +7 -7
  181. package/settlement/encoders/settlement.encoder.d.ts +13 -4
  182. package/settlement/encoders/settlement.encoder.js +41 -19
  183. package/settlement/index.d.ts +4 -4
  184. package/settlement/index.js +8 -8
  185. package/settlement/settlement.d.ts +8 -5
  186. package/settlement/settlement.js +28 -14
  187. package/settlement/settlement.spec.d.ts +1 -1
  188. package/settlement/settlement.spec.js +45 -35
  189. package/settlement/signature-patcher.d.ts +1 -1
  190. package/settlement/signature-patcher.js +19 -16
  191. package/settlement/types.d.ts +13 -13
  192. package/settlement/types.js +3 -3
  193. package/utils.d.ts +6 -6
  194. package/utils.js +29 -23
  195. package/validations.d.ts +2 -2
  196. package/validations.js +14 -15
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RelayerRequest = void 0;
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ exports.RelayerRequest = void 0
4
4
  class RelayerRequest {
5
5
  constructor(params) {
6
- this.order = params.order;
7
- this.signature = params.signature;
8
- this.quoteId = params.quoteId;
6
+ this.order = params.order
7
+ this.signature = params.signature
8
+ this.quoteId = params.quoteId
9
9
  }
10
10
  static new(params) {
11
- return new RelayerRequest(params);
11
+ return new RelayerRequest(params)
12
12
  }
13
13
  build() {
14
14
  return {
15
15
  order: this.order,
16
16
  signature: this.signature,
17
17
  quoteId: this.quoteId
18
- };
18
+ }
19
19
  }
20
20
  }
21
- exports.RelayerRequest = RelayerRequest;
22
- //# sourceMappingURL=relayer.request.js.map
21
+ exports.RelayerRequest = RelayerRequest
22
+ //# sourceMappingURL=relayer.request.js.map
@@ -1,11 +1,11 @@
1
- import { NetworkEnum } from '../../constants';
2
- import { LimitOrderV3Struct } from '../../limit-order';
1
+ import {NetworkEnum} from '../../constants'
2
+ import {LimitOrderV3Struct} from '../../limit-order'
3
3
  export declare type RelayerRequestParams = {
4
- order: LimitOrderV3Struct;
5
- signature: string;
6
- quoteId: string;
7
- };
4
+ order: LimitOrderV3Struct
5
+ signature: string
6
+ quoteId: string
7
+ }
8
8
  export declare type RelayerApiConfig = {
9
- network: NetworkEnum;
10
- url: string;
11
- };
9
+ network: NetworkEnum
10
+ url: string
11
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ //# sourceMappingURL=types.js.map
package/api/types.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- import { NetworkEnum } from '../constants';
2
- import { HttpProviderConnector } from '../connector';
1
+ import {NetworkEnum} from '../constants'
2
+ import {HttpProviderConnector} from '../connector'
3
3
  export declare type FusionApiConfig = {
4
- url: string;
5
- network: NetworkEnum;
6
- httpProvider?: HttpProviderConnector;
7
- };
4
+ url: string
5
+ network: NetworkEnum
6
+ httpProvider?: HttpProviderConnector
7
+ }
8
8
  export declare type PaginationMeta = {
9
- totalItems: number;
10
- itemsPerPage: number;
11
- totalPages: number;
12
- currentPage: number;
13
- };
14
- export declare type PaginationOutput<T extends Record<string, any> = Record<string, any>> = {
15
- meta: PaginationMeta;
16
- items: T[];
17
- };
9
+ totalItems: number
10
+ itemsPerPage: number
11
+ totalPages: number
12
+ currentPage: number
13
+ }
14
+ export declare type PaginationOutput<
15
+ T extends Record<string, any> = Record<string, any>
16
+ > = {
17
+ meta: PaginationMeta
18
+ items: T[]
19
+ }
package/api/types.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ //# sourceMappingURL=types.js.map
@@ -1,19 +1,28 @@
1
- import { AuctionPoint, AuctionSuffix } from '../auction-suffix';
2
- import { LimitOrderV3Struct } from '../limit-order';
3
- import { AuctionSalt } from '../auction-salt';
1
+ import {AuctionPoint, AuctionSuffix} from '../auction-suffix'
2
+ import {LimitOrderV3Struct} from '../limit-order'
3
+ import {AuctionSalt} from '../auction-salt'
4
4
  export declare class AuctionCalculator {
5
- private readonly startTime;
6
- private readonly duration;
7
- private readonly initialRateBump;
8
- private readonly points;
9
- private readonly takerFeeRatio;
10
- constructor(startTime: number, duration: number, initialRateBump: number, points: AuctionPoint[], takerFeeRatio: string);
11
- static fromLimitOrderV3Struct(order: LimitOrderV3Struct): AuctionCalculator;
12
- static fromAuctionData(suffix: AuctionSuffix, salt: AuctionSalt): AuctionCalculator;
13
- calcAuctionTakingAmount(takingAmount: string, rate: number): string;
5
+ private readonly startTime
6
+ private readonly duration
7
+ private readonly initialRateBump
8
+ private readonly points
9
+ private readonly takerFeeRatio
10
+ constructor(
11
+ startTime: number,
12
+ duration: number,
13
+ initialRateBump: number,
14
+ points: AuctionPoint[],
15
+ takerFeeRatio: string
16
+ )
17
+ static fromLimitOrderV3Struct(order: LimitOrderV3Struct): AuctionCalculator
18
+ static fromAuctionData(
19
+ suffix: AuctionSuffix,
20
+ salt: AuctionSalt
21
+ ): AuctionCalculator
22
+ calcAuctionTakingAmount(takingAmount: string, rate: number): string
14
23
  /**
15
24
  * @see https://github.com/1inch/limit-order-settlement/blob/3c7cf9eacbaf7a60624d7a6f069c59d809f2204a/contracts/libraries/OrderSuffix.sol#L75
16
25
  * @param time auction timestamp in seconds
17
26
  */
18
- calcRateBump(time: number): number;
27
+ calcRateBump(time: number): number
19
28
  }
@@ -1,71 +1,96 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuctionCalculator = void 0;
4
- const auction_suffix_1 = require("../auction-suffix");
5
- const auction_salt_1 = require("../auction-salt");
6
- const bignumber_1 = require("@ethersproject/bignumber");
7
- const calc_1 = require("./calc");
8
- const constants_1 = require("./constants");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ exports.AuctionCalculator = void 0
4
+ const auction_suffix_1 = require('../auction-suffix')
5
+ const auction_salt_1 = require('../auction-salt')
6
+ const bignumber_1 = require('@ethersproject/bignumber')
7
+ const calc_1 = require('./calc')
8
+ const constants_1 = require('./constants')
9
9
  class AuctionCalculator {
10
10
  constructor(startTime, duration, initialRateBump, points, takerFeeRatio) {
11
- this.startTime = startTime;
12
- this.duration = duration;
13
- this.initialRateBump = initialRateBump;
14
- this.points = points;
15
- this.takerFeeRatio = takerFeeRatio;
11
+ this.startTime = startTime
12
+ this.duration = duration
13
+ this.initialRateBump = initialRateBump
14
+ this.points = points
15
+ this.takerFeeRatio = takerFeeRatio
16
16
  }
17
17
  static fromLimitOrderV3Struct(order) {
18
- const suffix = auction_suffix_1.AuctionSuffix.decode(order.interactions);
19
- const salt = auction_salt_1.AuctionSalt.decode(order.salt);
20
- return AuctionCalculator.fromAuctionData(suffix, salt);
18
+ const suffix = auction_suffix_1.AuctionSuffix.decode(order.interactions)
19
+ const salt = auction_salt_1.AuctionSalt.decode(order.salt)
20
+ return AuctionCalculator.fromAuctionData(suffix, salt)
21
21
  }
22
22
  static fromAuctionData(suffix, salt) {
23
- return new AuctionCalculator(salt.auctionStartTime, salt.duration, salt.initialRateBump, suffix.points, suffix.takerFeeRatio);
23
+ return new AuctionCalculator(
24
+ salt.auctionStartTime,
25
+ salt.duration,
26
+ salt.initialRateBump,
27
+ suffix.points,
28
+ suffix.takerFeeRatio
29
+ )
24
30
  }
25
31
  calcAuctionTakingAmount(takingAmount, rate) {
26
32
  const auctionTakingAmount = bignumber_1.BigNumber.from(takingAmount)
27
- .mul(bignumber_1.BigNumber.from(rate).add(constants_1.RATE_BUMP_DENOMINATOR))
28
- .div(constants_1.RATE_BUMP_DENOMINATOR);
33
+ .mul(
34
+ bignumber_1.BigNumber.from(rate).add(
35
+ constants_1.RATE_BUMP_DENOMINATOR
36
+ )
37
+ )
38
+ .div(constants_1.RATE_BUMP_DENOMINATOR)
29
39
  if (this.takerFeeRatio === '0') {
30
- return auctionTakingAmount.toString();
40
+ return auctionTakingAmount.toString()
31
41
  }
32
42
  return auctionTakingAmount
33
- .add(auctionTakingAmount
34
- .mul(this.takerFeeRatio)
35
- .div(auction_suffix_1.CONTRACT_TAKER_FEE_PRECISION))
36
- .toString();
43
+ .add(
44
+ auctionTakingAmount
45
+ .mul(this.takerFeeRatio)
46
+ .div(auction_suffix_1.CONTRACT_TAKER_FEE_PRECISION)
47
+ )
48
+ .toString()
37
49
  }
38
50
  /**
39
51
  * @see https://github.com/1inch/limit-order-settlement/blob/3c7cf9eacbaf7a60624d7a6f069c59d809f2204a/contracts/libraries/OrderSuffix.sol#L75
40
52
  * @param time auction timestamp in seconds
41
53
  */
42
54
  calcRateBump(time) {
43
- let cumulativeTime = bignumber_1.BigNumber.from(this.startTime);
44
- const lastTime = bignumber_1.BigNumber.from(this.duration).add(cumulativeTime);
45
- const startBump = bignumber_1.BigNumber.from(this.initialRateBump);
46
- const currentTime = bignumber_1.BigNumber.from(time);
55
+ let cumulativeTime = bignumber_1.BigNumber.from(this.startTime)
56
+ const lastTime = bignumber_1.BigNumber.from(this.duration).add(
57
+ cumulativeTime
58
+ )
59
+ const startBump = bignumber_1.BigNumber.from(this.initialRateBump)
60
+ const currentTime = bignumber_1.BigNumber.from(time)
47
61
  if (currentTime.lte(cumulativeTime)) {
48
- return this.initialRateBump;
62
+ return this.initialRateBump
63
+ } else if (currentTime.gte(lastTime)) {
64
+ return 0
49
65
  }
50
- else if (currentTime.gte(lastTime)) {
51
- return 0;
52
- }
53
- let prevCoefficient = startBump;
54
- let prevCumulativeTime = cumulativeTime;
66
+ let prevCoefficient = startBump
67
+ let prevCumulativeTime = cumulativeTime
55
68
  for (let i = this.points.length - 1; i >= 0; i--) {
56
- const { coefficient, delay } = this.points[i];
57
- cumulativeTime = cumulativeTime.add(delay);
58
- const coefficientBN = bignumber_1.BigNumber.from(coefficient);
69
+ const {coefficient, delay} = this.points[i]
70
+ cumulativeTime = cumulativeTime.add(delay)
71
+ const coefficientBN = bignumber_1.BigNumber.from(coefficient)
59
72
  if (cumulativeTime.gt(currentTime)) {
60
- const rate = (0, calc_1.linearInterpolation)(prevCumulativeTime, cumulativeTime, prevCoefficient, coefficientBN, currentTime);
61
- return rate.toNumber();
73
+ const rate = (0, calc_1.linearInterpolation)(
74
+ prevCumulativeTime,
75
+ cumulativeTime,
76
+ prevCoefficient,
77
+ coefficientBN,
78
+ currentTime
79
+ )
80
+ return rate.toNumber()
62
81
  }
63
- prevCumulativeTime = cumulativeTime;
64
- prevCoefficient = coefficientBN;
82
+ prevCumulativeTime = cumulativeTime
83
+ prevCoefficient = coefficientBN
65
84
  }
66
- const rate = (0, calc_1.linearInterpolation)(prevCumulativeTime, lastTime, prevCoefficient, bignumber_1.BigNumber.from(0), currentTime);
67
- return rate.toNumber();
85
+ const rate = (0, calc_1.linearInterpolation)(
86
+ prevCumulativeTime,
87
+ lastTime,
88
+ prevCoefficient,
89
+ bignumber_1.BigNumber.from(0),
90
+ currentTime
91
+ )
92
+ return rate.toNumber()
68
93
  }
69
94
  }
70
- exports.AuctionCalculator = AuctionCalculator;
71
- //# sourceMappingURL=auction-calculator.js.map
95
+ exports.AuctionCalculator = AuctionCalculator
96
+ //# sourceMappingURL=auction-calculator.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,35 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const auction_suffix_1 = require("../auction-suffix");
4
- const auction_salt_1 = require("../auction-salt");
5
- const auction_calculator_1 = require("./auction-calculator");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ const auction_suffix_1 = require('../auction-suffix')
4
+ const auction_salt_1 = require('../auction-salt')
5
+ const auction_calculator_1 = require('./auction-calculator')
6
6
  describe('Auction Calculator', () => {
7
7
  it('should calculate auction rate and taking amount', () => {
8
- const calculator = auction_calculator_1.AuctionCalculator.fromLimitOrderV3Struct({
9
- allowedSender: '0x0000000000000000000000000000000000000000',
10
- interactions: '0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
11
- maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
12
- makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
13
- makingAmount: '1000000000000000000',
14
- offsets: '0',
15
- receiver: '0x0000000000000000000000000000000000000000',
16
- salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
17
- takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
18
- takingAmount: '1420000000'
19
- });
20
- const rate = calculator.calcRateBump(1673548209);
21
- const auctionTakingAmount = calculator.calcAuctionTakingAmount('1420000000', rate);
22
- expect(rate).toBe(14285);
23
- expect(auctionTakingAmount).toBe('1422028470');
24
- });
8
+ const calculator =
9
+ auction_calculator_1.AuctionCalculator.fromLimitOrderV3Struct({
10
+ allowedSender: '0x0000000000000000000000000000000000000000',
11
+ interactions:
12
+ '0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
13
+ maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
14
+ makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
15
+ makingAmount: '1000000000000000000',
16
+ offsets: '0',
17
+ receiver: '0x0000000000000000000000000000000000000000',
18
+ salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
19
+ takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
20
+ takingAmount: '1420000000'
21
+ })
22
+ const rate = calculator.calcRateBump(1673548209)
23
+ const auctionTakingAmount = calculator.calcAuctionTakingAmount(
24
+ '1420000000',
25
+ rate
26
+ )
27
+ expect(rate).toBe(14285)
28
+ expect(auctionTakingAmount).toBe('1422028470')
29
+ })
25
30
  it('should be created successfully from suffix and salt', () => {
26
- const suffix = auction_suffix_1.AuctionSuffix.decode('0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009');
27
- const salt = auction_salt_1.AuctionSalt.decode('45118768841948961586167738353692277076075522015101619148498725069326976558864');
28
- const calculator = auction_calculator_1.AuctionCalculator.fromAuctionData(suffix, salt);
29
- const rate = calculator.calcRateBump(1673548209);
30
- const auctionTakingAmount = calculator.calcAuctionTakingAmount('1420000000', rate);
31
- expect(rate).toBe(14285);
32
- expect(auctionTakingAmount).toBe('1422028470');
33
- });
34
- });
35
- //# sourceMappingURL=auction-calculator.spec.js.map
31
+ const suffix = auction_suffix_1.AuctionSuffix.decode(
32
+ '0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009'
33
+ )
34
+ const salt = auction_salt_1.AuctionSalt.decode(
35
+ '45118768841948961586167738353692277076075522015101619148498725069326976558864'
36
+ )
37
+ const calculator =
38
+ auction_calculator_1.AuctionCalculator.fromAuctionData(suffix, salt)
39
+ const rate = calculator.calcRateBump(1673548209)
40
+ const auctionTakingAmount = calculator.calcAuctionTakingAmount(
41
+ '1420000000',
42
+ rate
43
+ )
44
+ expect(rate).toBe(14285)
45
+ expect(auctionTakingAmount).toBe('1422028470')
46
+ })
47
+ })
48
+ //# sourceMappingURL=auction-calculator.spec.js.map
@@ -1,4 +1,4 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
1
+ import {BigNumber} from '@ethersproject/bignumber'
2
2
  /**
3
3
  *
4
4
  * v2(t-t1) + v1(t2-t)
@@ -7,4 +7,10 @@ import { BigNumber } from '@ethersproject/bignumber';
7
7
  *
8
8
  * @see https://github.com/1inch/limit-order-settlement/blob/3c7cf9eacbaf7a60624d7a6f069c59d809f2204a/contracts/libraries/OrderSuffix.sol#L94
9
9
  */
10
- export declare function linearInterpolation(t1: BigNumber, t2: BigNumber, v1: BigNumber, v2: BigNumber, t: BigNumber): BigNumber;
10
+ export declare function linearInterpolation(
11
+ t1: BigNumber,
12
+ t2: BigNumber,
13
+ v1: BigNumber,
14
+ v2: BigNumber,
15
+ t: BigNumber
16
+ ): BigNumber
@@ -1,6 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.linearInterpolation = void 0;
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ exports.linearInterpolation = void 0
4
4
  /**
5
5
  *
6
6
  * v2(t-t1) + v1(t2-t)
@@ -10,13 +10,13 @@ exports.linearInterpolation = void 0;
10
10
  * @see https://github.com/1inch/limit-order-settlement/blob/3c7cf9eacbaf7a60624d7a6f069c59d809f2204a/contracts/libraries/OrderSuffix.sol#L94
11
11
  */
12
12
  function linearInterpolation(t1, t2, v1, v2, t) {
13
- const timePassedFromNow = t.sub(t1);
14
- const timeLeft = t2.sub(t);
15
- const partialCoefficient = v2.mul(timePassedFromNow);
16
- const partialPrevCoefficient = v1.mul(timeLeft);
17
- const coefficient = partialCoefficient.add(partialPrevCoefficient);
18
- const pointsTimeDiff = t2.sub(t1);
19
- return coefficient.div(pointsTimeDiff);
13
+ const timePassedFromNow = t.sub(t1)
14
+ const timeLeft = t2.sub(t)
15
+ const partialCoefficient = v2.mul(timePassedFromNow)
16
+ const partialPrevCoefficient = v1.mul(timeLeft)
17
+ const coefficient = partialCoefficient.add(partialPrevCoefficient)
18
+ const pointsTimeDiff = t2.sub(t1)
19
+ return coefficient.div(pointsTimeDiff)
20
20
  }
21
- exports.linearInterpolation = linearInterpolation;
22
- //# sourceMappingURL=calc.js.map
21
+ exports.linearInterpolation = linearInterpolation
22
+ //# sourceMappingURL=calc.js.map
@@ -1 +1 @@
1
- export declare const RATE_BUMP_DENOMINATOR = 10000000;
1
+ export declare const RATE_BUMP_DENOMINATOR = 10000000
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RATE_BUMP_DENOMINATOR = void 0;
4
- exports.RATE_BUMP_DENOMINATOR = 10000000; // 100%
5
- //# sourceMappingURL=constants.js.map
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ exports.RATE_BUMP_DENOMINATOR = void 0
4
+ exports.RATE_BUMP_DENOMINATOR = 10000000 // 100%
5
+ //# sourceMappingURL=constants.js.map
@@ -1,3 +1,3 @@
1
- export * from './auction-calculator';
2
- export * from './calc';
3
- export * from './constants';
1
+ export * from './auction-calculator'
2
+ export * from './calc'
3
+ export * from './constants'
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./auction-calculator"), exports);
5
- tslib_1.__exportStar(require("./calc"), exports);
6
- tslib_1.__exportStar(require("./constants"), exports);
7
- //# sourceMappingURL=index.js.map
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ const tslib_1 = require('tslib')
4
+ tslib_1.__exportStar(require('./auction-calculator'), exports)
5
+ tslib_1.__exportStar(require('./calc'), exports)
6
+ tslib_1.__exportStar(require('./constants'), exports)
7
+ //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
- import { AuctionSaltData } from './types';
1
+ import {AuctionSaltData} from './types'
2
2
  export declare class AuctionSalt {
3
- readonly auctionStartTime: number;
4
- readonly initialRateBump: number;
5
- readonly duration: number;
6
- readonly bankFee: string;
7
- readonly salt: string;
8
- constructor(auction: AuctionSaltData);
9
- static decode(salt: string): AuctionSalt;
10
- build(): string;
3
+ readonly auctionStartTime: number
4
+ readonly initialRateBump: number
5
+ readonly duration: number
6
+ readonly bankFee: string
7
+ readonly salt: string
8
+ constructor(auction: AuctionSaltData)
9
+ static decode(salt: string): AuctionSalt
10
+ build(): string
11
11
  }
@@ -1,21 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuctionSalt = void 0;
4
- const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
6
- const utils_1 = require("../utils");
7
- const crypto_1 = require("crypto");
8
- const parser_1 = require("./parser");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', {value: true})
3
+ exports.AuctionSalt = void 0
4
+ const tslib_1 = require('tslib')
5
+ const assert_1 = tslib_1.__importDefault(require('assert'))
6
+ const utils_1 = require('../utils')
7
+ const crypto_1 = require('crypto')
8
+ const parser_1 = require('./parser')
9
9
  class AuctionSalt {
10
10
  constructor(auction) {
11
- if (auction.salt && parser_1.SALT_MASK.lt((0, utils_1.toBN)(auction.salt))) {
12
- throw new Error('salt should be less 18 bytes');
11
+ if (
12
+ auction.salt &&
13
+ parser_1.SALT_MASK.lt((0, utils_1.toBN)(auction.salt))
14
+ ) {
15
+ throw new Error('salt should be less 18 bytes')
13
16
  }
14
- this.salt = auction.salt || (0, crypto_1.randomInt)(10000).toString();
15
- this.auctionStartTime = auction.auctionStartTime;
16
- this.initialRateBump = auction.initialRateBump;
17
- this.duration = auction.duration;
18
- this.bankFee = auction.bankFee;
17
+ this.salt = auction.salt || (0, crypto_1.randomInt)(10000).toString()
18
+ this.auctionStartTime = auction.auctionStartTime
19
+ this.initialRateBump = auction.initialRateBump
20
+ this.duration = auction.duration
21
+ this.bankFee = auction.bankFee
19
22
  }
20
23
  static decode(salt) {
21
24
  return new AuctionSalt({
@@ -24,17 +27,25 @@ class AuctionSalt {
24
27
  duration: (0, parser_1.getDuration)(salt).toNumber(),
25
28
  bankFee: (0, parser_1.getFee)(salt).toString(),
26
29
  initialRateBump: (0, parser_1.getInitialRateBump)(salt).toNumber()
27
- });
30
+ })
28
31
  }
29
32
  build() {
30
- const res = (0, utils_1.toBN)(this.auctionStartTime).toString('hex').padStart(8, '0') +
33
+ const res =
34
+ (0, utils_1.toBN)(this.auctionStartTime)
35
+ .toString('hex')
36
+ .padStart(8, '0') +
31
37
  (0, utils_1.toBN)(this.duration).toString('hex').padStart(6, '0') +
32
- (0, utils_1.toBN)(this.initialRateBump).toString('hex').padStart(6, '0') +
38
+ (0, utils_1.toBN)(this.initialRateBump)
39
+ .toString('hex')
40
+ .padStart(6, '0') +
33
41
  (0, utils_1.toBN)(this.bankFee).toString('hex').padStart(8, '0') +
34
- (0, utils_1.toBN)(this.salt).toString('hex').padStart(36, '0');
35
- (0, assert_1.default)(res.length === 64, 'Some inputs were out of allowed ranges');
36
- return (0, utils_1.toBN)('0x' + res).toString();
42
+ (0, utils_1.toBN)(this.salt).toString('hex').padStart(36, '0')
43
+ ;(0, assert_1.default)(
44
+ res.length === 64,
45
+ 'Some inputs were out of allowed ranges'
46
+ )
47
+ return (0, utils_1.toBN)('0x' + res).toString()
37
48
  }
38
49
  }
39
- exports.AuctionSalt = AuctionSalt;
40
- //# sourceMappingURL=auction-salt.js.map
50
+ exports.AuctionSalt = AuctionSalt
51
+ //# sourceMappingURL=auction-salt.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {}