@paraswap/dex-lib 3.8.33-pt-fix → 3.8.34-converters

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sky-converter.js","sourceRoot":"","sources":["../../../src/dex/sky-converter/sky-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAA8C;AAC9C,6DAAiD;AAEjD,MAAa,YACX,SAAQ,gCAAc;IActB,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACrB,SAAS,2BAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QAErD,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACrB,WAAM,GAAN,MAAM,CAAsC;QAf9C,iCAA4B,GAAG,IAAI,CAAC;QACpC,mBAAc,GAAG,KAAK,CAAC;QAiB9B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,WAAmB,IAAG,CAAC;IAE/C,WAAW,CAAC,IAAc;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,QAAe,EACf,SAAgB,EAChB,IAAc,EACd,WAAmB;QAEnB,IACE,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,QAAQ;YA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AAE,CAAC;IACZ,CAAC;;AAvMH,oCAwMC;AAjMe,+BAAkB,GAC9B,IAAA,6BAAqB,EAAC,2BAAkB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { Address } from '../../types';
3
+ export declare type SkyConverterData = null;
4
+ export declare type DexParams = {
5
+ converterAddress: Address;
6
+ oldTokenAddress: Address;
7
+ newTokenAddress: Address;
8
+ newTokenRateMultiplier: bigint;
9
+ oldToNewFunctionName: string;
10
+ newToOldFunctionName: string;
11
+ converterIface: Interface;
12
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/sky-converter/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "3.8.33-pt-fix",
3
+ "version": "3.8.34-converters",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -0,0 +1,116 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "daiJoin_", "type": "address" },
5
+ { "internalType": "address", "name": "usdsJoin_", "type": "address" }
6
+ ],
7
+ "stateMutability": "nonpayable",
8
+ "type": "constructor"
9
+ },
10
+ {
11
+ "anonymous": false,
12
+ "inputs": [
13
+ {
14
+ "indexed": true,
15
+ "internalType": "address",
16
+ "name": "caller",
17
+ "type": "address"
18
+ },
19
+ {
20
+ "indexed": true,
21
+ "internalType": "address",
22
+ "name": "usr",
23
+ "type": "address"
24
+ },
25
+ {
26
+ "indexed": false,
27
+ "internalType": "uint256",
28
+ "name": "wad",
29
+ "type": "uint256"
30
+ }
31
+ ],
32
+ "name": "DaiToUsds",
33
+ "type": "event"
34
+ },
35
+ {
36
+ "anonymous": false,
37
+ "inputs": [
38
+ {
39
+ "indexed": true,
40
+ "internalType": "address",
41
+ "name": "caller",
42
+ "type": "address"
43
+ },
44
+ {
45
+ "indexed": true,
46
+ "internalType": "address",
47
+ "name": "usr",
48
+ "type": "address"
49
+ },
50
+ {
51
+ "indexed": false,
52
+ "internalType": "uint256",
53
+ "name": "wad",
54
+ "type": "uint256"
55
+ }
56
+ ],
57
+ "name": "UsdsToDai",
58
+ "type": "event"
59
+ },
60
+ {
61
+ "inputs": [],
62
+ "name": "dai",
63
+ "outputs": [
64
+ { "internalType": "contract GemLike", "name": "", "type": "address" }
65
+ ],
66
+ "stateMutability": "view",
67
+ "type": "function"
68
+ },
69
+ {
70
+ "inputs": [],
71
+ "name": "daiJoin",
72
+ "outputs": [
73
+ { "internalType": "contract DaiJoinLike", "name": "", "type": "address" }
74
+ ],
75
+ "stateMutability": "view",
76
+ "type": "function"
77
+ },
78
+ {
79
+ "inputs": [
80
+ { "internalType": "address", "name": "usr", "type": "address" },
81
+ { "internalType": "uint256", "name": "wad", "type": "uint256" }
82
+ ],
83
+ "name": "daiToUsds",
84
+ "outputs": [],
85
+ "stateMutability": "nonpayable",
86
+ "type": "function"
87
+ },
88
+ {
89
+ "inputs": [],
90
+ "name": "usds",
91
+ "outputs": [
92
+ { "internalType": "contract GemLike", "name": "", "type": "address" }
93
+ ],
94
+ "stateMutability": "view",
95
+ "type": "function"
96
+ },
97
+ {
98
+ "inputs": [],
99
+ "name": "usdsJoin",
100
+ "outputs": [
101
+ { "internalType": "contract UsdsJoinLike", "name": "", "type": "address" }
102
+ ],
103
+ "stateMutability": "view",
104
+ "type": "function"
105
+ },
106
+ {
107
+ "inputs": [
108
+ { "internalType": "address", "name": "usr", "type": "address" },
109
+ { "internalType": "uint256", "name": "wad", "type": "uint256" }
110
+ ],
111
+ "name": "usdsToDai",
112
+ "outputs": [],
113
+ "stateMutability": "nonpayable",
114
+ "type": "function"
115
+ }
116
+ ]
@@ -0,0 +1,118 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "mkr_", "type": "address" },
5
+ { "internalType": "address", "name": "sky_", "type": "address" },
6
+ { "internalType": "uint256", "name": "rate_", "type": "uint256" }
7
+ ],
8
+ "stateMutability": "nonpayable",
9
+ "type": "constructor"
10
+ },
11
+ {
12
+ "anonymous": false,
13
+ "inputs": [
14
+ {
15
+ "indexed": true,
16
+ "internalType": "address",
17
+ "name": "caller",
18
+ "type": "address"
19
+ },
20
+ {
21
+ "indexed": true,
22
+ "internalType": "address",
23
+ "name": "usr",
24
+ "type": "address"
25
+ },
26
+ {
27
+ "indexed": false,
28
+ "internalType": "uint256",
29
+ "name": "mkrAmt",
30
+ "type": "uint256"
31
+ },
32
+ {
33
+ "indexed": false,
34
+ "internalType": "uint256",
35
+ "name": "skyAmt",
36
+ "type": "uint256"
37
+ }
38
+ ],
39
+ "name": "MkrToSky",
40
+ "type": "event"
41
+ },
42
+ {
43
+ "anonymous": false,
44
+ "inputs": [
45
+ {
46
+ "indexed": true,
47
+ "internalType": "address",
48
+ "name": "caller",
49
+ "type": "address"
50
+ },
51
+ {
52
+ "indexed": true,
53
+ "internalType": "address",
54
+ "name": "usr",
55
+ "type": "address"
56
+ },
57
+ {
58
+ "indexed": false,
59
+ "internalType": "uint256",
60
+ "name": "skyAmt",
61
+ "type": "uint256"
62
+ },
63
+ {
64
+ "indexed": false,
65
+ "internalType": "uint256",
66
+ "name": "mkrAmt",
67
+ "type": "uint256"
68
+ }
69
+ ],
70
+ "name": "SkyToMkr",
71
+ "type": "event"
72
+ },
73
+ {
74
+ "inputs": [],
75
+ "name": "mkr",
76
+ "outputs": [
77
+ { "internalType": "contract GemLike", "name": "", "type": "address" }
78
+ ],
79
+ "stateMutability": "view",
80
+ "type": "function"
81
+ },
82
+ {
83
+ "inputs": [
84
+ { "internalType": "address", "name": "usr", "type": "address" },
85
+ { "internalType": "uint256", "name": "mkrAmt", "type": "uint256" }
86
+ ],
87
+ "name": "mkrToSky",
88
+ "outputs": [],
89
+ "stateMutability": "nonpayable",
90
+ "type": "function"
91
+ },
92
+ {
93
+ "inputs": [],
94
+ "name": "rate",
95
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
96
+ "stateMutability": "view",
97
+ "type": "function"
98
+ },
99
+ {
100
+ "inputs": [],
101
+ "name": "sky",
102
+ "outputs": [
103
+ { "internalType": "contract GemLike", "name": "", "type": "address" }
104
+ ],
105
+ "stateMutability": "view",
106
+ "type": "function"
107
+ },
108
+ {
109
+ "inputs": [
110
+ { "internalType": "address", "name": "usr", "type": "address" },
111
+ { "internalType": "uint256", "name": "skyAmt", "type": "uint256" }
112
+ ],
113
+ "name": "skyToMkr",
114
+ "outputs": [],
115
+ "stateMutability": "nonpayable",
116
+ "type": "function"
117
+ }
118
+ ]
package/src/dex/index.ts CHANGED
@@ -89,6 +89,7 @@ import { FxProtocolRusd } from './fx-protocol-rusd/fx-protocol-rusd';
89
89
  import { AaveGsm } from './aave-gsm/aave-gsm';
90
90
  import { LitePsm } from './lite-psm/lite-psm';
91
91
  import { StkGHO } from './stkgho/stkgho';
92
+ import { SkyConverter } from './sky-converter/sky-converter';
92
93
 
93
94
  const LegacyDexes = [
94
95
  CurveV2,
@@ -173,6 +174,7 @@ const Dexes = [
173
174
  AaveGsm,
174
175
  LitePsm,
175
176
  StkGHO,
177
+ SkyConverter,
176
178
  ];
177
179
 
178
180
  export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
@@ -0,0 +1,31 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap } from '../../types';
3
+ import { Network } from '../../constants';
4
+ import DaiUsdsConverterABI from '../../abi/sky-converter/DaiUsdsConverter.json';
5
+ import MkrSkyConverterABI from '../../abi/sky-converter/MkrSkyConverter.json';
6
+ import { Interface } from '@ethersproject/abi';
7
+
8
+ export const SkyConverterConfig: DexConfigMap<DexParams> = {
9
+ DaiUsds: {
10
+ [Network.MAINNET]: {
11
+ converterAddress: '0x3225737a9Bbb6473CB4a45b7244ACa2BeFdB276A',
12
+ oldTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
13
+ newTokenAddress: '0xdC035D45d973E3EC169d2276DDab16f1e407384F',
14
+ oldToNewFunctionName: 'daiToUsds',
15
+ newToOldFunctionName: 'usdsToDai',
16
+ newTokenRateMultiplier: 1n, // constant, never to be updated
17
+ converterIface: new Interface(DaiUsdsConverterABI),
18
+ },
19
+ },
20
+ MkrSky: {
21
+ [Network.MAINNET]: {
22
+ converterAddress: '0xBDcFCA946b6CDd965f99a839e4435Bcdc1bc470B',
23
+ oldTokenAddress: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
24
+ newTokenAddress: '0x56072C95FAA701256059aa122697B133aDEd9279',
25
+ oldToNewFunctionName: 'mkrToSky',
26
+ newToOldFunctionName: 'skyToMkr',
27
+ newTokenRateMultiplier: 24_000n, // constant, never to be updated
28
+ converterIface: new Interface(MkrSkyConverterABI),
29
+ },
30
+ },
31
+ };
@@ -0,0 +1,113 @@
1
+ /* eslint-disable no-console */
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+
5
+ import { testE2E } from '../../../tests/utils-e2e';
6
+ import {
7
+ Tokens,
8
+ Holders,
9
+ NativeTokenSymbols,
10
+ } from '../../../tests/constants-e2e';
11
+ import { Network, ContractMethod, SwapSide } from '../../constants';
12
+ import { StaticJsonRpcProvider } from '@ethersproject/providers';
13
+ import { generateConfig } from '../../config';
14
+
15
+ function testForNetwork(
16
+ network: Network,
17
+ dexKey: string,
18
+ tokenASymbol: string,
19
+ tokenBSymbol: string,
20
+ tokenAAmount: string,
21
+ tokenBAmount: string,
22
+ ) {
23
+ const provider = new StaticJsonRpcProvider(
24
+ generateConfig(network).privateHttpProvider,
25
+ network,
26
+ );
27
+ const tokens = Tokens[network];
28
+ const holders = Holders[network];
29
+
30
+ const sideToContractMethods = new Map([
31
+ [SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
32
+ [SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
33
+ ]);
34
+
35
+ describe(`${network}`, () => {
36
+ sideToContractMethods.forEach((contractMethods, side) =>
37
+ describe(`${side}`, () => {
38
+ contractMethods.forEach((contractMethod: ContractMethod) => {
39
+ describe(`${contractMethod}`, () => {
40
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
41
+ await testE2E(
42
+ tokens[tokenASymbol],
43
+ tokens[tokenBSymbol],
44
+ holders[tokenASymbol],
45
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
46
+ side,
47
+ dexKey,
48
+ contractMethod,
49
+ network,
50
+ provider,
51
+ );
52
+ });
53
+ it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
54
+ await testE2E(
55
+ tokens[tokenBSymbol],
56
+ tokens[tokenASymbol],
57
+ holders[tokenBSymbol],
58
+ side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
59
+ side,
60
+ dexKey,
61
+ contractMethod,
62
+ network,
63
+ provider,
64
+ );
65
+ });
66
+ });
67
+ });
68
+ }),
69
+ );
70
+ });
71
+ }
72
+
73
+ describe('SkyConverter E2E', () => {
74
+ describe('USDS - DAI', () => {
75
+ const dexKey = 'DaiUsds';
76
+ const network = Network.MAINNET;
77
+
78
+ const tokenASymbol: string = 'DAI';
79
+ const tokenBSymbol: string = 'USDS';
80
+
81
+ const tokenAAmount: string = '10000000000000000000';
82
+ const tokenBAmount: string = '10000000000000000000';
83
+
84
+ testForNetwork(
85
+ network,
86
+ dexKey,
87
+ tokenASymbol,
88
+ tokenBSymbol,
89
+ tokenAAmount,
90
+ tokenBAmount,
91
+ );
92
+ });
93
+
94
+ describe('MKR - SKY', () => {
95
+ const dexKey = 'MkrSky';
96
+ const network = Network.MAINNET;
97
+
98
+ const tokenASymbol: string = 'MKR';
99
+ const tokenBSymbol: string = 'SKY';
100
+
101
+ const tokenAAmount: string = '10000000000000000000';
102
+ const tokenBAmount: string = '10000000000000000000';
103
+
104
+ testForNetwork(
105
+ network,
106
+ dexKey,
107
+ tokenASymbol,
108
+ tokenBSymbol,
109
+ tokenAAmount,
110
+ tokenBAmount,
111
+ );
112
+ });
113
+ });
@@ -0,0 +1,135 @@
1
+ import dotenv from 'dotenv';
2
+ dotenv.config();
3
+
4
+ import { DummyDexHelper } from '../../dex-helper/index';
5
+ import { Network, SwapSide } from '../../constants';
6
+ import { SkyConverter } from './sky-converter';
7
+ import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
8
+ import { Tokens } from '../../../tests/constants-e2e';
9
+ import { BI_POWS } from '../../bigint-constants';
10
+
11
+ const network = Network.MAINNET;
12
+
13
+ const tokenAAmounts = [
14
+ 0n,
15
+ 1n * BI_POWS[18],
16
+ 2n * BI_POWS[18],
17
+ 3n * BI_POWS[18],
18
+ 4n * BI_POWS[18],
19
+ 5n * BI_POWS[18],
20
+ 6n * BI_POWS[18],
21
+ 7n * BI_POWS[18],
22
+ 8n * BI_POWS[18],
23
+ 9n * BI_POWS[18],
24
+ 10n * BI_POWS[18],
25
+ ];
26
+
27
+ const tokenBAmounts = [
28
+ 0n,
29
+ 1n * BI_POWS[18],
30
+ 2n * BI_POWS[18],
31
+ 3n * BI_POWS[18],
32
+ 4n * BI_POWS[18],
33
+ 5n * BI_POWS[18],
34
+ 6n * BI_POWS[18],
35
+ 7n * BI_POWS[18],
36
+ 8n * BI_POWS[18],
37
+ 9n * BI_POWS[18],
38
+ 10n * BI_POWS[18],
39
+ ];
40
+
41
+ ['DaiUsds', 'MkrSky'].forEach(dexKey => {
42
+ const TokenASymbol = dexKey === 'DaiUsds' ? 'DAI' : 'MKR';
43
+ const TokenA = Tokens[network][TokenASymbol];
44
+
45
+ const TokenBSymbol = dexKey === 'DaiUsds' ? 'USDS' : 'SKY';
46
+ const TokenB = Tokens[network][TokenBSymbol];
47
+
48
+ describe(dexKey, function () {
49
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
50
+ const dexHelper = new DummyDexHelper(network);
51
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
52
+ const skyConverter = new SkyConverter(network, dexKey, dexHelper);
53
+
54
+ const pools = await skyConverter.getPoolIdentifiers(
55
+ TokenA,
56
+ TokenB,
57
+ SwapSide.SELL,
58
+ blocknumber,
59
+ );
60
+ console.log(
61
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
62
+ pools,
63
+ );
64
+
65
+ expect(pools.length).toBeGreaterThan(0);
66
+
67
+ const poolPrices = await skyConverter.getPricesVolume(
68
+ TokenA,
69
+ TokenB,
70
+ tokenAAmounts,
71
+ SwapSide.SELL,
72
+ blocknumber,
73
+ pools,
74
+ );
75
+ console.log(
76
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
77
+ poolPrices,
78
+ );
79
+
80
+ expect(poolPrices).not.toBeNull();
81
+ checkPoolPrices(poolPrices!, tokenAAmounts, SwapSide.SELL, dexKey);
82
+ });
83
+
84
+ it('getPoolIdentifiers and getPricesVolume BUY', async function () {
85
+ const dexHelper = new DummyDexHelper(network);
86
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
87
+ const skyConverter = new SkyConverter(network, dexKey, dexHelper);
88
+
89
+ const pools = await skyConverter.getPoolIdentifiers(
90
+ TokenA,
91
+ TokenB,
92
+ SwapSide.BUY,
93
+ blocknumber,
94
+ );
95
+ console.log(
96
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
97
+ pools,
98
+ );
99
+
100
+ expect(pools.length).toBeGreaterThan(0);
101
+
102
+ const poolPrices = await skyConverter.getPricesVolume(
103
+ TokenA,
104
+ TokenB,
105
+ tokenBAmounts,
106
+ SwapSide.BUY,
107
+ blocknumber,
108
+ pools,
109
+ );
110
+ console.log(
111
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
112
+ poolPrices,
113
+ );
114
+
115
+ expect(poolPrices).not.toBeNull();
116
+ checkPoolPrices(poolPrices!, tokenBAmounts, SwapSide.BUY, dexKey);
117
+ });
118
+
119
+ it('getTopPoolsForToken', async function () {
120
+ const dexHelper = new DummyDexHelper(network);
121
+ const skyConverter = new SkyConverter(network, dexKey, dexHelper);
122
+
123
+ const poolLiquidity = await skyConverter.getTopPoolsForToken(
124
+ TokenA.address,
125
+ 10,
126
+ );
127
+ console.log(
128
+ `${TokenASymbol} Top Pools:`,
129
+ JSON.stringify(poolLiquidity, null, 2),
130
+ );
131
+
132
+ checkPoolsLiquidity(poolLiquidity, TokenA.address, dexKey);
133
+ });
134
+ });
135
+ });