@paraswap/dex-lib 3.8.13 → 3.8.15
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.
- package/.vscode/launch.json +16 -0
- package/.vscode/settings.json +3 -0
- package/build/abi/Uncompressor.json +250 -0
- package/build/abi/concentrator/arUSD5115.json +1746 -0
- package/build/abi/fx-protocol/FxMarket.json +1284 -0
- package/build/abi/fx-protocol/weETHOralce.json +676 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/{inception/inception-ineth-pool.json → integral/pool.json} +522 -543
- package/build/abi/integral/relayer.json +1536 -0
- package/build/abi/maverick-v2/MaverickV2Router.json +778 -0
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -22
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +17 -0
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js +66 -0
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +1 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +6 -3
- package/build/dex/concentrator-arusd/concentrator-arusd.js +45 -41
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -1
- package/build/dex/concentrator-arusd/config.d.ts +1 -2
- package/build/dex/concentrator-arusd/config.js +2 -6
- package/build/dex/concentrator-arusd/config.js.map +1 -1
- package/build/dex/concentrator-arusd/types.d.ts +7 -3
- package/build/dex/concentrator-arusd/utils.d.ts +4 -0
- package/build/dex/concentrator-arusd/utils.js +27 -0
- package/build/dex/concentrator-arusd/utils.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.js.map +1 -0
- package/build/dex/etherfi/etherfi.d.ts +26 -0
- package/build/dex/etherfi/etherfi.js +96 -0
- package/build/dex/etherfi/etherfi.js.map +1 -0
- package/build/dex/fx-protocol-rusd/config.d.ts +1 -2
- package/build/dex/fx-protocol-rusd/config.js +3 -6
- package/build/dex/fx-protocol-rusd/config.js.map +1 -1
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.d.ts +18 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js +71 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd-event.js.map +1 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +10 -10
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +75 -70
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -1
- package/build/dex/fx-protocol-rusd/types.d.ts +6 -3
- package/build/dex/fx-protocol-rusd/utils.d.ts +4 -0
- package/build/dex/fx-protocol-rusd/utils.js +26 -0
- package/build/dex/fx-protocol-rusd/utils.js.map +1 -0
- package/build/dex/index.js +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/{infusion → integral}/config.d.ts +1 -1
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/helpers.d.ts +17 -0
- package/build/dex/integral/helpers.js +157 -0
- package/build/dex/integral/helpers.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
- package/build/dex/integral/integral.js +377 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +84 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/oswap/oswap.js +4 -1
- package/build/dex/oswap/oswap.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -31
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/sdai/config.d.ts +11 -0
- package/build/dex/sdai/config.js +21 -0
- package/build/dex/sdai/config.js.map +1 -0
- package/build/dex/sdai/constants.d.ts +2 -0
- package/build/dex/sdai/constants.js +6 -0
- package/build/dex/sdai/constants.js.map +1 -0
- package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
- package/build/dex/sdai/scripts/validate-state.js +102 -0
- package/build/dex/sdai/scripts/validate-state.js.map +1 -0
- package/build/dex/sdai/sdai-pool.d.ts +16 -0
- package/build/dex/sdai/sdai-pool.js +85 -0
- package/build/dex/sdai/sdai-pool.js.map +1 -0
- package/build/dex/sdai/sdai.d.ts +51 -0
- package/build/dex/sdai/sdai.js +172 -0
- package/build/dex/sdai/sdai.js.map +1 -0
- package/build/dex/sdai/types.d.ts +21 -0
- package/build/dex/sdai/types.js +11 -0
- package/build/dex/sdai/types.js.map +1 -0
- package/build/dex/sdai/utils.d.ts +4 -0
- package/build/dex/sdai/utils.js +39 -0
- package/build/dex/sdai/utils.js.map +1 -0
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -10
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.js +4 -5
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +2 -3
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +24 -14
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/executor/compressor/Compressor.d.ts +23 -0
- package/build/executor/compressor/Compressor.js +144 -0
- package/build/executor/compressor/Compressor.js.map +1 -0
- package/build/executor/compressor/compress.d.ts +17 -0
- package/build/executor/compressor/compress.js +187 -0
- package/build/executor/compressor/compress.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +17 -0
- package/build/executor/compressor/fetchSaved.js.map +1 -0
- package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
- package/build/executor/compressor/utils/computeCostL2.js +14 -0
- package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
- package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
- package/build/executor/compressor/utils/getAllIndexes.js +12 -0
- package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
- package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
- package/build/executor/compressor/utils/getByteForAddress.js +14 -0
- package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
- package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
- package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intToByte.d.ts +2 -0
- package/build/executor/compressor/utils/intToByte.js +10 -0
- package/build/executor/compressor/utils/intToByte.js.map +1 -0
- package/build/generic-swap-transaction-builder.d.ts +1 -1
- package/build/generic-swap-transaction-builder.js +10 -10
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/concentrator/arUSD.json +568 -0
- package/src/abi/concentrator/arUSD5115.json +1746 -0
- package/src/abi/fx-protocol/FxMarket.json +1284 -0
- package/src/abi/fx-protocol/FxUSD.json +1227 -0
- package/src/abi/fx-protocol/weETHOralce.json +676 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-e2e.test.ts +92 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-event.ts +100 -0
- package/src/dex/concentrator-arusd/concentrator-arusd-integration.test.ts +104 -0
- package/src/dex/concentrator-arusd/concentrator-arusd.ts +269 -0
- package/src/dex/concentrator-arusd/concetrator-arusd-events.test.ts +97 -0
- package/src/dex/concentrator-arusd/config.ts +13 -0
- package/src/dex/concentrator-arusd/types.ts +16 -0
- package/src/dex/concentrator-arusd/utils.ts +36 -0
- package/src/dex/fx-protocol-rusd/config.ts +14 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-e2e.test.ts +96 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-events.test.ts +101 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-integration.test.ts +104 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd-event.ts +112 -0
- package/src/dex/fx-protocol-rusd/fx-protocol-rusd.ts +282 -0
- package/src/dex/fx-protocol-rusd/types.ts +16 -0
- package/src/dex/fx-protocol-rusd/utils.ts +47 -0
- package/src/dex/index.ts +4 -0
- package/src/dex/wsteth/wsteth-integration.test.ts +0 -1
- package/src/executor/Executor01BytecodeBuilder.ts +4 -8
- package/src/executor/Executor02BytecodeBuilder.ts +2 -7
- package/src/executor/Executor03BytecodeBuilder.ts +34 -19
- package/src/generic-swap-transaction-builder.ts +3 -5
- package/tests/constants-e2e.ts +10 -0
- package/build/abi/inception/inception-ineth.json +0 -609
- package/build/abi/inception/inception-ratio-feed.json +0 -93
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/infusion/InfusionFactory.json +0 -147
- package/build/abi/infusion/InfusionPair.json +0 -658
- package/build/abi/infusion/InfusionRouter.json +0 -442
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -5
- package/build/dex/inception/config.js +0 -112
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -23
- package/build/dex/inception/inception-event-pool.js +0 -34
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception-price-feed.d.ts +0 -19
- package/build/dex/inception/inception-price-feed.js +0 -51
- package/build/dex/inception/inception-price-feed.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -44
- package/build/dex/inception/inception.js +0 -162
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -7
- package/build/dex/inception/utils.js +0 -58
- package/build/dex/inception/utils.js.map +0 -1
- package/build/dex/infusion/config.js +0 -25
- package/build/dex/infusion/config.js.map +0 -1
- package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
- package/build/dex/infusion/infusion-stable-pool.js +0 -74
- package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
- package/build/dex/infusion/infusion.d.ts +0 -54
- package/build/dex/infusion/infusion.js +0 -532
- package/build/dex/infusion/infusion.js.map +0 -1
- package/build/dex/infusion/types.d.ts +0 -47
- package/build/dex/infusion/types.js +0 -3
- package/build/dex/infusion/types.js.map +0 -1
- package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
- package/build/dex/infusion/utils/isStablePair.js +0 -18
- package/build/dex/infusion/utils/isStablePair.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
3
|
import { SwapSide, Network } from '../../constants';
|
|
4
4
|
import { IDex } from '../../dex/idex';
|
|
5
5
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
@@ -28,7 +28,6 @@ export declare class AaveV1 extends SimpleExchange implements IDex<AaveV1Data, A
|
|
|
28
28
|
getCalldataGasCost(poolPrices: PoolPrices<AaveV1Data>): number | number[];
|
|
29
29
|
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AaveV1Data, side: SwapSide): AdapterExchangeParam;
|
|
30
30
|
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AaveV1Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
31
|
-
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: AaveV1Data, side: SwapSide): DexExchangeParam;
|
|
32
31
|
updatePoolState(): Promise<void>;
|
|
33
32
|
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
34
33
|
}
|
|
@@ -139,28 +139,6 @@ class AaveV1 extends simple_exchange_1.SimpleExchange {
|
|
|
139
139
|
const swapData = Interface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
140
140
|
return this.buildSimpleParamWithoutWETHConversion(srcToken, amount, destToken, destAmount, swapData, swapCallee, spender);
|
|
141
141
|
}
|
|
142
|
-
// DEAD
|
|
143
|
-
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
144
|
-
const amount = side === constants_1.SwapSide.SELL ? srcAmount : destAmount;
|
|
145
|
-
const [Interface, swapFunction, swapFunctionParams, swapCallee] = (() => {
|
|
146
|
-
if (data.fromAToken) {
|
|
147
|
-
return [this.aContract, AaveV1Functions.redeem, [amount], srcToken];
|
|
148
|
-
}
|
|
149
|
-
return [
|
|
150
|
-
this.aavePool,
|
|
151
|
-
AaveV1Functions.deposit,
|
|
152
|
-
[srcToken, amount, REF_CODE],
|
|
153
|
-
AAVE_LENDING_POOL,
|
|
154
|
-
];
|
|
155
|
-
})();
|
|
156
|
-
const exchangeData = Interface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
157
|
-
return {
|
|
158
|
-
needWrapNative: this.needWrapNative,
|
|
159
|
-
dexFuncHasRecipient: false,
|
|
160
|
-
exchangeData,
|
|
161
|
-
targetExchange: swapCallee,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
142
|
// This is called once before getTopPoolsForToken is
|
|
165
143
|
// called for multiple tokens. This can be helpful to
|
|
166
144
|
// update common state required for calculating
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aave-v1.js","sourceRoot":"","sources":["../../../src/dex/aave-v1/aave-v1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6D;
|
|
1
|
+
{"version":3,"file":"aave-v1.js","sourceRoot":"","sources":["../../../src/dex/aave-v1/aave-v1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6D;AAW7D,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAkE;AAIlE,wDAAoD;AACpD,qCAAkD;AAClD,kGAA0E;AAC1E,sEAAyC;AACzC,qCAAsC;AAEtC,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC;AAE/B,IAAK,eAGJ;AAHD,WAAK,eAAe;IAClB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EAHI,eAAe,KAAf,eAAe,QAGnB;AAED,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;AACvE,MAAM,UAAU,GAAG,4CAA4C,CAAC;AAChE,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,MAAa,MACX,SAAQ,gCAAc;IAatB,YAC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,yBAAkB,GAC9B,IAAA,6BAAqB,EAAC,qBAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export declare type BProtocolData = {
|
|
8
|
+
exchange: string;
|
|
9
|
+
};
|
|
10
|
+
declare type BProtocolParam = [lusdAmount: string, minEthReturn: string, dest: string];
|
|
11
|
+
export declare class BProtocol extends SimpleExchange implements IDexTxBuilder<BProtocolData, BProtocolParam> {
|
|
12
|
+
static dexKeys: string[];
|
|
13
|
+
exchangeRouterInterface: Interface;
|
|
14
|
+
constructor(dexHelper: IDexHelper);
|
|
15
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BProtocolData, side: SwapSide): AdapterExchangeParam;
|
|
16
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BProtocolData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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.BProtocol = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const BProtocol_json_1 = __importDefault(require("../abi/BProtocol.json"));
|
|
10
|
+
var BProtocolFunctions;
|
|
11
|
+
(function (BProtocolFunctions) {
|
|
12
|
+
BProtocolFunctions["swap"] = "swap";
|
|
13
|
+
})(BProtocolFunctions || (BProtocolFunctions = {}));
|
|
14
|
+
class BProtocol extends simple_exchange_1.SimpleExchange {
|
|
15
|
+
constructor(dexHelper) {
|
|
16
|
+
super(dexHelper, 'bprotocol');
|
|
17
|
+
this.exchangeRouterInterface = new abi_1.Interface(BProtocol_json_1.default);
|
|
18
|
+
}
|
|
19
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
20
|
+
return {
|
|
21
|
+
targetExchange: data.exchange,
|
|
22
|
+
payload: '0x',
|
|
23
|
+
networkFee: '0',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
27
|
+
const swapFunction = BProtocolFunctions.swap;
|
|
28
|
+
const swapFunctionParams = [
|
|
29
|
+
srcAmount,
|
|
30
|
+
destAmount,
|
|
31
|
+
this.augustusAddress,
|
|
32
|
+
];
|
|
33
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
34
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BProtocol = BProtocol;
|
|
38
|
+
BProtocol.dexKeys = ['bprotocol'];
|
|
39
|
+
//# sourceMappingURL=bProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bProtocol.js","sourceRoot":"","sources":["../../src/dex/bProtocol.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAI7D,uDAAmD;AACnD,2EAAiD;AAOjD,IAAK,kBAEJ;AAFD,WAAK,kBAAkB;IACrB,mCAAa,CAAA;AACf,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,QAEtB;AAED,MAAa,SACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC9B,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,wBAA8B,CAC/B,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAmB,EACnB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAmB,EACnB,IAAc;QAEd,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC;QAC7C,MAAM,kBAAkB,GAAmB;YACzC,SAAS;YACT,UAAU;YACV,IAAI,CAAC,eAAe;SACrB,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,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;;AAxDH,8BAyDC;AArDQ,iBAAO,GAAG,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../constants';
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../dex-helper';
|
|
7
|
+
export declare type BancorData = {
|
|
8
|
+
minDestToken: string;
|
|
9
|
+
path: Address[];
|
|
10
|
+
bancorNetwork?: string;
|
|
11
|
+
};
|
|
12
|
+
declare type BancorParam = [
|
|
13
|
+
path: Address[],
|
|
14
|
+
srcAmount: string,
|
|
15
|
+
minDestToken: string,
|
|
16
|
+
affiliateAccount: string,
|
|
17
|
+
affiliateFee: string
|
|
18
|
+
];
|
|
19
|
+
export declare class Bancor extends SimpleExchange implements IDexTxBuilder<BancorData, BancorParam> {
|
|
20
|
+
static dexKeys: string[];
|
|
21
|
+
exchangeRouterInterface: Interface;
|
|
22
|
+
constructor(dexHelper: IDexHelper);
|
|
23
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BancorData, side: SwapSide): AdapterExchangeParam;
|
|
24
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BancorData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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.Bancor = 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 Bancor_json_1 = __importDefault(require("../abi/Bancor.json"));
|
|
11
|
+
const BANCOR_NETWORK = {
|
|
12
|
+
1: '0x2F9EC37d6CcFFf1caB21733BdaDEdE11c823cCB0',
|
|
13
|
+
};
|
|
14
|
+
const BancorRegistry = {
|
|
15
|
+
1: '0x52ae12abe5d8bd778bd5397f99ca900624cfadd4',
|
|
16
|
+
};
|
|
17
|
+
var BancorFunctions;
|
|
18
|
+
(function (BancorFunctions) {
|
|
19
|
+
BancorFunctions["convert2"] = "convert2";
|
|
20
|
+
})(BancorFunctions || (BancorFunctions = {}));
|
|
21
|
+
class Bancor extends simple_exchange_1.SimpleExchange {
|
|
22
|
+
constructor(dexHelper) {
|
|
23
|
+
super(dexHelper, 'bancor');
|
|
24
|
+
this.exchangeRouterInterface = new abi_1.Interface(Bancor_json_1.default);
|
|
25
|
+
}
|
|
26
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
27
|
+
if (side === constants_1.SwapSide.BUY)
|
|
28
|
+
throw new Error(`Buy not supported`);
|
|
29
|
+
const { path } = data;
|
|
30
|
+
const payload = this.abiCoder.encodeParameter({
|
|
31
|
+
ParentStruct: {
|
|
32
|
+
path: 'address[]',
|
|
33
|
+
},
|
|
34
|
+
}, { path });
|
|
35
|
+
return {
|
|
36
|
+
targetExchange: BancorRegistry[this.network],
|
|
37
|
+
payload,
|
|
38
|
+
networkFee: '0',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
42
|
+
if (side === constants_1.SwapSide.BUY)
|
|
43
|
+
throw new Error(`Buy not supported`);
|
|
44
|
+
const defaultArgs = [
|
|
45
|
+
data.path,
|
|
46
|
+
srcAmount,
|
|
47
|
+
data.minDestToken || '1',
|
|
48
|
+
constants_1.NULL_ADDRESS,
|
|
49
|
+
'0',
|
|
50
|
+
];
|
|
51
|
+
const swapMethod = BancorFunctions.convert2;
|
|
52
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapMethod, defaultArgs);
|
|
53
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.bancorNetwork || BANCOR_NETWORK[this.network]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Bancor = Bancor;
|
|
57
|
+
Bancor.dexKeys = ['bancor'];
|
|
58
|
+
//# sourceMappingURL=bancor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bancor.js","sourceRoot":"","sources":["../../src/dex/bancor.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD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ACxB,wBAAY;YACZ,GAAG;SACJ,CAAC;QACF,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,UAAU,EACV,WAAW,CACZ,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,aAAa,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CACnD,CAAC;IACJ,CAAC;;AAtEH,wBAuEC;AAnEQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export declare type CompoundData = {
|
|
8
|
+
fromCToken: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare type CompoundParam = [srcAmount: string];
|
|
11
|
+
export declare class Compound extends SimpleExchange implements IDexTxBuilder<CompoundData, CompoundParam> {
|
|
12
|
+
static dexKeys: string[];
|
|
13
|
+
cethInterface: Interface;
|
|
14
|
+
constructor(dexHelper: IDexHelper);
|
|
15
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CompoundData, side: SwapSide): AdapterExchangeParam;
|
|
16
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CompoundData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
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.Compound = 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 Compound_CETH_json_1 = __importDefault(require("../abi/Compound_CETH.json")); // CETH abi
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
var CompoundFunctions;
|
|
13
|
+
(function (CompoundFunctions) {
|
|
14
|
+
CompoundFunctions["redeem"] = "redeem";
|
|
15
|
+
CompoundFunctions["mint"] = "mint";
|
|
16
|
+
})(CompoundFunctions || (CompoundFunctions = {}));
|
|
17
|
+
class Compound extends simple_exchange_1.SimpleExchange {
|
|
18
|
+
constructor(dexHelper) {
|
|
19
|
+
super(dexHelper, 'compound');
|
|
20
|
+
this.cethInterface = new abi_1.Interface(Compound_CETH_json_1.default);
|
|
21
|
+
}
|
|
22
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
23
|
+
const cToken = data.fromCToken ? srcToken : destToken; // Warning
|
|
24
|
+
const payload = this.abiCoder.encodeParameter({
|
|
25
|
+
ParentStruct: {
|
|
26
|
+
cToken: 'address',
|
|
27
|
+
},
|
|
28
|
+
}, { cToken });
|
|
29
|
+
return {
|
|
30
|
+
// target exchange is not used by the contract
|
|
31
|
+
targetExchange: constants_1.NULL_ADDRESS,
|
|
32
|
+
payload,
|
|
33
|
+
networkFee: '0',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
37
|
+
const cToken = data.fromCToken ? srcToken : destToken;
|
|
38
|
+
const swapData = (0, utils_1.isETHAddress)(srcToken)
|
|
39
|
+
? this.cethInterface.encodeFunctionData(CompoundFunctions.mint)
|
|
40
|
+
: this.erc20Interface.encodeFunctionData(data.fromCToken ? CompoundFunctions.redeem : CompoundFunctions.mint, [srcAmount]);
|
|
41
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, cToken, undefined, undefined, undefined, data.fromCToken);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Compound = Compound;
|
|
45
|
+
Compound.dexKeys = ['compound'];
|
|
46
|
+
//# sourceMappingURL=compound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.js","sourceRoot":"","sources":["../../src/dex/compound.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD;AACnD,mFAA6C,CAAC,WAAW;AACzD,oCAAwC;AAQxC,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;AACf,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAa,QACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,eAAS,CAAC,4BAAsB,CAAC,CAAC;IAC7D,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU;QAEjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,MAAM,EAAE,SAAS;aAClB;SACF,EACD,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,OAAO;YACL,8CAA8C;YAC9C,cAAc,EAAE,wBAAY;YAC5B,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAC/D,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACpC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EACnE,CAAC,SAAS,CAAC,CACZ,CAAC;QAEN,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;;AAnEH,4BAoEC;AAhEQ,gBAAO,GAAG,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { IDexHelper } from '../../dex-helper';
|
|
3
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
4
|
+
import { Address, Log, Logger } from '../../types';
|
|
5
|
+
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
6
|
+
import { ConcentratorArusdState } from './types';
|
|
7
|
+
export declare class ConcentratorArusdEvent extends StatefulEventSubscriber<ConcentratorArusdState> {
|
|
8
|
+
protected dexHelper: IDexHelper;
|
|
9
|
+
private poolAddress;
|
|
10
|
+
private poolInterface;
|
|
11
|
+
decoder: (log: Log) => import("@ethersproject/abi").LogDescription;
|
|
12
|
+
constructor(parentName: string, dexHelper: IDexHelper, poolAddress: Address, poolInterface: Interface, logger: Logger);
|
|
13
|
+
protected processLog(state: DeepReadonly<ConcentratorArusdState>, log: Readonly<Log>): AsyncOrSync<DeepReadonly<ConcentratorArusdState> | null>;
|
|
14
|
+
generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<ConcentratorArusdState>>;
|
|
15
|
+
getPrice(blockNumber: number, ethAmount: bigint, is_deposit: boolean): Promise<bigint>;
|
|
16
|
+
getOrGenerateState(blockNumber: number): Promise<DeepReadonly<ConcentratorArusdState> | null>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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.ConcentratorArusdEvent = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
9
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
class ConcentratorArusdEvent extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
12
|
+
constructor(parentName, dexHelper, poolAddress, poolInterface, logger) {
|
|
13
|
+
super(parentName, 'ConcentratorArusd', dexHelper, logger);
|
|
14
|
+
this.dexHelper = dexHelper;
|
|
15
|
+
this.poolAddress = poolAddress;
|
|
16
|
+
this.poolInterface = poolInterface;
|
|
17
|
+
this.decoder = (log) => this.poolInterface.parseLog(log);
|
|
18
|
+
this.addressesSubscribed = [poolAddress];
|
|
19
|
+
}
|
|
20
|
+
processLog(state, log) {
|
|
21
|
+
const event = this.decoder(log);
|
|
22
|
+
const _state = lodash_1.default.cloneDeep(state);
|
|
23
|
+
if (event.name === 'Deposit') {
|
|
24
|
+
_state.totalSupply = (BigInt(_state.totalSupply) + BigInt(event.args.amountSyOut)).toString();
|
|
25
|
+
_state.totalAssets = (BigInt(_state.totalAssets) + BigInt(event.args.amountDeposited)).toString();
|
|
26
|
+
return _state;
|
|
27
|
+
}
|
|
28
|
+
else if (event.name === 'Redeem') {
|
|
29
|
+
_state.totalSupply = (BigInt(_state.totalSupply) - BigInt(event.args.amountSyToRedeem)).toString();
|
|
30
|
+
_state.totalAssets = (BigInt(_state.totalAssets) - BigInt(event.args.amountTokenOut)).toString();
|
|
31
|
+
return _state;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
async generateState(blockNumber = 'latest') {
|
|
36
|
+
const state = await (0, utils_1.getOnChainState)(this.dexHelper.multiContract, this.poolAddress, this.poolInterface, blockNumber);
|
|
37
|
+
return state;
|
|
38
|
+
}
|
|
39
|
+
async getPrice(blockNumber, ethAmount, is_deposit) {
|
|
40
|
+
const state = await this.getOrGenerateState(blockNumber);
|
|
41
|
+
if (!state)
|
|
42
|
+
throw new Error('Cannot compute price');
|
|
43
|
+
const { totalSupply, totalAssets } = state;
|
|
44
|
+
const nav = (BigInt(totalAssets) * bigint_constants_1.BI_POWS[18]) / BigInt(totalSupply);
|
|
45
|
+
if (is_deposit) {
|
|
46
|
+
return BigInt((ethAmount * bigint_constants_1.BI_POWS[18]) / nav);
|
|
47
|
+
}
|
|
48
|
+
return BigInt((nav * ethAmount) / bigint_constants_1.BI_POWS[18]);
|
|
49
|
+
}
|
|
50
|
+
async getOrGenerateState(blockNumber) {
|
|
51
|
+
const state = this.getState(blockNumber);
|
|
52
|
+
if (state) {
|
|
53
|
+
return state;
|
|
54
|
+
}
|
|
55
|
+
this.logger.debug(`No state found for ${this.addressesSubscribed[0]}, generating new one`);
|
|
56
|
+
const newState = await this.generateState(blockNumber);
|
|
57
|
+
if (!newState) {
|
|
58
|
+
this.logger.debug(`Could not regenerate state for ${this.addressesSubscribed[0]}`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
this.setState(newState, blockNumber);
|
|
62
|
+
return newState;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ConcentratorArusdEvent = ConcentratorArusdEvent;
|
|
66
|
+
//# sourceMappingURL=concentrator-arusd-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concentrator-arusd-event.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd-event.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,+EAA0E;AAI1E,6DAAiD;AACjD,mCAA0C;AAE1C,MAAa,sBAAuB,SAAQ,mDAA+C;IAGzF,YACE,UAAkB,EACR,SAAqB,EACvB,WAAoB,EACpB,aAAwB,EAChC,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QALhD,cAAS,GAAT,SAAS,CAAY;QACvB,gBAAW,GAAX,WAAW,CAAS;QACpB,kBAAa,GAAb,aAAa,CAAW;QANlC,YAAO,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAUvD,IAAI,CAAC,mBAAmB,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAES,UAAU,CAClB,KAA2C,EAC3C,GAAkB;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,MAAM,GAA2B,gBAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YAC5B,MAAM,CAAC,WAAW,GAAG,CACnB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAC5D,CAAC,QAAQ,EAAE,CAAC;YACb,MAAM,CAA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QACtE,IAAI,UAAU,EAAE;YACd,OAAO,MAAM,CAAC,CAAC,SAAS,GAAG,0BAAO,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;SAChD;QACD,OAAO,MAAM,CAAC,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,0BAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,WAAmB;QAEnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,sBAAsB,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,sBAAsB,CACxE,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEvD,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,kCAAkC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAzFD,wDAyFC"}
|
|
@@ -5,11 +5,12 @@ import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
|
5
5
|
import { ConcentratorArusdData, DexParams } from './types';
|
|
6
6
|
import { SimpleExchange } from '../simple-exchange';
|
|
7
7
|
import { Interface } from '@ethersproject/abi';
|
|
8
|
+
import { ConcentratorArusdEvent } from './concentrator-arusd-event';
|
|
8
9
|
export declare class ConcentratorArusd extends SimpleExchange implements IDex<ConcentratorArusdData> {
|
|
9
10
|
readonly network: Network;
|
|
10
11
|
readonly dexKey: string;
|
|
11
12
|
readonly dexHelper: IDexHelper;
|
|
12
|
-
protected adapters:
|
|
13
|
+
protected adapters: {};
|
|
13
14
|
static readonly arUSDIface: Interface;
|
|
14
15
|
protected config: DexParams;
|
|
15
16
|
readonly hasConstantPriceLargeAmounts = true;
|
|
@@ -19,11 +20,13 @@ export declare class ConcentratorArusd extends SimpleExchange implements IDex<Co
|
|
|
19
20
|
key: string;
|
|
20
21
|
networks: Network[];
|
|
21
22
|
}[];
|
|
23
|
+
arUSD5115Iface: Interface;
|
|
24
|
+
concentratorArusdEvent: ConcentratorArusdEvent;
|
|
22
25
|
logger: Logger;
|
|
23
|
-
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?:
|
|
26
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: {});
|
|
27
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
24
28
|
is_arUSD(token: string): boolean;
|
|
25
29
|
is_rUSD(token: string): boolean;
|
|
26
|
-
is_weETH(token: string): boolean;
|
|
27
30
|
is_arUSD_swap_token(srcToken: string, destToken: string): boolean;
|
|
28
31
|
getAdapters(side: SwapSide): {
|
|
29
32
|
name: string;
|
|
@@ -27,15 +27,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ConcentratorArusd = void 0;
|
|
30
|
+
const constants_1 = require("../../constants");
|
|
30
31
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
31
32
|
const utils_1 = require("../../utils");
|
|
32
33
|
const simple_exchange_1 = require("../simple-exchange");
|
|
33
34
|
const config_1 = require("./config");
|
|
34
35
|
const abi_1 = require("@ethersproject/abi");
|
|
35
36
|
const arUSD_json_1 = __importDefault(require("../../abi/concentrator/arUSD.json"));
|
|
37
|
+
const arUSD5115_json_1 = __importDefault(require("../../abi/concentrator/arUSD5115.json"));
|
|
36
38
|
const utils_2 = require("../../executor/utils");
|
|
39
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
40
|
+
const concentrator_arusd_event_1 = require("./concentrator-arusd-event");
|
|
41
|
+
const utils_3 = require("./utils");
|
|
37
42
|
class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
38
|
-
constructor(network, dexKey, dexHelper, adapters =
|
|
43
|
+
constructor(network, dexKey, dexHelper, adapters = {}) {
|
|
39
44
|
super(dexHelper, dexKey);
|
|
40
45
|
this.network = network;
|
|
41
46
|
this.dexKey = dexKey;
|
|
@@ -48,9 +53,17 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
48
53
|
this.config = {
|
|
49
54
|
rUSDAddress: config.rUSDAddress.toLowerCase(),
|
|
50
55
|
arUSDAddress: config.arUSDAddress.toLowerCase(),
|
|
51
|
-
|
|
56
|
+
arUSD5115Address: config.arUSD5115Address.toLowerCase(),
|
|
52
57
|
};
|
|
58
|
+
this.arUSD5115Iface = new abi_1.Interface(arUSD5115_json_1.default);
|
|
53
59
|
this.logger = dexHelper.getLogger(dexKey);
|
|
60
|
+
this.concentratorArusdEvent = new concentrator_arusd_event_1.ConcentratorArusdEvent(this.dexKey, dexHelper, this.config.arUSD5115Address, this.arUSD5115Iface, this.logger);
|
|
61
|
+
}
|
|
62
|
+
async initializePricing(blockNumber) {
|
|
63
|
+
const poolState = await (0, utils_3.getOnChainState)(this.dexHelper.multiContract, this.config.arUSD5115Address, this.arUSD5115Iface, blockNumber);
|
|
64
|
+
await this.concentratorArusdEvent.initialize(blockNumber, {
|
|
65
|
+
state: poolState,
|
|
66
|
+
});
|
|
54
67
|
}
|
|
55
68
|
is_arUSD(token) {
|
|
56
69
|
return token.toLowerCase() === this.config.arUSDAddress;
|
|
@@ -58,9 +71,6 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
58
71
|
is_rUSD(token) {
|
|
59
72
|
return token.toLowerCase() === this.config.rUSDAddress;
|
|
60
73
|
}
|
|
61
|
-
is_weETH(token) {
|
|
62
|
-
return token.toLowerCase() === this.config.weETHAddress;
|
|
63
|
-
}
|
|
64
74
|
is_arUSD_swap_token(srcToken, destToken) {
|
|
65
75
|
if (this.is_rUSD(srcToken) && this.is_arUSD(destToken)) {
|
|
66
76
|
return true;
|
|
@@ -68,9 +78,6 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
68
78
|
if (this.is_arUSD(srcToken) && this.is_rUSD(destToken)) {
|
|
69
79
|
return true;
|
|
70
80
|
}
|
|
71
|
-
if (this.is_arUSD(srcToken) && this.is_weETH(destToken)) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
81
|
return false;
|
|
75
82
|
}
|
|
76
83
|
getAdapters(side) {
|
|
@@ -80,33 +87,32 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
80
87
|
if (!this.is_arUSD_swap_token(srcToken.address, destToken.address)) {
|
|
81
88
|
return [];
|
|
82
89
|
}
|
|
83
|
-
return [this.dexKey];
|
|
90
|
+
return [`${this.dexKey}_${this.config.arUSDAddress}`];
|
|
84
91
|
}
|
|
85
92
|
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
93
|
+
// note: BUY is not supported
|
|
94
|
+
if (side === constants_1.SwapSide.BUY)
|
|
95
|
+
return null;
|
|
86
96
|
const isArUSDSwapToken = this.is_arUSD_swap_token(srcToken.address, destToken.address);
|
|
87
97
|
if (!isArUSDSwapToken) {
|
|
88
98
|
return null;
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// true,
|
|
99
|
-
// readerCallData,
|
|
100
|
-
// blockNumber,
|
|
101
|
-
// );
|
|
100
|
+
const is_deposit = !!this.is_rUSD(srcToken.address);
|
|
101
|
+
const pool = this.concentratorArusdEvent;
|
|
102
|
+
const unitIn = bigint_constants_1.BI_POWS[18];
|
|
103
|
+
const unitOut = await pool.getPrice(blockNumber, unitIn, is_deposit);
|
|
104
|
+
const amountsOut = await Promise.all(amounts.map(async (amountIn) => {
|
|
105
|
+
const _newPrice = await pool.getPrice(blockNumber, amountIn, is_deposit);
|
|
106
|
+
return _newPrice;
|
|
107
|
+
}));
|
|
102
108
|
return [
|
|
103
109
|
{
|
|
104
|
-
unit:
|
|
105
|
-
prices:
|
|
110
|
+
unit: unitOut,
|
|
111
|
+
prices: amountsOut,
|
|
106
112
|
data: {},
|
|
107
113
|
poolAddresses: [this.config.arUSDAddress],
|
|
108
114
|
exchange: this.dexKey,
|
|
109
|
-
gasCost:
|
|
115
|
+
gasCost: 1000000,
|
|
110
116
|
},
|
|
111
117
|
];
|
|
112
118
|
}
|
|
@@ -127,7 +133,6 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
127
133
|
const is_arUSD_src = this.is_arUSD(srcToken);
|
|
128
134
|
const is_rUSD_dest = this.is_rUSD(destToken);
|
|
129
135
|
const is_arUSD_dest = this.is_arUSD(destToken);
|
|
130
|
-
const is_weETH_dest = this.is_weETH(destToken);
|
|
131
136
|
if (is_rUSD_src && is_arUSD_dest) {
|
|
132
137
|
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('deposit', [srcAmount, recipient]);
|
|
133
138
|
return {
|
|
@@ -148,31 +153,30 @@ class ConcentratorArusd extends simple_exchange_1.SimpleExchange {
|
|
|
148
153
|
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'redeem', 'assets'),
|
|
149
154
|
};
|
|
150
155
|
}
|
|
151
|
-
if (is_arUSD_src && is_weETH_dest) {
|
|
152
|
-
const exchangeData = ConcentratorArusd.arUSDIface.encodeFunctionData('redeemToBaseToken', [srcAmount, recipient, executorAddress, 0]);
|
|
153
|
-
return {
|
|
154
|
-
needWrapNative: false,
|
|
155
|
-
dexFuncHasRecipient: true,
|
|
156
|
-
exchangeData,
|
|
157
|
-
targetExchange: this.config.arUSDAddress,
|
|
158
|
-
returnAmountPos: (0, utils_2.extractReturnAmountPosition)(ConcentratorArusd.arUSDIface, 'redeemToBaseToken', 'assets'),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
156
|
throw new Error('LOGIC ERROR');
|
|
162
157
|
}
|
|
163
158
|
// Returns list of top pools based on liquidity. Max
|
|
164
159
|
// limit number pools should be returned.
|
|
165
160
|
async getTopPoolsForToken(tokenAddress, limit) {
|
|
161
|
+
if (!this.is_rUSD(tokenAddress) && !this.is_arUSD(tokenAddress))
|
|
162
|
+
return [];
|
|
166
163
|
return [
|
|
167
164
|
{
|
|
168
165
|
exchange: this.dexKey,
|
|
169
166
|
address: this.config.arUSDAddress,
|
|
170
|
-
connectorTokens:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
connectorTokens: this.is_rUSD(tokenAddress)
|
|
168
|
+
? [
|
|
169
|
+
{
|
|
170
|
+
decimals: 18,
|
|
171
|
+
address: this.config.arUSDAddress,
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
: [
|
|
175
|
+
{
|
|
176
|
+
decimals: 18,
|
|
177
|
+
address: this.config.rUSDAddress,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
176
180
|
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
177
181
|
},
|
|
178
182
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concentrator-arusd.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"concentrator-arusd.js","sourceRoot":"","sources":["../../../src/dex/concentrator-arusd/concentrator-arusd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAAmD;AACnD,4CAA+C;AAC/C,mFAA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,iBAAiB,CAAC,UAAU,EAC5B,QAAQ,EACR,QAAQ,CACT;aACF,CAAC;SACH;QACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAE3E,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;gBACjC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;oBACzC,CAAC,CAAC;wBACE;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;yBAClC;qBACF;oBACH,CAAC,CAAC;wBACE;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;yBACjC;qBACF;gBACL,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;;AAhPH,8CAiPC;AA7OiB,4BAAU,GAAG,IAAI,eAAS,CAAC,oBAAS,CAAC,CAAC;AASxC,oCAAkB,GAC9B,IAAA,6BAAqB,EAAC,gCAAuB,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { DexParams } from './types';
|
|
2
|
-
import { DexConfigMap
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
3
|
export declare const ConcentratorArusdConfig: DexConfigMap<DexParams>;
|
|
4
|
-
export declare const Adapters: Record<number, AdapterMappings>;
|