@paraswap/dex-lib 4.3.20 → 4.4.0

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 (182) hide show
  1. package/build/abi/BProtocol.json +1155 -0
  2. package/build/abi/Jarvis.json +1172 -0
  3. package/build/abi/MStableAsset.json +1545 -0
  4. package/build/abi/OneInchLp.json +1304 -0
  5. package/build/abi/Onebit.json +736 -0
  6. package/build/abi/Shell.json +1294 -0
  7. package/build/abi/TraderJoeV2Router.json +50 -0
  8. package/build/abi/miro-migrator/MiroMigrator.abi.json +36 -19
  9. package/build/abi/uniswap-v3/UniswapSwapRouter02.abi.json +548 -0
  10. package/build/abi/wUSDM.json +757 -0
  11. package/build/abi/zrx.v2.json +1967 -0
  12. package/build/abi/zrx.v3.json +3454 -0
  13. package/build/abi/zrx.v4.json +2193 -0
  14. package/build/config.js +18 -22
  15. package/build/config.js.map +1 -1
  16. package/build/constants.d.ts +1 -0
  17. package/build/constants.js +1 -0
  18. package/build/constants.js.map +1 -1
  19. package/build/dex/OneInchLp.d.ts +24 -0
  20. package/build/dex/OneInchLp.js +43 -0
  21. package/build/dex/OneInchLp.js.map +1 -0
  22. package/build/dex/aave-v3/config.js +3 -17
  23. package/build/dex/aave-v3/config.js.map +1 -1
  24. package/build/dex/aave-v3-stata-v2/config.js +6 -0
  25. package/build/dex/aave-v3-stata-v2/config.js.map +1 -1
  26. package/build/dex/bProtocol/bProtocol.d.ts +15 -0
  27. package/build/dex/bProtocol/bProtocol.js +56 -0
  28. package/build/dex/bProtocol/bProtocol.js.map +1 -0
  29. package/build/dex/bProtocol/types.d.ts +11 -0
  30. package/build/dex/bProtocol/types.js +8 -0
  31. package/build/dex/bProtocol/types.js.map +1 -0
  32. package/build/dex/balancer-v2/config.js +3 -7
  33. package/build/dex/balancer-v2/config.js.map +1 -1
  34. package/build/dex/curve-v1/config.js +0 -111
  35. package/build/dex/curve-v1/config.js.map +1 -1
  36. package/build/dex/curve-v1-factory/config.js +0 -135
  37. package/build/dex/curve-v1-factory/config.js.map +1 -1
  38. package/build/dex/curve-v1-factory/constants.js +1 -1
  39. package/build/dex/curve-v1-factory/constants.js.map +1 -1
  40. package/build/dex/curve-v1-stable-ng/config.js +11 -19
  41. package/build/dex/curve-v1-stable-ng/config.js.map +1 -1
  42. package/build/dex/gmx/config.js +0 -16
  43. package/build/dex/gmx/config.js.map +1 -1
  44. package/build/dex/index.js +0 -2
  45. package/build/dex/index.js.map +1 -1
  46. package/build/dex/jarvis.d.ts +56 -0
  47. package/build/dex/jarvis.js +163 -0
  48. package/build/dex/jarvis.js.map +1 -0
  49. package/build/dex/mStable.d.ts +44 -0
  50. package/build/dex/mStable.js +75 -0
  51. package/build/dex/mStable.js.map +1 -0
  52. package/build/dex/miro-migrator/config.js +3 -10
  53. package/build/dex/miro-migrator/config.js.map +1 -1
  54. package/build/dex/miro-migrator/constants.d.ts +1 -0
  55. package/build/dex/miro-migrator/constants.js +2 -1
  56. package/build/dex/miro-migrator/constants.js.map +1 -1
  57. package/build/dex/miro-migrator/miro-migrator-pool.d.ts +8 -5
  58. package/build/dex/miro-migrator/miro-migrator-pool.js +48 -30
  59. package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
  60. package/build/dex/miro-migrator/miro-migrator.d.ts +5 -4
  61. package/build/dex/miro-migrator/miro-migrator.js +40 -83
  62. package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
  63. package/build/dex/miro-migrator/types.d.ts +2 -4
  64. package/build/dex/miro-migrator/types.js +1 -2
  65. package/build/dex/miro-migrator/types.js.map +1 -1
  66. package/build/dex/nerve/config.js +0 -3
  67. package/build/dex/nerve/config.js.map +1 -1
  68. package/build/dex/onebit/onebit.d.ts +16 -0
  69. package/build/dex/onebit/onebit.js +61 -0
  70. package/build/dex/onebit/onebit.js.map +1 -0
  71. package/build/dex/onebit/types.d.ts +14 -0
  72. package/build/dex/onebit/types.js +8 -0
  73. package/build/dex/onebit/types.js.map +1 -0
  74. package/build/dex/paraswap-limit-orders/config.js +0 -7
  75. package/build/dex/paraswap-limit-orders/config.js.map +1 -1
  76. package/build/dex/shell.d.ts +25 -0
  77. package/build/dex/shell.js +41 -0
  78. package/build/dex/shell.js.map +1 -0
  79. package/build/dex/solidly/config.js +0 -41
  80. package/build/dex/solidly/config.js.map +1 -1
  81. package/build/dex/solidly-v3/config.js +0 -13
  82. package/build/dex/solidly-v3/config.js.map +1 -1
  83. package/build/dex/trader-joe-v2.d.ts +40 -0
  84. package/build/dex/trader-joe-v2.js +74 -0
  85. package/build/dex/trader-joe-v2.js.map +1 -0
  86. package/build/dex/uniswap-v2/config.js +7 -53
  87. package/build/dex/uniswap-v2/config.js.map +1 -1
  88. package/build/dex/uniswap-v2/constants.js +0 -3
  89. package/build/dex/uniswap-v2/constants.js.map +1 -1
  90. package/build/dex/uniswap-v3/config.js +29 -18
  91. package/build/dex/uniswap-v3/config.js.map +1 -1
  92. package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.d.ts +1 -2
  93. package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js +2 -5
  94. package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js.map +1 -1
  95. package/build/dex/uniswap-v3/types.d.ts +5 -0
  96. package/build/dex/uniswap-v3/types.js +4 -1
  97. package/build/dex/uniswap-v3/types.js.map +1 -1
  98. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
  99. package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
  100. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
  101. package/build/dex/uniswap-v3/uniswap-v3.d.ts +2 -2
  102. package/build/dex/uniswap-v3/uniswap-v3.js +7 -3
  103. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  104. package/build/dex/usual-bond/config.d.ts +3 -0
  105. package/build/dex/usual-bond/config.js +13 -0
  106. package/build/dex/usual-bond/config.js.map +1 -0
  107. package/build/dex/usual-bond/types.d.ts +7 -0
  108. package/build/dex/usual-bond/types.js +3 -0
  109. package/build/dex/usual-bond/types.js.map +1 -0
  110. package/build/dex/usual-bond/usual-bond.d.ts +35 -0
  111. package/build/dex/usual-bond/usual-bond.js +176 -0
  112. package/build/dex/usual-bond/usual-bond.js.map +1 -0
  113. package/build/dex/weth/config.js +2 -5
  114. package/build/dex/weth/config.js.map +1 -1
  115. package/build/dex/woo-fi-v2/config.js +0 -3
  116. package/build/dex/woo-fi-v2/config.js.map +1 -1
  117. package/build/dex/wusdm/config.d.ts +3 -0
  118. package/build/dex/wusdm/config.js +43 -0
  119. package/build/dex/wusdm/config.js.map +1 -0
  120. package/build/dex/wusdm/constants.d.ts +2 -0
  121. package/build/dex/wusdm/constants.js +6 -0
  122. package/build/dex/wusdm/constants.js.map +1 -0
  123. package/build/dex/wusdm/types.d.ts +18 -0
  124. package/build/dex/wusdm/types.js +11 -0
  125. package/build/dex/wusdm/types.js.map +1 -0
  126. package/build/dex/wusdm/wusdm-pool.d.ts +21 -0
  127. package/build/dex/wusdm/wusdm-pool.js +74 -0
  128. package/build/dex/wusdm/wusdm-pool.js.map +1 -0
  129. package/build/dex/wusdm/wusdm.d.ts +46 -0
  130. package/build/dex/wusdm/wusdm.js +243 -0
  131. package/build/dex/wusdm/wusdm.js.map +1 -0
  132. package/build/dex/zerox/config.d.ts +2 -0
  133. package/build/dex/zerox/config.js +33 -0
  134. package/build/dex/zerox/config.js.map +1 -0
  135. package/build/dex/zerox/index.d.ts +22 -0
  136. package/build/dex/zerox/index.js +225 -0
  137. package/build/dex/zerox/index.js.map +1 -0
  138. package/build/dex/zerox/order.d.ts +88 -0
  139. package/build/dex/zerox/order.js +53 -0
  140. package/build/dex/zerox/order.js.map +1 -0
  141. package/build/dex/zerox/types.d.ts +73 -0
  142. package/build/dex/zerox/types.js +21 -0
  143. package/build/dex/zerox/types.js.map +1 -0
  144. package/build/executor/WETHBytecodeBuilder.js +1 -0
  145. package/build/executor/WETHBytecodeBuilder.js.map +1 -1
  146. package/package.json +1 -1
  147. package/build/abi/ekubo/twamm-data-fetcher.json +0 -216
  148. package/build/abi/ekubo/twamm.json +0 -720
  149. package/build/abi/ring-v2/few-wrapped-token.json +0 -587
  150. package/build/abi/ring-v2/ring-v2-factory.json +0 -125
  151. package/build/abi/ring-v2/ring-v2-pool.json +0 -461
  152. package/build/abi/ring-v2/ring-v2-router.json +0 -332
  153. package/build/dex/ekubo/pools/base.d.ts +0 -36
  154. package/build/dex/ekubo/pools/base.js +0 -289
  155. package/build/dex/ekubo/pools/base.js.map +0 -1
  156. package/build/dex/ekubo/pools/full-range.d.ts +0 -23
  157. package/build/dex/ekubo/pools/full-range.js +0 -99
  158. package/build/dex/ekubo/pools/full-range.js.map +0 -1
  159. package/build/dex/ekubo/pools/iface.d.ts +0 -46
  160. package/build/dex/ekubo/pools/iface.js +0 -75
  161. package/build/dex/ekubo/pools/iface.js.map +0 -1
  162. package/build/dex/ekubo/pools/math/twamm/exp2.d.ts +0 -1
  163. package/build/dex/ekubo/pools/math/twamm/exp2.js +0 -86
  164. package/build/dex/ekubo/pools/math/twamm/exp2.js.map +0 -1
  165. package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.d.ts +0 -1
  166. package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js +0 -56
  167. package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js.map +0 -1
  168. package/build/dex/ekubo/pools/oracle.d.ts +0 -8
  169. package/build/dex/ekubo/pools/oracle.js +0 -19
  170. package/build/dex/ekubo/pools/oracle.js.map +0 -1
  171. package/build/dex/ekubo/pools/twamm.d.ts +0 -38
  172. package/build/dex/ekubo/pools/twamm.js +0 -253
  173. package/build/dex/ekubo/pools/twamm.js.map +0 -1
  174. package/build/dex/ekubo/pools/utils.d.ts +0 -28
  175. package/build/dex/ekubo/pools/utils.js +0 -80
  176. package/build/dex/ekubo/pools/utils.js.map +0 -1
  177. package/build/dex/miro-migrator/miro-migrator-state.d.ts +0 -27
  178. package/build/dex/miro-migrator/miro-migrator-state.js +0 -89
  179. package/build/dex/miro-migrator/miro-migrator-state.js.map +0 -1
  180. package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +0 -26
  181. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +0 -75
  182. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +0 -1
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Jarvis = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const constants_1 = require("../constants");
9
+ const simple_exchange_1 = require("./simple-exchange");
10
+ const Jarvis_json_1 = __importDefault(require("../abi/Jarvis.json"));
11
+ const utils_1 = require("../executor/utils");
12
+ const THIRTY_MINUTES = 60 * 30;
13
+ var JarvisFunctions;
14
+ (function (JarvisFunctions) {
15
+ JarvisFunctions["mint"] = "mint";
16
+ JarvisFunctions["redeem"] = "redeem";
17
+ JarvisFunctions["exchange"] = "exchange";
18
+ })(JarvisFunctions || (JarvisFunctions = {}));
19
+ class Jarvis extends simple_exchange_1.SimpleExchange {
20
+ constructor(dexHelper) {
21
+ super(dexHelper, 'jarvis');
22
+ this.needWrapNative = false;
23
+ this.poolInterface = new abi_1.Interface(Jarvis_json_1.default);
24
+ }
25
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
26
+ const { method } = data;
27
+ const type = [
28
+ JarvisFunctions.mint,
29
+ JarvisFunctions.redeem,
30
+ JarvisFunctions.exchange,
31
+ ].indexOf(method);
32
+ if (type === undefined) {
33
+ throw new Error(`Jarvis: Invalid OpType ${method}, Should be one of ['mint', 'exchange', 'redeem']`);
34
+ }
35
+ const payload = this.abiCoder.encodeParameter({
36
+ ParentStruct: {
37
+ opType: 'uint',
38
+ derivatives: 'address',
39
+ destDerivatives: 'address',
40
+ fee: 'uint128',
41
+ destPool: 'address',
42
+ expiration: 'uint128',
43
+ },
44
+ }, {
45
+ opType: type,
46
+ derivatives: data.derivatives,
47
+ destDerivatives: data.destDerivatives || constants_1.NULL_ADDRESS,
48
+ fee: data.fee,
49
+ destPool: data.pools[1] || constants_1.NULL_ADDRESS,
50
+ expiration: (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0),
51
+ });
52
+ return {
53
+ targetExchange: data.pools[0],
54
+ payload,
55
+ networkFee: '0',
56
+ };
57
+ }
58
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
59
+ const swapFunction = data.method;
60
+ const timestamp = (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0);
61
+ let swapFunctionParams;
62
+ switch (swapFunction) {
63
+ case JarvisFunctions.mint:
64
+ swapFunctionParams = [
65
+ data.derivatives,
66
+ destAmount,
67
+ srcAmount,
68
+ data.fee,
69
+ timestamp,
70
+ this.augustusAddress,
71
+ ];
72
+ break;
73
+ case JarvisFunctions.redeem:
74
+ swapFunctionParams = [
75
+ data.derivatives,
76
+ srcAmount,
77
+ destAmount,
78
+ data.fee,
79
+ timestamp,
80
+ this.augustusAddress,
81
+ ];
82
+ break;
83
+ case JarvisFunctions.exchange:
84
+ swapFunctionParams = [
85
+ data.derivatives,
86
+ data.pools[1],
87
+ data.destDerivatives,
88
+ srcAmount,
89
+ destAmount,
90
+ data.fee,
91
+ timestamp,
92
+ this.augustusAddress,
93
+ ];
94
+ break;
95
+ default:
96
+ throw new Error(`Unknown function ${swapFunction}`);
97
+ }
98
+ const swapData = this.poolInterface.encodeFunctionData(swapFunction, [
99
+ swapFunctionParams,
100
+ ]);
101
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.pools[0]);
102
+ }
103
+ getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
104
+ const swapFunction = data.method;
105
+ const timestamp = (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0);
106
+ let swapFunctionParams;
107
+ let outputName;
108
+ switch (swapFunction) {
109
+ case JarvisFunctions.mint:
110
+ swapFunctionParams = [
111
+ data.derivatives,
112
+ destAmount,
113
+ srcAmount,
114
+ data.fee,
115
+ timestamp,
116
+ recipient,
117
+ ];
118
+ outputName = 'syntheticTokensMinted';
119
+ break;
120
+ case JarvisFunctions.redeem:
121
+ swapFunctionParams = [
122
+ data.derivatives,
123
+ srcAmount,
124
+ destAmount,
125
+ data.fee,
126
+ timestamp,
127
+ recipient,
128
+ ];
129
+ outputName = 'collateralRedeemed';
130
+ break;
131
+ case JarvisFunctions.exchange:
132
+ swapFunctionParams = [
133
+ data.derivatives,
134
+ data.pools[1],
135
+ data.destDerivatives,
136
+ srcAmount,
137
+ destAmount,
138
+ data.fee,
139
+ timestamp,
140
+ recipient,
141
+ ];
142
+ outputName = 'destNumTokensMinted';
143
+ break;
144
+ default:
145
+ throw new Error(`Unknown function ${swapFunction}`);
146
+ }
147
+ const swapData = this.poolInterface.encodeFunctionData(swapFunction, [
148
+ swapFunctionParams,
149
+ ]);
150
+ return {
151
+ needWrapNative: this.needWrapNative,
152
+ dexFuncHasRecipient: true,
153
+ exchangeData: swapData,
154
+ targetExchange: data.pools[0],
155
+ returnAmountPos: side === constants_1.SwapSide.SELL
156
+ ? (0, utils_1.extractReturnAmountPosition)(this.poolInterface, swapFunction, outputName)
157
+ : undefined,
158
+ };
159
+ }
160
+ }
161
+ exports.Jarvis = Jarvis;
162
+ Jarvis.dexKeys = ['jarvis'];
163
+ //# sourceMappingURL=jarvis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jarvis.js","sourceRoot":"","sources":["../../src/dex/jarvis.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAStD,uDAAmD;AACnD,qEAA2C;AAG3C,6CAAgE;AAEhE,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC;AA0C/B,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,gCAA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,qBAAqB,CAAC;gBACnC,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;SACvD;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,YAAY,EAAE;YACnE,kBAAkB;SACnB,CAAC,CAAC;QAEH,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7B,eAAe,EACb,IAAI,KAAK,oBAAQ,CAAC,IAAI;gBACpB,CAAC,CAAC,IAAA,mCAA2B,EACzB,IAAI,CAAC,aAAa,EAClB,YAAY,EACZ,UAAU,CACX;gBACH,CAAC,CAAC,SAAS;SAChB,CAAC;IACJ,CAAC;;AApMH,wBAqMC;AAjMQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { SwapSide } from '../constants';
3
+ import { AdapterExchangeParam, SimpleExchangeParam } from '../types';
4
+ import { IDexTxBuilder } from './idex';
5
+ import { SimpleExchange } from './simple-exchange';
6
+ import { IDexHelper } from '../dex-helper';
7
+ declare enum MStableFunctions {
8
+ mint = "mint",
9
+ swap = "swap",
10
+ redeem = "redeem"
11
+ }
12
+ declare type MStableData = {
13
+ exchange: string;
14
+ opType: MStableFunctions;
15
+ isAssetContract: boolean;
16
+ };
17
+ declare type MStableMint = [
18
+ _input: string,
19
+ _inputQuantity: string,
20
+ _minOutputQuantity: string,
21
+ _recipient: string
22
+ ];
23
+ declare type MStableSwap = [
24
+ _input: string,
25
+ _output: string,
26
+ _inputQuantity: string,
27
+ _minOutputQuantity: string,
28
+ _recipient: string
29
+ ];
30
+ declare type MStableRedeem = [
31
+ _output: string,
32
+ _mAssetQuantity: string,
33
+ _minOutputQuantity: string,
34
+ _recipient: string
35
+ ];
36
+ declare type MStableParam = MStableMint | MStableSwap | MStableRedeem;
37
+ export declare class MStable extends SimpleExchange implements IDexTxBuilder<MStableData, MStableParam> {
38
+ static dexKeys: string[];
39
+ mStableAsset: Interface;
40
+ constructor(dexHelper: IDexHelper);
41
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MStableData, side: SwapSide): AdapterExchangeParam;
42
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MStableData, side: SwapSide): Promise<SimpleExchangeParam>;
43
+ }
44
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MStable = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const simple_exchange_1 = require("./simple-exchange");
9
+ const MStableAsset_json_1 = __importDefault(require("../abi/MStableAsset.json"));
10
+ var MStableFunctions;
11
+ (function (MStableFunctions) {
12
+ MStableFunctions["mint"] = "mint";
13
+ MStableFunctions["swap"] = "swap";
14
+ MStableFunctions["redeem"] = "redeem";
15
+ })(MStableFunctions || (MStableFunctions = {}));
16
+ class MStable extends simple_exchange_1.SimpleExchange {
17
+ constructor(dexHelper) {
18
+ super(dexHelper, 'mStable');
19
+ this.mStableAsset = new abi_1.Interface(MStableAsset_json_1.default);
20
+ }
21
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
22
+ const { opType } = data;
23
+ const type = [
24
+ MStableFunctions.swap,
25
+ MStableFunctions.mint,
26
+ MStableFunctions.redeem,
27
+ ].indexOf(opType);
28
+ if (type === undefined) {
29
+ throw new Error(`mStable: Invalid OpType ${opType}, Should be one of ['mint', 'swap', 'redeem']`);
30
+ }
31
+ const payload = this.abiCoder.encodeParameter({
32
+ ParentStruct: {
33
+ opType: 'uint',
34
+ },
35
+ }, {
36
+ opType: type,
37
+ });
38
+ return {
39
+ targetExchange: data.exchange,
40
+ payload,
41
+ networkFee: '0',
42
+ };
43
+ }
44
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
45
+ const { opType, isAssetContract } = data;
46
+ const [swapFunction, swapFunctionsParams] = (() => {
47
+ switch (opType) {
48
+ case MStableFunctions.mint:
49
+ return [
50
+ opType,
51
+ [srcToken, srcAmount, destAmount, this.augustusAddress],
52
+ ];
53
+ case MStableFunctions.swap:
54
+ return [
55
+ opType,
56
+ [srcToken, destToken, srcAmount, destAmount, this.augustusAddress],
57
+ ];
58
+ case MStableFunctions.redeem:
59
+ return [
60
+ opType,
61
+ [destToken, srcAmount, destAmount, this.augustusAddress],
62
+ ];
63
+ default:
64
+ throw new Error(`mStable's OpType ${opType} not supported, failed to build`);
65
+ }
66
+ })();
67
+ // mStableAsset & mStablePool both have the same interface hence we can
68
+ // simply use mStableAsset contract
69
+ const swapData = this.mStableAsset.encodeFunctionData(swapFunction, swapFunctionsParams);
70
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
71
+ }
72
+ }
73
+ exports.MStable = MStable;
74
+ MStable.dexKeys = ['mStable'];
75
+ //# sourceMappingURL=mStable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mStable.js","sourceRoot":"","sources":["../../src/dex/mStable.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAK7D,uDAAmD;AACnD,iFAAuD;AAIvD,IAAK,gBAIJ;AAJD,WAAK,gBAAgB;IACnB,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,qCAAiB,CAAA;AACnB,CAAC,EAJI,gBAAgB,KAAhB,gBAAgB,QAIpB;AA4BD,MAAa,OACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,eAAS,CAAC,2BAAiC,CAAC,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,KAAK,gBAAgB,CAAC,MAAM;oBAC1B,OAAO;wBACL,MAAM;wBACN,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC;qBACzD,CAAC;gBACJ;oBACE,MAAM,IAAI,KAAK,CACb,oBAAoB,MAAM,iCAAiC,CAC5D,CAAC;aACL;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,uEAAuE;QACvE,mCAAmC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CACnD,YAAY,EACZ,mBAAmB,CACpB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;;AAvGH,0BAwGC;AApGQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
@@ -4,17 +4,10 @@ exports.MiroMigratorConfig = void 0;
4
4
  const constants_1 = require("../../constants");
5
5
  exports.MiroMigratorConfig = {
6
6
  MiroMigrator: {
7
- [constants_1.Network.MAINNET]: {
8
- migratorAddress: '0x4aBD869acbF927048434d137A3331D006Db54416',
9
- vlrTokenAddress: '0x4e107a0000DB66f0E9Fd2039288Bf811dD1f9c74',
10
- pspTokenAddress: '0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5',
11
- sePsp1TokenAddress: '0x716fBC68E0c761684D9280484243FF094CC5FfAB',
12
- },
13
7
  [constants_1.Network.OPTIMISM]: {
14
- migratorAddress: '0xb6208dE484dFb4Fd54148b1B9a745E9dF29519Ee',
15
- vlrTokenAddress: '0x4e107a0000DB66f0E9Fd2039288Bf811dD1f9c74',
16
- pspTokenAddress: '0xd3594E879B358F430E20F82bea61e83562d49D48',
17
- sePsp1TokenAddress: '0x8C934b7dBc782568d14ceaBbEAeDF37cB6348615',
8
+ migratorAddress: '0x5032433fb65d7db8e8b90cb239d50fdfd941fb6b',
9
+ pspTokenAddress: '0x326aec8d7d99d1d6022c57c5f6194d2a7867227d',
10
+ xyzTokenAddress: '0xa2781111f824ca1cd98454b2c9722baefc898e99',
18
11
  },
19
12
  },
20
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,kBAAkB,GAA4B;IACzD,YAAY,EAAE;QACZ,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,kBAAkB,EAAE,4CAA4C;SACjE;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,kBAAkB,EAAE,4CAA4C;SACjE;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,kBAAkB,GAA4B;IACzD,YAAY,EAAE;QACZ,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;YAC7D,eAAe,EAAE,4CAA4C;SAC9D;KACF;CACF,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const MIRO_MIGRATION_GAS_COST = 35000;
2
+ export declare const TRANSFER_TOPIC = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MIRO_MIGRATION_GAS_COST = void 0;
3
+ exports.TRANSFER_TOPIC = exports.MIRO_MIGRATION_GAS_COST = void 0;
4
4
  exports.MIRO_MIGRATION_GAS_COST = 35_000;
5
+ exports.TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
5
6
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,MAAM,CAAC;AAEjC,QAAA,cAAc,GACzB,oEAAoE,CAAC"}
@@ -1,23 +1,26 @@
1
+ import { Interface } from '@ethersproject/abi';
1
2
  import { DeepReadonly } from 'ts-essentials';
2
3
  import { Log, Logger } from '../../types';
3
4
  import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
4
5
  import { IDexHelper } from '../../dex-helper/idex-helper';
5
6
  import { PoolState } from './types';
6
- import { Contract } from 'ethers';
7
7
  export declare class MiroMigratorEventPool extends StatefulEventSubscriber<PoolState> {
8
8
  readonly parentName: string;
9
9
  protected network: number;
10
10
  protected dexHelper: IDexHelper;
11
11
  protected migratorAddress: string;
12
- protected vlrTokenAddress: string;
13
- protected vlrContract: Contract;
12
+ protected xyzAddress: string;
13
+ protected transferTopic: string;
14
+ protected migratorInterface: Interface;
15
+ protected xyzInterface: Interface;
14
16
  handlers: {
15
17
  [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
16
18
  };
17
19
  logDecoder: (log: Log) => any;
18
- constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, migratorAddress: string, vlrTokenAddress: string, vlrContract?: Contract);
20
+ constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, migratorAddress: string, xyzAddress: string, transferTopic: string, migratorInterface?: Interface, xyzInterface?: Interface);
19
21
  protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
20
22
  generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<PoolState>>;
21
23
  getOrGenerateState(blockNumber: number): Promise<PoolState>;
22
- handleTransfer(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
24
+ handleTransferTo(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState>>;
25
+ handleTransferFrom(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState>>;
23
26
  }
@@ -1,50 +1,69 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.MiroMigratorEventPool = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
4
8
  const utils_1 = require("../../utils");
5
9
  const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
6
- const utils_interfaces_1 = require("../../lib/utils-interfaces");
7
- const ethers_1 = require("ethers");
10
+ const decoders_1 = require("../../lib/decoders");
11
+ const MiroMigrator_abi_json_1 = __importDefault(require("../../abi/miro-migrator/MiroMigrator.abi.json"));
12
+ const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
8
13
  class MiroMigratorEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
9
14
  parentName;
10
15
  network;
11
16
  dexHelper;
12
17
  migratorAddress;
13
- vlrTokenAddress;
14
- vlrContract;
18
+ xyzAddress;
19
+ transferTopic;
20
+ migratorInterface;
21
+ xyzInterface;
15
22
  handlers = {};
16
23
  logDecoder;
17
- constructor(parentName, network, dexHelper, logger, migratorAddress, vlrTokenAddress, vlrContract = new ethers_1.Contract(vlrTokenAddress, utils_interfaces_1.erc20Iface, dexHelper.provider)) {
18
- super(parentName, 'vlr', dexHelper, logger);
24
+ constructor(parentName, network, dexHelper, logger, migratorAddress, xyzAddress, transferTopic, migratorInterface = new abi_1.Interface(MiroMigrator_abi_json_1.default), xyzInterface = new abi_1.Interface(erc20_json_1.default)) {
25
+ super(parentName, 'state', dexHelper, logger);
19
26
  this.parentName = parentName;
20
27
  this.network = network;
21
28
  this.dexHelper = dexHelper;
22
29
  this.migratorAddress = migratorAddress;
23
- this.vlrTokenAddress = vlrTokenAddress;
24
- this.vlrContract = vlrContract;
25
- this.logDecoder = (log) => this.vlrContract.interface.parseLog(log);
26
- this.addressesSubscribed = [vlrTokenAddress];
27
- this.handlers['Transfer'] = this.handleTransfer.bind(this);
30
+ this.xyzAddress = xyzAddress;
31
+ this.transferTopic = transferTopic;
32
+ this.migratorInterface = migratorInterface;
33
+ this.xyzInterface = xyzInterface;
34
+ this.logDecoder = (log) => this.xyzInterface.parseLog(log);
35
+ this.addressesSubscribed = [xyzAddress];
28
36
  }
29
37
  async processLog(state, log) {
30
38
  try {
31
39
  const event = this.logDecoder(log);
32
- if (event.name in this.handlers) {
33
- return this.handlers[event.name](event, state, log);
40
+ if (log.topics[0] === this.transferTopic &&
41
+ event.args.dst.toLowerCase() === this.migratorAddress.toLowerCase()) {
42
+ return this.handleTransferTo(event, state, log);
34
43
  }
44
+ if (log.topics[0] === this.transferTopic &&
45
+ event.args.src.toLowerCase() === this.migratorAddress.toLowerCase()) {
46
+ return this.handleTransferFrom(event, state, log);
47
+ }
48
+ return null;
35
49
  }
36
50
  catch (e) {
37
51
  (0, utils_1.catchParseLogError)(e, this.logger);
52
+ return null;
38
53
  }
39
- return null;
40
54
  }
41
55
  async generateState(blockNumber = 'latest') {
42
- // TEMP: return mock balacne for testing purposes while MiroMigrator has no VLR token
43
- return { balance: 1000000000000000000000000n };
44
- // const balance = await this.vlrContract.balanceOf(this.migratorAddress, {
45
- // blockTag: blockNumber,
46
- // });
47
- // return { balance: balance.toBigInt() };
56
+ const calls = [
57
+ {
58
+ target: this.xyzAddress,
59
+ callData: this.xyzInterface.encodeFunctionData('balanceOf', [
60
+ this.migratorAddress,
61
+ ]),
62
+ decodeFunction: decoders_1.uint256ToBigInt,
63
+ },
64
+ ];
65
+ const [balance] = await this.dexHelper.multiWrapper.tryAggregate(true, calls, blockNumber);
66
+ return { balance: balance.returnData };
48
67
  }
49
68
  async getOrGenerateState(blockNumber) {
50
69
  let state = this.getState(blockNumber);
@@ -54,16 +73,15 @@ class MiroMigratorEventPool extends stateful_event_subscriber_1.StatefulEventSub
54
73
  }
55
74
  return state;
56
75
  }
57
- handleTransfer(event, state, log) {
58
- const { from, to, value } = event.args;
59
- let balance = state.balance;
60
- if (to.toLowerCase() === this.migratorAddress.toLowerCase()) {
61
- balance += value.toBigInt();
62
- }
63
- if (from.toLowerCase() === this.migratorAddress.toLowerCase()) {
64
- balance -= value.toBigInt();
65
- }
66
- return { balance };
76
+ async handleTransferTo(event, state, log) {
77
+ return {
78
+ balance: state.balance + BigInt(event.args.wad),
79
+ };
80
+ }
81
+ async handleTransferFrom(event, state, log) {
82
+ return {
83
+ balance: state.balance - BigInt(event.args.wad),
84
+ };
67
85
  }
68
86
  }
69
87
  exports.MiroMigratorEventPool = MiroMigratorEventPool;
@@ -1 +1 @@
1
- {"version":3,"file":"miro-migrator-pool.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/miro-migrator-pool.ts"],"names":[],"mappings":";;;AAEA,uCAAiD;AACjD,+EAA0E;AAG1E,iEAAwD;AACxD,mCAAkC;AAElC,MAAa,qBAAsB,SAAQ,mDAAkC;IAYhE;IACC;IACA;IAEA;IACA;IACA;IAjBZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,eAAuB,EACvB,eAAuB,EACvB,cAAwB,IAAI,iBAAQ,CAC5C,eAAe,EACf,6BAAU,EACV,SAAS,CAAC,QAAQ,CACnB;QAED,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CA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,CACtB,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SAChD,CAAC;IACJ,CAAC;CACF;AAzGD,sDAyGC"}
@@ -10,7 +10,9 @@ export declare class MiroMigrator extends SimpleExchange implements IDex<MiroMig
10
10
  readonly network: Network;
11
11
  readonly dexKey: string;
12
12
  readonly dexHelper: IDexHelper;
13
- readonly config: import("./types").DexParams;
13
+ readonly migratorAddress: string;
14
+ readonly pspTokenAddress: string;
15
+ readonly xyzTokenAddress: string;
14
16
  protected unitPrice: bigint;
15
17
  protected migratorInterface: Interface;
16
18
  readonly hasConstantPriceLargeAmounts = true;
@@ -21,10 +23,9 @@ export declare class MiroMigrator extends SimpleExchange implements IDex<MiroMig
21
23
  }[];
22
24
  readonly eventPool: MiroMigratorEventPool;
23
25
  logger: Logger;
24
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config?: import("./types").DexParams, unitPrice?: bigint, migratorInterface?: Interface);
26
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, migratorAddress?: string, pspTokenAddress?: string, xyzTokenAddress?: string, unitPrice?: bigint, migratorInterface?: Interface);
25
27
  isPSP(tokenAddress: Address): boolean;
26
- isSePSP1Token(tokenAddress: Address): boolean;
27
- isVLRToken(tokenAddress: Address): boolean;
28
+ isXYZ(tokenAddress: Address): boolean;
28
29
  isAppropriatePair(srcToken: Token, destToken: Token): boolean;
29
30
  getAdapters(side: SwapSide): {
30
31
  name: string;