@paraswap/dex-lib 3.8.33 → 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.
- package/build/abi/sky-converter/DaiUsdsConverter.json +116 -0
- package/build/abi/sky-converter/MkrSkyConverter.json +118 -0
- package/build/dex/aave-gsm/aave-gsm.d.ts +0 -1
- package/build/dex/aave-gsm/aave-gsm.js +0 -4
- package/build/dex/aave-gsm/aave-gsm.js.map +1 -1
- package/build/dex/inception/inception.js +9 -1
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/inception/utils.d.ts +0 -1
- package/build/dex/inception/utils.js +1 -22
- package/build/dex/inception/utils.js.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/sky-converter/config.d.ts +3 -0
- package/build/dex/sky-converter/config.js +35 -0
- package/build/dex/sky-converter/config.js.map +1 -0
- package/build/dex/sky-converter/sky-converter.d.ts +35 -0
- package/build/dex/sky-converter/sky-converter.js +170 -0
- package/build/dex/sky-converter/sky-converter.js.map +1 -0
- package/build/dex/sky-converter/types.d.ts +12 -0
- package/build/dex/sky-converter/types.js +3 -0
- package/build/dex/sky-converter/types.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/sky-converter/DaiUsdsConverter.json +116 -0
- package/src/abi/sky-converter/MkrSkyConverter.json +118 -0
- package/src/dex/aave-gsm/aave-gsm.ts +0 -5
- package/src/dex/index.ts +2 -0
- package/src/dex/sky-converter/config.ts +31 -0
- package/src/dex/sky-converter/sky-converter-e2e.test.ts +113 -0
- package/src/dex/sky-converter/sky-converter-integration.test.ts +135 -0
- package/src/dex/sky-converter/sky-converter.ts +222 -0
- package/src/dex/sky-converter/types.ts +14 -0
- package/tests/constants-e2e.ts +15 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SkyConverter = void 0;
|
|
27
|
+
const constants_1 = require("../../constants");
|
|
28
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
30
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
31
|
+
const config_1 = require("./config");
|
|
32
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
33
|
+
class SkyConverter extends simple_exchange_1.SimpleExchange {
|
|
34
|
+
constructor(network, dexKey, dexHelper, config = config_1.SkyConverterConfig[dexKey][network]) {
|
|
35
|
+
super(dexHelper, dexKey);
|
|
36
|
+
this.network = network;
|
|
37
|
+
this.dexKey = dexKey;
|
|
38
|
+
this.dexHelper = dexHelper;
|
|
39
|
+
this.config = config;
|
|
40
|
+
this.hasConstantPriceLargeAmounts = true;
|
|
41
|
+
this.needWrapNative = false;
|
|
42
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
43
|
+
this.oldToken = this.config.oldTokenAddress.toLowerCase();
|
|
44
|
+
this.newToken = this.config.newTokenAddress.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
async initializePricing(blockNumber) { }
|
|
47
|
+
getAdapters(side) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
51
|
+
if (srcToken.address.toLowerCase() === this.oldToken &&
|
|
52
|
+
destToken.address.toLowerCase() === this.newToken) {
|
|
53
|
+
return [`${this.dexKey}_${destToken.address}`];
|
|
54
|
+
}
|
|
55
|
+
else if (srcToken.address.toLowerCase() === this.newToken &&
|
|
56
|
+
destToken.address.toLowerCase() === this.oldToken) {
|
|
57
|
+
return [`${this.dexKey}_${srcToken.address}`];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
oldAmountToNewAmount(amount) {
|
|
64
|
+
return amount * this.config.newTokenRateMultiplier;
|
|
65
|
+
}
|
|
66
|
+
newAmountToOldAmount(amount) {
|
|
67
|
+
return amount / this.config.newTokenRateMultiplier;
|
|
68
|
+
}
|
|
69
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
70
|
+
const isKnown = (srcToken.address.toLowerCase() === this.oldToken &&
|
|
71
|
+
destToken.address.toLowerCase() === this.newToken) ||
|
|
72
|
+
(srcToken.address.toLowerCase() === this.newToken &&
|
|
73
|
+
destToken.address.toLowerCase() === this.oldToken);
|
|
74
|
+
if (!isKnown) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const isOldToNew = srcToken.address.toLowerCase() === this.oldToken;
|
|
78
|
+
let mappingFunction;
|
|
79
|
+
if (side === constants_1.SwapSide.SELL) {
|
|
80
|
+
if (isOldToNew) {
|
|
81
|
+
mappingFunction = this.oldAmountToNewAmount.bind(this);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
mappingFunction = this.newAmountToOldAmount.bind(this);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (isOldToNew) {
|
|
89
|
+
mappingFunction = this.newAmountToOldAmount.bind(this);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
mappingFunction = this.oldAmountToNewAmount.bind(this);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
prices: amounts.map(el => mappingFunction(el)),
|
|
98
|
+
unit: bigint_constants_1.BI_POWS[18],
|
|
99
|
+
// TODO: Update after simulations
|
|
100
|
+
gasCost: 40000,
|
|
101
|
+
exchange: this.dexKey,
|
|
102
|
+
poolAddresses: [this.config.converterAddress],
|
|
103
|
+
data: null,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
108
|
+
getCalldataGasCost(poolPrices) {
|
|
109
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
110
|
+
}
|
|
111
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
112
|
+
// Encode here the payload for adapter
|
|
113
|
+
const payload = '';
|
|
114
|
+
return {
|
|
115
|
+
targetExchange: '0x',
|
|
116
|
+
payload,
|
|
117
|
+
networkFee: '0',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
121
|
+
const swapData = this.config.converterIface.encodeFunctionData(srcToken === this.oldToken
|
|
122
|
+
? this.config.oldToNewFunctionName
|
|
123
|
+
: this.config.newToOldFunctionName, [recipient, srcAmount]);
|
|
124
|
+
return {
|
|
125
|
+
needWrapNative: this.needWrapNative,
|
|
126
|
+
dexFuncHasRecipient: true,
|
|
127
|
+
exchangeData: swapData,
|
|
128
|
+
targetExchange: this.config.converterAddress,
|
|
129
|
+
returnAmountPos: undefined,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// Returns list of top pools based on liquidity. Max
|
|
133
|
+
// limit number pools should be returned.
|
|
134
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
135
|
+
if (tokenAddress.toLowerCase() === this.oldToken) {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
exchange: this.dexKey,
|
|
139
|
+
address: this.config.converterAddress,
|
|
140
|
+
connectorTokens: [
|
|
141
|
+
{
|
|
142
|
+
decimals: 18,
|
|
143
|
+
address: this.newToken,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
liquidityUSD: 1000000000, // infinite
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
else if (tokenAddress.toLowerCase() === this.newToken) {
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
exchange: this.dexKey,
|
|
154
|
+
address: this.config.converterAddress,
|
|
155
|
+
connectorTokens: [
|
|
156
|
+
{
|
|
157
|
+
decimals: 18,
|
|
158
|
+
address: this.oldToken,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
liquidityUSD: 1000000000, // infinite
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.SkyConverter = SkyConverter;
|
|
169
|
+
SkyConverter.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SkyConverterConfig);
|
|
170
|
+
//# sourceMappingURL=sky-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sky-converter.js","sourceRoot":"","sources":["../../../src/dex/sky-converter/sky-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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AAC,CACvB,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC5C,eAAe,EAAE,SAAS;SAC3B,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE;YAChD,OAAO;gBACL;oBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;oBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;oBACrC,eAAe,EAAE;wBACf;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,QAAQ;yBACvB;qBACF;oBACD,YAAY,EAAE,UAAU,EAAE,WAAW;iBACtC;aACF,CAAC;SACH;aAAM,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE;YACvD,OAAO;gBACL;oBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;oBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;oBACrC,eAAe,EAAE;wBACf;4BACE,QAAQ,EAAE,EAAE;4BACZ,OAAO,EAAE,IAAI,CAAC,QAAQ;yBACvB;qBACF;oBACD,YAAY,EAAE,UAAU,EAAE,WAAW;iBACtC;aACF,CAAC;SACH;QAED,OAAO,EAAE,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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/sky-converter/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -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
|
+
]
|
|
@@ -130,11 +130,6 @@ export class AaveGsm extends SimpleExchange implements IDex<AaveGsmData> {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
async updatePoolState(): Promise<void> {
|
|
134
|
-
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
135
|
-
await this.initializePricing(blockNumber);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
133
|
async getPoolState(gsm: string, blockNumber?: number): Promise<PoolState> {
|
|
139
134
|
if (!blockNumber) {
|
|
140
135
|
return this.eventPools[gsm].getStaleState()!;
|
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
|
+
});
|