@paraswap/dex-lib 3.8.25 → 3.8.26-aave-gsm.2

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 (234) hide show
  1. package/build/abi/Aave_GSM.json +751 -0
  2. package/build/abi/inception/inception-ineth-pool.json +1062 -0
  3. package/build/abi/inception/inception-ineth.json +609 -0
  4. package/build/abi/inception/inception-ratio-feed.json +93 -0
  5. package/build/abi/inception/inception-vault.json +991 -0
  6. package/build/abi/{integral/pool.json → usual-bond/usd0pp.abi.json} +389 -563
  7. package/build/dex/aave-gsm/aave-gsm.d.ts +33 -0
  8. package/build/dex/aave-gsm/aave-gsm.js +283 -0
  9. package/build/dex/aave-gsm/aave-gsm.js.map +1 -0
  10. package/build/dex/aave-gsm/config.d.ts +3 -0
  11. package/build/dex/aave-gsm/config.js +17 -0
  12. package/build/dex/aave-gsm/config.js.map +1 -0
  13. package/build/dex/aave-gsm/types.d.ts +11 -0
  14. package/build/dex/aave-gsm/types.js +3 -0
  15. package/build/dex/aave-gsm/types.js.map +1 -0
  16. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  17. package/build/dex/aave-v1/aave-v1.js +22 -0
  18. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  19. package/build/dex/generic-rfq/rate-fetcher.js +1 -1
  20. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  21. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  22. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  23. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  24. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  25. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  26. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  27. package/build/dex/idle-dao/scripts.d.ts +9 -0
  28. package/build/dex/idle-dao/scripts.js +552 -0
  29. package/build/dex/idle-dao/scripts.js.map +1 -0
  30. package/build/dex/inception/config.d.ts +5 -0
  31. package/build/dex/inception/config.js +112 -0
  32. package/build/dex/inception/config.js.map +1 -0
  33. package/build/dex/inception/inception-event-pool.d.ts +25 -0
  34. package/build/dex/inception/inception-event-pool.js +57 -0
  35. package/build/dex/inception/inception-event-pool.js.map +1 -0
  36. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  37. package/build/dex/inception/inception-native.js +131 -0
  38. package/build/dex/inception/inception-native.js.map +1 -0
  39. package/build/dex/inception/inception-pool.d.ts +18 -0
  40. package/build/dex/inception/inception-pool.js +32 -0
  41. package/build/dex/inception/inception-pool.js.map +1 -0
  42. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  43. package/build/dex/inception/inception-price-feed.js +51 -0
  44. package/build/dex/inception/inception-price-feed.js.map +1 -0
  45. package/build/dex/inception/inception.d.ts +44 -0
  46. package/build/dex/inception/inception.js +177 -0
  47. package/build/dex/inception/inception.js.map +1 -0
  48. package/build/dex/inception/tokens.d.ts +9 -0
  49. package/build/dex/inception/tokens.js +28 -0
  50. package/build/dex/inception/tokens.js.map +1 -0
  51. package/build/dex/inception/types.d.ts +22 -0
  52. package/build/dex/inception/types.js +3 -0
  53. package/build/dex/inception/types.js.map +1 -0
  54. package/build/dex/inception/utils.d.ts +7 -0
  55. package/build/dex/inception/utils.js +58 -0
  56. package/build/dex/inception/utils.js.map +1 -0
  57. package/build/dex/index.js +2 -0
  58. package/build/dex/index.js.map +1 -1
  59. package/build/dex/platypus/platypus.d.ts +2 -1
  60. package/build/dex/platypus/platypus.js +31 -0
  61. package/build/dex/platypus/platypus.js.map +1 -1
  62. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  63. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  64. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  65. package/build/dex/usual-bond/config.d.ts +3 -0
  66. package/build/dex/usual-bond/config.js +13 -0
  67. package/build/dex/usual-bond/config.js.map +1 -0
  68. package/build/dex/usual-bond/types.d.ts +7 -0
  69. package/build/dex/usual-bond/types.js +3 -0
  70. package/build/dex/usual-bond/types.js.map +1 -0
  71. package/build/dex/usual-bond/usual-bond.d.ts +35 -0
  72. package/build/dex/usual-bond/usual-bond.js +162 -0
  73. package/build/dex/usual-bond/usual-bond.js.map +1 -0
  74. package/package.json +1 -1
  75. package/src/abi/Aave_GSM.json +751 -0
  76. package/src/dex/aave-gsm/aave-gsm-e2e.test.ts +109 -0
  77. package/src/dex/aave-gsm/aave-gsm-integration.test.ts +318 -0
  78. package/src/dex/aave-gsm/aave-gsm.ts +369 -0
  79. package/src/dex/aave-gsm/config.ts +16 -0
  80. package/src/dex/aave-gsm/types.ts +15 -0
  81. package/src/dex/generic-rfq/rate-fetcher.ts +6 -5
  82. package/src/dex/index.ts +2 -0
  83. package/.vscode/launch.json +0 -16
  84. package/.vscode/settings.json +0 -3
  85. package/build/abi/Uncompressor.json +0 -250
  86. package/build/abi/integral/factory.json +0 -333
  87. package/build/abi/integral/oracle.json +0 -501
  88. package/build/abi/integral/relayer.json +0 -1536
  89. package/build/dex/bProtocol.d.ts +0 -18
  90. package/build/dex/bProtocol.js +0 -39
  91. package/build/dex/bProtocol.js.map +0 -1
  92. package/build/dex/bancor.d.ts +0 -26
  93. package/build/dex/bancor.js +0 -58
  94. package/build/dex/bancor.js.map +0 -1
  95. package/build/dex/compound.d.ts +0 -18
  96. package/build/dex/compound.js +0 -46
  97. package/build/dex/compound.js.map +0 -1
  98. package/build/dex/curve-v2.d.ts +0 -58
  99. package/build/dex/curve-v2.js +0 -180
  100. package/build/dex/curve-v2.js.map +0 -1
  101. package/build/dex/dodo-v1.d.ts +0 -33
  102. package/build/dex/dodo-v1.js +0 -63
  103. package/build/dex/dodo-v1.js.map +0 -1
  104. package/build/dex/etherfi/etherfi.d.ts +0 -26
  105. package/build/dex/etherfi/etherfi.js +0 -96
  106. package/build/dex/etherfi/etherfi.js.map +0 -1
  107. package/build/dex/integral/config.d.ts +0 -4
  108. package/build/dex/integral/config.js +0 -20
  109. package/build/dex/integral/config.js.map +0 -1
  110. package/build/dex/integral/context.d.ts +0 -40
  111. package/build/dex/integral/context.js +0 -158
  112. package/build/dex/integral/context.js.map +0 -1
  113. package/build/dex/integral/helpers.d.ts +0 -17
  114. package/build/dex/integral/helpers.js +0 -157
  115. package/build/dex/integral/helpers.js.map +0 -1
  116. package/build/dex/integral/integral-factory.d.ts +0 -24
  117. package/build/dex/integral/integral-factory.js +0 -95
  118. package/build/dex/integral/integral-factory.js.map +0 -1
  119. package/build/dex/integral/integral-pool.d.ts +0 -50
  120. package/build/dex/integral/integral-pool.js +0 -149
  121. package/build/dex/integral/integral-pool.js.map +0 -1
  122. package/build/dex/integral/integral-pricing.d.ts +0 -18
  123. package/build/dex/integral/integral-pricing.js +0 -114
  124. package/build/dex/integral/integral-pricing.js.map +0 -1
  125. package/build/dex/integral/integral-relayer.d.ts +0 -42
  126. package/build/dex/integral/integral-relayer.js +0 -192
  127. package/build/dex/integral/integral-relayer.js.map +0 -1
  128. package/build/dex/integral/integral-token.d.ts +0 -27
  129. package/build/dex/integral/integral-token.js +0 -59
  130. package/build/dex/integral/integral-token.js.map +0 -1
  131. package/build/dex/integral/integral.js +0 -376
  132. package/build/dex/integral/integral.js.map +0 -1
  133. package/build/dex/integral/types.d.ts +0 -85
  134. package/build/dex/integral/types.js +0 -9
  135. package/build/dex/integral/types.js.map +0 -1
  136. package/build/dex/integral/utils-e2e.d.ts +0 -9
  137. package/build/dex/integral/utils-e2e.js +0 -131
  138. package/build/dex/integral/utils-e2e.js.map +0 -1
  139. package/build/dex/integral/utils.d.ts +0 -17
  140. package/build/dex/integral/utils.js +0 -94
  141. package/build/dex/integral/utils.js.map +0 -1
  142. package/build/dex/lido.d.ts +0 -19
  143. package/build/dex/lido.js +0 -42
  144. package/build/dex/lido.js.map +0 -1
  145. package/build/dex/onebit.d.ts +0 -25
  146. package/build/dex/onebit.js +0 -42
  147. package/build/dex/onebit.js.map +0 -1
  148. package/build/dex/sdai/config.d.ts +0 -11
  149. package/build/dex/sdai/config.js +0 -21
  150. package/build/dex/sdai/config.js.map +0 -1
  151. package/build/dex/sdai/constants.d.ts +0 -2
  152. package/build/dex/sdai/constants.js +0 -6
  153. package/build/dex/sdai/constants.js.map +0 -1
  154. package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
  155. package/build/dex/sdai/scripts/validate-state.js +0 -102
  156. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  157. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  158. package/build/dex/sdai/sdai-pool.js +0 -85
  159. package/build/dex/sdai/sdai-pool.js.map +0 -1
  160. package/build/dex/sdai/sdai.d.ts +0 -51
  161. package/build/dex/sdai/sdai.js +0 -172
  162. package/build/dex/sdai/sdai.js.map +0 -1
  163. package/build/dex/sdai/types.d.ts +0 -21
  164. package/build/dex/sdai/types.js +0 -11
  165. package/build/dex/sdai/types.js.map +0 -1
  166. package/build/dex/sdai/utils.d.ts +0 -4
  167. package/build/dex/sdai/utils.js +0 -39
  168. package/build/dex/sdai/utils.js.map +0 -1
  169. package/build/dex/smoothy.d.ts +0 -26
  170. package/build/dex/smoothy.js +0 -48
  171. package/build/dex/smoothy.js.map +0 -1
  172. package/build/dex/stable-pool.d.ts +0 -28
  173. package/build/dex/stable-pool.js +0 -62
  174. package/build/dex/stable-pool.js.map +0 -1
  175. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  176. package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
  177. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  178. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  179. package/build/dex/trader-joe-v2.1.js +0 -79
  180. package/build/dex/trader-joe-v2.1.js.map +0 -1
  181. package/build/executor/compressor/Compressor.d.ts +0 -23
  182. package/build/executor/compressor/Compressor.js +0 -144
  183. package/build/executor/compressor/Compressor.js.map +0 -1
  184. package/build/executor/compressor/compress.d.ts +0 -17
  185. package/build/executor/compressor/compress.js +0 -187
  186. package/build/executor/compressor/compress.js.map +0 -1
  187. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
  188. package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
  189. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
  190. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
  191. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
  192. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
  193. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
  194. package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
  195. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
  196. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
  197. package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
  198. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
  199. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
  200. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
  201. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
  202. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
  203. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
  204. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
  205. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
  206. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
  207. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
  208. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
  209. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
  210. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
  211. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  212. package/build/executor/compressor/fetchSaved.js +0 -17
  213. package/build/executor/compressor/fetchSaved.js.map +0 -1
  214. package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
  215. package/build/executor/compressor/utils/computeCostL2.js +0 -14
  216. package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
  217. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
  218. package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
  219. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
  220. package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
  221. package/build/executor/compressor/utils/getAllIndexes.js +0 -12
  222. package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
  223. package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
  224. package/build/executor/compressor/utils/getByteForAddress.js +0 -14
  225. package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
  226. package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
  227. package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
  228. package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
  229. package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
  230. package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
  231. package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
  232. package/build/executor/compressor/utils/intToByte.d.ts +0 -2
  233. package/build/executor/compressor/utils/intToByte.js +0 -10
  234. package/build/executor/compressor/utils/intToByte.js.map +0 -1
@@ -0,0 +1,369 @@
1
+ import {
2
+ Token,
3
+ Address,
4
+ ExchangePrices,
5
+ PoolPrices,
6
+ AdapterExchangeParam,
7
+ PoolLiquidity,
8
+ Logger,
9
+ NumberAsString,
10
+ DexExchangeParam,
11
+ } from '../../types';
12
+ import { SwapSide, Network } from '../../constants';
13
+ import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
14
+ import { getDexKeysWithNetwork } from '../../utils';
15
+ import { IDex } from '../../dex/idex';
16
+ import { IDexHelper } from '../../dex-helper/idex-helper';
17
+ import { AaveGsmData, DexParams } from './types';
18
+ import { SimpleExchange } from '../simple-exchange';
19
+ import { AaveGsmConfig } from './config';
20
+
21
+ import GSM_ABI from '../../abi/Aave_GSM.json';
22
+ import { Interface } from '@ethersproject/abi';
23
+ import { MultiResult } from '../../lib/multi-wrapper';
24
+ import { BytesLike } from 'ethers';
25
+ import { generalDecoder } from '../../lib/decoders';
26
+ import { parseUnits } from 'ethers/lib/utils';
27
+ import { extractReturnAmountPosition } from '../../executor/utils';
28
+ import {
29
+ RETURN_AMOUNT_POS_0,
30
+ RETURN_AMOUNT_POS_32,
31
+ } from '../../executor/constants';
32
+
33
+ export class AaveGsm extends SimpleExchange implements IDex<AaveGsmData> {
34
+ static readonly gsmInterface = new Interface(GSM_ABI);
35
+
36
+ protected config: DexParams;
37
+
38
+ readonly hasConstantPriceLargeAmounts = false;
39
+ readonly needWrapNative = false;
40
+
41
+ readonly isFeeOnTransferSupported = false;
42
+
43
+ public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
44
+ getDexKeysWithNetwork(AaveGsmConfig);
45
+
46
+ logger: Logger;
47
+
48
+ constructor(
49
+ readonly network: Network,
50
+ readonly dexKey: string,
51
+ readonly dexHelper: IDexHelper,
52
+ ) {
53
+ super(dexHelper, dexKey);
54
+ const config = AaveGsmConfig[dexKey][network];
55
+ this.config = {
56
+ GSM_USDT: config.GSM_USDT.toLowerCase(),
57
+ GSM_USDC: config.GSM_USDC.toLowerCase(),
58
+ USDT: config.USDT.toLowerCase(),
59
+ USDC: config.USDC.toLowerCase(),
60
+ GHO: config.GHO.toLowerCase(),
61
+ };
62
+
63
+ this.logger = dexHelper.getLogger(dexKey);
64
+ }
65
+
66
+ getAdapters(side: SwapSide): { name: string; index: number }[] | null {
67
+ return null;
68
+ }
69
+
70
+ async getPoolIdentifiers(
71
+ srcToken: Token,
72
+ destToken: Token,
73
+ side: SwapSide,
74
+ blockNumber: number,
75
+ ): Promise<string[]> {
76
+ const srcTokenAddress = srcToken.address.toLowerCase();
77
+ const destTokenAddress = destToken.address.toLowerCase();
78
+
79
+ if (
80
+ (srcTokenAddress === this.config.GHO &&
81
+ destTokenAddress === this.config.USDT) ||
82
+ (srcTokenAddress === this.config.USDT &&
83
+ destTokenAddress === this.config.GHO)
84
+ ) {
85
+ return [`${this.dexKey}_${this.config.GSM_USDT}`];
86
+ } else if (
87
+ (srcTokenAddress === this.config.GHO &&
88
+ destTokenAddress === this.config.USDC) ||
89
+ (srcTokenAddress === this.config.USDC &&
90
+ destTokenAddress === this.config.GHO)
91
+ ) {
92
+ return [`${this.dexKey}_${this.config.GSM_USDC}`];
93
+ } else {
94
+ return [];
95
+ }
96
+ }
97
+
98
+ // Returns pool prices for amounts.
99
+ // If limitPools is defined only pools in limitPools
100
+ // should be used. If limitPools is undefined then
101
+ // any pools can be used.
102
+ async getPricesVolume(
103
+ srcToken: Token,
104
+ destToken: Token,
105
+ amounts: bigint[],
106
+ side: SwapSide,
107
+ blockNumber: number,
108
+ limitPools?: string[],
109
+ ): Promise<null | ExchangePrices<AaveGsmData>> {
110
+ const srcTokenAddress = srcToken.address.toLowerCase();
111
+ const destTokenAddress = destToken.address.toLowerCase();
112
+
113
+ if (
114
+ !(
115
+ (srcTokenAddress == this.config.GHO &&
116
+ (destTokenAddress == this.config.USDC ||
117
+ destTokenAddress == this.config.USDT)) ||
118
+ (destTokenAddress == this.config.GHO &&
119
+ (srcTokenAddress == this.config.USDC ||
120
+ srcTokenAddress == this.config.USDT))
121
+ )
122
+ ) {
123
+ return null;
124
+ }
125
+
126
+ let endpoint: string;
127
+ let target: string;
128
+ let resultIsGho: boolean;
129
+ if (srcTokenAddress == this.config.GHO && side == SwapSide.BUY) {
130
+ endpoint = 'getGhoAmountForBuyAsset';
131
+ resultIsGho = true;
132
+ } else if (srcTokenAddress == this.config.GHO && side == SwapSide.SELL) {
133
+ endpoint = 'getAssetAmountForBuyAsset';
134
+ resultIsGho = false;
135
+ } else if (destTokenAddress == this.config.GHO && side == SwapSide.SELL) {
136
+ endpoint = 'getGhoAmountForSellAsset';
137
+ resultIsGho = true;
138
+ } else {
139
+ endpoint = 'getAssetAmountForSellAsset';
140
+ resultIsGho = false;
141
+ }
142
+
143
+ if (
144
+ srcTokenAddress == this.config.USDT ||
145
+ destTokenAddress == this.config.USDT
146
+ ) {
147
+ target = this.config.GSM_USDT;
148
+ } else {
149
+ target = this.config.GSM_USDC;
150
+ }
151
+
152
+ const unit = parseUnits(
153
+ '1',
154
+ side == SwapSide.SELL ? srcToken.decimals : destToken.decimals,
155
+ ).toBigInt();
156
+
157
+ const amountsWithUnit = [...amounts, unit];
158
+
159
+ const calls = amountsWithUnit.map(amount => ({
160
+ target,
161
+ callData: AaveGsm.gsmInterface.encodeFunctionData(endpoint, [amount]),
162
+ decodeFunction: (
163
+ result: MultiResult<BytesLike> | BytesLike,
164
+ ): { underlying: bigint; gho: bigint } => {
165
+ return generalDecoder(
166
+ result,
167
+ ['uint256', 'uint256', 'uint256', 'uint256'],
168
+ {
169
+ underlying: 0n,
170
+ gho: 0n,
171
+ },
172
+ value => ({
173
+ underlying: value[0].toBigInt(),
174
+ gho: value[1].toBigInt(),
175
+ }),
176
+ );
177
+ },
178
+ }));
179
+
180
+ let results = await this.dexHelper.multiWrapper.tryAggregate<{
181
+ underlying: bigint;
182
+ gho: bigint;
183
+ }>(true, calls, blockNumber);
184
+
185
+ const unitPriceResult = results.pop()!;
186
+
187
+ return [
188
+ {
189
+ unit: resultIsGho
190
+ ? unitPriceResult.returnData.gho
191
+ : unitPriceResult.returnData.underlying,
192
+ prices: results.map(result =>
193
+ resultIsGho ? result.returnData.gho : result.returnData.underlying,
194
+ ),
195
+ data: {
196
+ exchange: this.dexKey,
197
+ },
198
+ poolAddresses: [target],
199
+ exchange: this.dexKey,
200
+ gasCost: endpoint.indexOf('BuyAsset') > 0 ? 80000 : 74000,
201
+ poolIdentifier: `${this.dexKey}_${target}`,
202
+ },
203
+ ];
204
+ }
205
+
206
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
207
+ getCalldataGasCost(poolPrices: PoolPrices<AaveGsmData>): number | number[] {
208
+ return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
209
+ }
210
+
211
+ getAdapterParam(
212
+ srcToken: string,
213
+ destToken: string,
214
+ srcAmount: string,
215
+ destAmount: string,
216
+ data: AaveGsmData,
217
+ side: SwapSide,
218
+ ): AdapterExchangeParam {
219
+ const { exchange } = data;
220
+
221
+ const payload = '';
222
+
223
+ return {
224
+ targetExchange: exchange,
225
+ payload,
226
+ networkFee: '0',
227
+ };
228
+ }
229
+
230
+ async getDexParam(
231
+ srcToken: Address,
232
+ destToken: Address,
233
+ srcAmount: NumberAsString,
234
+ destAmount: NumberAsString,
235
+ recipient: Address,
236
+ data: AaveGsmData,
237
+ side: SwapSide,
238
+ ): Promise<DexExchangeParam> {
239
+ const isSrcGho = srcToken.toLowerCase() === this.config.GHO;
240
+ const swapFunction = isSrcGho ? 'buyAsset' : 'sellAsset';
241
+ const ghoAmount = isSrcGho ? srcAmount : destAmount;
242
+ let assetAmount = isSrcGho ? destAmount : srcAmount;
243
+ const targetExchange =
244
+ srcToken.toLowerCase() === this.config.USDT ||
245
+ destToken.toLowerCase() === this.config.USDT
246
+ ? this.config.GSM_USDT
247
+ : this.config.GSM_USDC;
248
+
249
+ if (BigInt(assetAmount) == 1n) {
250
+ const endpoint = isSrcGho
251
+ ? 'getAssetAmountForBuyAsset'
252
+ : 'getAssetAmountForSellAsset';
253
+
254
+ const calldata = {
255
+ target: targetExchange,
256
+ callData: AaveGsm.gsmInterface.encodeFunctionData(endpoint, [
257
+ ghoAmount,
258
+ ]),
259
+ decodeFunction: (
260
+ result: MultiResult<BytesLike> | BytesLike,
261
+ ): { underlying: bigint; gho: bigint } => {
262
+ return generalDecoder(
263
+ result,
264
+ ['uint256', 'uint256', 'uint256', 'uint256'],
265
+ {
266
+ underlying: 0n,
267
+ gho: 0n,
268
+ },
269
+ value => ({
270
+ underlying: value[0].toBigInt(),
271
+ gho: value[1].toBigInt(),
272
+ }),
273
+ );
274
+ },
275
+ };
276
+
277
+ const result = await this.dexHelper.multiWrapper.tryAggregate<{
278
+ underlying: bigint;
279
+ gho: bigint;
280
+ }>(true, [calldata]);
281
+
282
+ assetAmount = result[0].returnData.underlying.toString();
283
+ }
284
+
285
+ const exchangeData = AaveGsm.gsmInterface.encodeFunctionData(swapFunction, [
286
+ assetAmount,
287
+ recipient,
288
+ ]);
289
+
290
+ return {
291
+ needWrapNative: this.needWrapNative,
292
+ dexFuncHasRecipient: true,
293
+ exchangeData,
294
+ targetExchange,
295
+ returnAmountPos:
296
+ side === SwapSide.SELL
297
+ ? isSrcGho
298
+ ? RETURN_AMOUNT_POS_32
299
+ : RETURN_AMOUNT_POS_0
300
+ : undefined,
301
+ };
302
+ }
303
+
304
+ // Returns list of top pools based on liquidity. Max
305
+ // limit number pools should be returned.
306
+ async getTopPoolsForToken(
307
+ tokenAddress: Address,
308
+ limit: number,
309
+ ): Promise<PoolLiquidity[]> {
310
+ tokenAddress = tokenAddress.toLowerCase();
311
+
312
+ if (tokenAddress == this.config.GHO) {
313
+ return [
314
+ {
315
+ exchange: this.dexKey,
316
+ address: this.config.GSM_USDC,
317
+ connectorTokens: [
318
+ {
319
+ decimals: 6,
320
+ address: this.config.USDC,
321
+ },
322
+ ],
323
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
324
+ },
325
+ {
326
+ exchange: this.dexKey,
327
+ address: this.config.GSM_USDT,
328
+ connectorTokens: [
329
+ {
330
+ decimals: 6,
331
+ address: this.config.USDT,
332
+ },
333
+ ],
334
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
335
+ },
336
+ ];
337
+ } else if (tokenAddress == this.config.USDC) {
338
+ return [
339
+ {
340
+ exchange: this.dexKey,
341
+ address: this.config.GSM_USDC,
342
+ connectorTokens: [
343
+ {
344
+ decimals: 18,
345
+ address: this.config.GHO,
346
+ },
347
+ ],
348
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
349
+ },
350
+ ];
351
+ } else if (tokenAddress == this.config.USDT) {
352
+ return [
353
+ {
354
+ exchange: this.dexKey,
355
+ address: this.config.GSM_USDT,
356
+ connectorTokens: [
357
+ {
358
+ decimals: 18,
359
+ address: this.config.GHO,
360
+ },
361
+ ],
362
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
363
+ },
364
+ ];
365
+ } else {
366
+ return [];
367
+ }
368
+ }
369
+ }
@@ -0,0 +1,16 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap, AdapterMappings } from '../../types';
3
+ import { Network, SwapSide } from '../../constants';
4
+ import { AaveV3Ethereum, MiscEthereum } from '@bgd-labs/aave-address-book';
5
+
6
+ export const AaveGsmConfig: DexConfigMap<DexParams> = {
7
+ AaveGsm: {
8
+ [Network.MAINNET]: {
9
+ GSM_USDT: MiscEthereum.GSM_USDT,
10
+ GSM_USDC: MiscEthereum.GSM_USDC,
11
+ USDT: AaveV3Ethereum.ASSETS.USDT.UNDERLYING,
12
+ USDC: AaveV3Ethereum.ASSETS.USDC.UNDERLYING,
13
+ GHO: AaveV3Ethereum.ASSETS.GHO.UNDERLYING,
14
+ },
15
+ },
16
+ };
@@ -0,0 +1,15 @@
1
+ import { Address } from '../../types';
2
+
3
+ export type AaveGsmData = {
4
+ // returned by the API that can be used for
5
+ // tx building. The data structure should be minimal.
6
+ exchange: Address;
7
+ };
8
+
9
+ export type DexParams = {
10
+ GSM_USDT: string;
11
+ GSM_USDC: string;
12
+ USDT: string;
13
+ USDC: string;
14
+ GHO: string;
15
+ };
@@ -1,5 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { isEmpty } from 'lodash';
2
+ import { isEmpty, omit } from 'lodash';
3
3
  import { SwapSide } from '@paraswap/core';
4
4
  import { BN_1 } from '../../bignumber-constants';
5
5
  import { IDexHelper } from '../../dex-helper';
@@ -433,14 +433,15 @@ export class RateFetcher {
433
433
  timeout: GET_FIRM_RATE_TIMEOUT_MS,
434
434
  };
435
435
 
436
+ this.logger.info(
437
+ 'FirmRate Request:',
438
+ JSON.stringify(omit(payload, 'secret')).replace(/(?:\r\n|\r|\n)/g, ' '),
439
+ );
440
+
436
441
  if (this.firmRateAuth) {
437
442
  this.firmRateAuth(payload);
438
443
  delete payload.secret;
439
444
  }
440
- this.logger.info(
441
- 'FirmRate Request:',
442
- JSON.stringify(payload).replace(/(?:\r\n|\r|\n)/g, ' '),
443
- );
444
445
  const { data } = await this.dexHelper.httpRequest.request<unknown>(
445
446
  payload,
446
447
  );
package/src/dex/index.ts CHANGED
@@ -86,6 +86,7 @@ import { AaveV3Stata } from './aave-v3-stata/aave-v3-stata';
86
86
  import { OSwap } from './oswap/oswap';
87
87
  import { ConcentratorArusd } from './concentrator-arusd/concentrator-arusd';
88
88
  import { FxProtocolRusd } from './fx-protocol-rusd/fx-protocol-rusd';
89
+ import { AaveGsm } from './aave-gsm/aave-gsm';
89
90
  import { LitePsm } from './lite-psm/lite-psm';
90
91
 
91
92
  const LegacyDexes = [
@@ -168,6 +169,7 @@ const Dexes = [
168
169
  OSwap,
169
170
  ConcentratorArusd,
170
171
  FxProtocolRusd,
172
+ AaveGsm,
171
173
  LitePsm,
172
174
  ];
173
175
 
@@ -1,16 +0,0 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "args": [
6
- "${workspaceFolder}/src/dex/maverick-v2/maverick-v2-integration.test.ts"
7
- ],
8
- "internalConsoleOptions": "openOnSessionStart",
9
- "name": "Dex-lib",
10
- "program": "${workspaceFolder}/node_modules/jest/bin/jest",
11
- "request": "launch",
12
- "skipFiles": ["<node_internals>/**"],
13
- "type": "node"
14
- }
15
- ]
16
- }
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules/typescript/lib"
3
- }