@openocean.finance/openocean-sdk 0.1.71 → 0.1.73
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/lib/api/index.js +136 -0
- package/lib/api/vo/RequestVo.js +401 -0
- package/lib/asset/abi/ERC20_abi.js +119 -0
- package/lib/asset/abi/aggregator.js +391 -0
- package/lib/config/Chains.js +508 -0
- package/lib/config/Wallets.js +81 -0
- package/lib/config/index.js +11 -0
- package/lib/index.js +20 -2
- package/lib/swapSdk/Approve.js +227 -0
- package/lib/swapSdk/ConnectWallet.js +311 -0
- package/lib/swapSdk/NotoMobile.js +141 -0
- package/lib/swapSdk/RequestVo.js +94 -0
- package/lib/swapSdk/Swap.js +739 -0
- package/lib/swapSdk/getAllowance.js +97 -0
- package/lib/swapSdk/getBalance.js +220 -0
- package/lib/swapSdk/index.d.ts +1 -1
- package/lib/swapSdk/index.js +277 -0
- package/lib/swapSdk/limitOrder.d.ts +1 -1
- package/lib/swapSdk/limitOrder.js +234 -0
- package/lib/swapSdk/qrcode.d.ts +6 -0
- package/lib/swapSdk/qrcode.js +969 -0
- package/lib/utils/ajx.js +150 -0
- package/lib/utils/index.js +91 -0
- package/lib/utils/limit-order-sdk/connector/private-key-provider.connector.d.ts +10 -0
- package/lib/utils/limit-order-sdk/connector/private-key-provider.connector.js +36 -0
- package/lib/utils/limit-order-sdk/connector/provider.connector.d.ts +1 -0
- package/lib/utils/limit-order-sdk/connector/provider.connector.js +2 -0
- package/lib/utils/limit-order-sdk/connector/web3-provider.connector.d.ts +9 -0
- package/lib/utils/limit-order-sdk/connector/web3-provider.connector.js +38 -0
- package/lib/utils/limit-order-sdk/erc20.facade.d.ts +7 -0
- package/lib/utils/limit-order-sdk/erc20.facade.js +19 -0
- package/lib/utils/limit-order-sdk/index.d.ts +1 -0
- package/lib/utils/limit-order-sdk/index.js +14 -0
- package/lib/utils/limit-order-sdk/limit-order-predicate.builder.d.ts +12 -0
- package/lib/utils/limit-order-sdk/limit-order-predicate.builder.js +60 -0
- package/lib/utils/limit-order-sdk/limit-order-protocol.const.d.ts +18 -0
- package/lib/utils/limit-order-sdk/limit-order-protocol.const.js +45 -0
- package/lib/utils/limit-order-sdk/limit-order-protocol.facade.d.ts +26 -0
- package/lib/utils/limit-order-sdk/limit-order-protocol.facade.js +180 -0
- package/lib/utils/limit-order-sdk/limit-order.builder.d.ts +101 -0
- package/lib/utils/limit-order-sdk/limit-order.builder.js +120 -0
- package/lib/utils/limit-order-sdk/model/abi.model.d.ts +1 -0
- package/lib/utils/limit-order-sdk/model/abi.model.js +2 -0
- package/lib/utils/limit-order-sdk/model/eip712.model.d.ts +1 -0
- package/lib/utils/limit-order-sdk/model/eip712.model.js +2 -0
- package/lib/utils/limit-order-sdk/model/limit-order-protocol.model.d.ts +3 -0
- package/lib/utils/limit-order-sdk/model/limit-order-protocol.model.js +38 -0
- package/lib/utils/limit-order-sdk/utils/get-rpc-code.d.ts +2 -0
- package/lib/utils/limit-order-sdk/utils/get-rpc-code.js +28 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.const.d.ts +89 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.const.js +140 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.helpers.d.ts +10 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.helpers.js +254 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.model.d.ts +1 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.model.js +2 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.utils.d.ts +2 -0
- package/lib/utils/limit-order-sdk/utils/limit-order-rfq.utils.js +82 -0
- package/lib/utils/web3.js +9 -0
- package/package.json +2 -2
package/lib/utils/ajx.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.post = exports.get = exports.validateReq = void 0;
|
|
40
|
+
var class_validator_1 = require("class-validator");
|
|
41
|
+
var class_transformer_1 = require("class-transformer");
|
|
42
|
+
var axios = require('axios');
|
|
43
|
+
function validateReq(option, vo) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
var reqAllowanceVo, errors;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
reqAllowanceVo = (0, class_transformer_1.plainToClass)(vo, option);
|
|
50
|
+
return [4 /*yield*/, (0, class_validator_1.validate)(reqAllowanceVo)];
|
|
51
|
+
case 1:
|
|
52
|
+
errors = _a.sent();
|
|
53
|
+
if (errors.length) {
|
|
54
|
+
return [2 /*return*/, errors.reduce(function (o, n) {
|
|
55
|
+
Object.keys(n.constraints).forEach(function (key) {
|
|
56
|
+
o.push(n.constraints[key]);
|
|
57
|
+
});
|
|
58
|
+
return o;
|
|
59
|
+
}, []).join(', ')];
|
|
60
|
+
}
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.validateReq = validateReq;
|
|
67
|
+
function get(url, option, vo) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var errors, error_1;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
_a.trys.push([0, 2, , 3]);
|
|
77
|
+
return [4 /*yield*/, validateReq(option, vo)];
|
|
78
|
+
case 1:
|
|
79
|
+
errors = _a.sent();
|
|
80
|
+
if (errors) {
|
|
81
|
+
reject(errors);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
axios({
|
|
85
|
+
method: 'get',
|
|
86
|
+
url: "".concat(url),
|
|
87
|
+
params: option
|
|
88
|
+
})
|
|
89
|
+
.then(function (response) {
|
|
90
|
+
resolve(response.data);
|
|
91
|
+
})
|
|
92
|
+
.catch(function (error) {
|
|
93
|
+
reject(error ? error.message : 'An unknown error');
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return [3 /*break*/, 3];
|
|
97
|
+
case 2:
|
|
98
|
+
error_1 = _a.sent();
|
|
99
|
+
reject(error_1 || 'An unknown error');
|
|
100
|
+
return [3 /*break*/, 3];
|
|
101
|
+
case 3: return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); })];
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.get = get;
|
|
109
|
+
function post(url, option, vo) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var _this = this;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
114
|
+
var errors, error_2;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
_a.trys.push([0, 2, , 3]);
|
|
119
|
+
return [4 /*yield*/, validateReq(option, vo)];
|
|
120
|
+
case 1:
|
|
121
|
+
errors = _a.sent();
|
|
122
|
+
if (errors) {
|
|
123
|
+
reject(errors);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
axios({
|
|
127
|
+
method: 'post',
|
|
128
|
+
url: "".concat(url),
|
|
129
|
+
data: option
|
|
130
|
+
})
|
|
131
|
+
.then(function (response) {
|
|
132
|
+
resolve(response.data);
|
|
133
|
+
})
|
|
134
|
+
.catch(function (error) {
|
|
135
|
+
reject(error ? error.message : 'An unknown error');
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return [3 /*break*/, 3];
|
|
139
|
+
case 2:
|
|
140
|
+
error_2 = _a.sent();
|
|
141
|
+
reject(error_2 || 'An unknown error');
|
|
142
|
+
return [3 /*break*/, 3];
|
|
143
|
+
case 3: return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}); })];
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.post = post;
|
|
@@ -0,0 +1,91 @@
|
|
|
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.isPc = exports.utils = exports.Utils = exports.ChainNames = void 0;
|
|
7
|
+
var axios = require('axios');
|
|
8
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
var ChainNames;
|
|
10
|
+
(function (ChainNames) {
|
|
11
|
+
ChainNames[ChainNames["eth"] = 0] = "eth";
|
|
12
|
+
ChainNames[ChainNames["solana"] = 1] = "solana";
|
|
13
|
+
ChainNames[ChainNames["ont"] = 2] = "ont";
|
|
14
|
+
ChainNames[ChainNames["terra"] = 3] = "terra";
|
|
15
|
+
ChainNames[ChainNames["tron"] = 4] = "tron";
|
|
16
|
+
ChainNames[ChainNames["osmosis"] = 5] = "osmosis";
|
|
17
|
+
ChainNames[ChainNames["sifchain"] = 6] = "sifchain";
|
|
18
|
+
ChainNames[ChainNames["ropsten"] = 7] = "ropsten";
|
|
19
|
+
ChainNames[ChainNames["bsc"] = 8] = "bsc";
|
|
20
|
+
ChainNames[ChainNames["okex"] = 9] = "okex";
|
|
21
|
+
ChainNames[ChainNames["polygon"] = 10] = "polygon";
|
|
22
|
+
ChainNames[ChainNames["fantom"] = 11] = "fantom";
|
|
23
|
+
ChainNames[ChainNames["heco"] = 12] = "heco";
|
|
24
|
+
ChainNames[ChainNames["avax"] = 13] = "avax";
|
|
25
|
+
ChainNames[ChainNames["arbitrum"] = 14] = "arbitrum";
|
|
26
|
+
ChainNames[ChainNames["xdai"] = 15] = "xdai";
|
|
27
|
+
ChainNames[ChainNames["optimism"] = 16] = "optimism";
|
|
28
|
+
ChainNames[ChainNames["boba"] = 17] = "boba";
|
|
29
|
+
ChainNames[ChainNames["moonriver"] = 18] = "moonriver";
|
|
30
|
+
ChainNames[ChainNames["aurora"] = 19] = "aurora";
|
|
31
|
+
ChainNames[ChainNames["cronos"] = 20] = "cronos";
|
|
32
|
+
ChainNames[ChainNames["cosmos"] = 21] = "cosmos";
|
|
33
|
+
ChainNames[ChainNames["harmony"] = 22] = "harmony";
|
|
34
|
+
ChainNames[ChainNames["bsctest"] = 23] = "bsctest";
|
|
35
|
+
})(ChainNames = exports.ChainNames || (exports.ChainNames = {}));
|
|
36
|
+
var Utils = /** @class */ (function () {
|
|
37
|
+
function Utils() {
|
|
38
|
+
}
|
|
39
|
+
Utils.prototype.sleep = function (interval) {
|
|
40
|
+
return new Promise(function (resolve) {
|
|
41
|
+
setTimeout(resolve, interval);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Utils.prototype.getShift = function (a, b) {
|
|
45
|
+
return new bignumber_js_1.default(a).shiftedBy(Number(b)).toFixed();
|
|
46
|
+
};
|
|
47
|
+
Utils.prototype.decimals2Amount = function (amount, decimals) {
|
|
48
|
+
return this.getShift(amount, -decimals);
|
|
49
|
+
};
|
|
50
|
+
Utils.prototype.amount2Decimals = function (amount, decimals) {
|
|
51
|
+
return this.getFixed(this.getShift(amount, decimals), 0);
|
|
52
|
+
};
|
|
53
|
+
Utils.prototype.getFixed = function (val, fixed, trailingZeros) {
|
|
54
|
+
var numStr = val || '0';
|
|
55
|
+
if (trailingZeros) {
|
|
56
|
+
return new bignumber_js_1.default(numStr).toFixed(fixed);
|
|
57
|
+
}
|
|
58
|
+
return new bignumber_js_1.default(numStr).decimalPlaces(fixed).toString();
|
|
59
|
+
};
|
|
60
|
+
Utils.prototype.toFixed = function (n, k, z) {
|
|
61
|
+
if (isNaN(n)) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
if (!k)
|
|
65
|
+
k = 4;
|
|
66
|
+
var a = Math.pow(10, k);
|
|
67
|
+
if (Number(n) < 0) {
|
|
68
|
+
a = Math.ceil(Number(n) * a) / a;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
a = Math.floor(Number(n) * a) / a;
|
|
72
|
+
}
|
|
73
|
+
if (!z) {
|
|
74
|
+
return a;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return a.toFixed(k);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return Utils;
|
|
81
|
+
}());
|
|
82
|
+
exports.Utils = Utils;
|
|
83
|
+
exports.utils = new Utils();
|
|
84
|
+
function isPc() {
|
|
85
|
+
var userAgent = navigator.userAgent, Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
|
|
86
|
+
console.log('userAgent:', userAgent);
|
|
87
|
+
return Agents.some(function (i) {
|
|
88
|
+
return userAgent.includes(i);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.isPc = isPc;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export class PrivateKeyProviderConnector {
|
|
3
|
+
constructor(privateKey: any, web3Provider: any);
|
|
4
|
+
privateKey: any;
|
|
5
|
+
web3Provider: any;
|
|
6
|
+
contractEncodeABI(abi: any, address: any, methodName: any, methodParams: any): any;
|
|
7
|
+
signTypedData(_walletAddress: any, typedData: any, _typedDataHash?: string): Promise<any>;
|
|
8
|
+
ethCall(contractAddress: any, callData: any): any;
|
|
9
|
+
decodeABIParameter(type: any, hex: any): any;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivateKeyProviderConnector = void 0;
|
|
4
|
+
var eth_sig_util_1 = require("eth-sig-util");
|
|
5
|
+
var PrivateKeyProviderConnector = /** @class */ (function () {
|
|
6
|
+
function PrivateKeyProviderConnector(privateKey, web3Provider) {
|
|
7
|
+
this.privateKey = privateKey;
|
|
8
|
+
this.web3Provider = web3Provider;
|
|
9
|
+
}
|
|
10
|
+
PrivateKeyProviderConnector.prototype.contractEncodeABI = function (abi, address, methodName, methodParams) {
|
|
11
|
+
var _a;
|
|
12
|
+
var contract = new this.web3Provider.eth.Contract(abi, address === null ? undefined : address);
|
|
13
|
+
return (_a = contract.methods)[methodName].apply(_a, methodParams).encodeABI();
|
|
14
|
+
};
|
|
15
|
+
PrivateKeyProviderConnector.prototype.signTypedData = function (_walletAddress, typedData,
|
|
16
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
17
|
+
_typedDataHash) {
|
|
18
|
+
if (_typedDataHash === void 0) { _typedDataHash = ''; }
|
|
19
|
+
var result = eth_sig_util_1.signTypedData_v4(Buffer.from(this.privateKey, 'hex'), {
|
|
20
|
+
data: typedData,
|
|
21
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
22
|
+
});
|
|
23
|
+
return Promise.resolve(result);
|
|
24
|
+
};
|
|
25
|
+
PrivateKeyProviderConnector.prototype.ethCall = function (contractAddress, callData) {
|
|
26
|
+
return this.web3Provider.eth.call({
|
|
27
|
+
to: contractAddress,
|
|
28
|
+
data: callData,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
PrivateKeyProviderConnector.prototype.decodeABIParameter = function (type, hex) {
|
|
32
|
+
return this.web3Provider.eth.abi.decodeParameter(type, hex);
|
|
33
|
+
};
|
|
34
|
+
return PrivateKeyProviderConnector;
|
|
35
|
+
}());
|
|
36
|
+
exports.PrivateKeyProviderConnector = PrivateKeyProviderConnector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export class Web3ProviderConnector {
|
|
3
|
+
constructor(web3Provider: any);
|
|
4
|
+
web3Provider: any;
|
|
5
|
+
contractEncodeABI(abi: any, address: any, methodName: any, methodParams: any): any;
|
|
6
|
+
signTypedData(walletAddress: any, typedData: any, _typedDataHash: any): any;
|
|
7
|
+
ethCall(contractAddress: any, callData: any): any;
|
|
8
|
+
decodeABIParameter(type: any, hex: any): any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Web3ProviderConnector = void 0;
|
|
4
|
+
var Web3ProviderConnector = /** @class */ (function () {
|
|
5
|
+
function Web3ProviderConnector(web3Provider) {
|
|
6
|
+
this.web3Provider = web3Provider;
|
|
7
|
+
}
|
|
8
|
+
Web3ProviderConnector.prototype.contractEncodeABI = function (abi, address, methodName, methodParams) {
|
|
9
|
+
var _a;
|
|
10
|
+
var contract = new this.web3Provider.eth.Contract(abi, address === null ? undefined : address);
|
|
11
|
+
return (_a = contract.methods)[methodName].apply(_a, methodParams).encodeABI();
|
|
12
|
+
};
|
|
13
|
+
Web3ProviderConnector.prototype.signTypedData = function (walletAddress, typedData,
|
|
14
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
15
|
+
_typedDataHash) {
|
|
16
|
+
var extendedWeb3 = this.web3Provider.extend({
|
|
17
|
+
methods: [
|
|
18
|
+
{
|
|
19
|
+
name: 'signTypedDataV4',
|
|
20
|
+
call: 'eth_signTypedData_v4',
|
|
21
|
+
params: 2,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
return extendedWeb3.signTypedDataV4(walletAddress, JSON.stringify(typedData));
|
|
26
|
+
};
|
|
27
|
+
Web3ProviderConnector.prototype.ethCall = function (contractAddress, callData) {
|
|
28
|
+
return this.web3Provider.eth.call({
|
|
29
|
+
to: contractAddress,
|
|
30
|
+
data: callData,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
Web3ProviderConnector.prototype.decodeABIParameter = function (type, hex) {
|
|
34
|
+
return this.web3Provider.eth.abi.decodeParameter(type, hex);
|
|
35
|
+
};
|
|
36
|
+
return Web3ProviderConnector;
|
|
37
|
+
}());
|
|
38
|
+
exports.Web3ProviderConnector = Web3ProviderConnector;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Erc20Facade = exports.Erc20Methods = void 0;
|
|
4
|
+
var limit_order_protocol_const_1 = require("./limit-order-protocol.const");
|
|
5
|
+
var Erc20Methods;
|
|
6
|
+
(function (Erc20Methods) {
|
|
7
|
+
Erc20Methods["transferFrom"] = "transferFrom";
|
|
8
|
+
Erc20Methods["balanceOf"] = "balanceOf";
|
|
9
|
+
})(Erc20Methods = exports.Erc20Methods || (exports.Erc20Methods = {}));
|
|
10
|
+
var Erc20Facade = /** @class */ (function () {
|
|
11
|
+
function Erc20Facade(providerConnector) {
|
|
12
|
+
this.providerConnector = providerConnector;
|
|
13
|
+
}
|
|
14
|
+
Erc20Facade.prototype.balanceOf = function (tokenAddress, walletAddress) {
|
|
15
|
+
return this.providerConnector.contractEncodeABI(limit_order_protocol_const_1.ERC20_ABI, tokenAddress, Erc20Methods.balanceOf, [walletAddress]);
|
|
16
|
+
};
|
|
17
|
+
return Erc20Facade;
|
|
18
|
+
}());
|
|
19
|
+
exports.Erc20Facade = Erc20Facade;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./erc20.facade"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./limit-order.builder"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./limit-order-predicate.builder"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./limit-order-protocol.const"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./limit-order-protocol.facade"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./connector/provider.connector"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./connector/web3-provider.connector"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./connector/private-key-provider.connector"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./model/abi.model"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./model/eip712.model"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./model/limit-order-protocol.model"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export class LimitOrderPredicateBuilder {
|
|
3
|
+
constructor(facade: any);
|
|
4
|
+
facade: any;
|
|
5
|
+
and: (...predicates: any[]) => any;
|
|
6
|
+
or: (...predicates: any[]) => any;
|
|
7
|
+
eq: (value: any, address: any, callData: any) => any;
|
|
8
|
+
lt: (value: any, address: any, callData: any) => any;
|
|
9
|
+
gt: (value: any, address: any, callData: any) => any;
|
|
10
|
+
nonceEquals: (makerAddress: any, makerNonce: any) => any;
|
|
11
|
+
timestampBelow: (timestamp: any) => any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LimitOrderPredicateBuilder = void 0;
|
|
4
|
+
var limit_order_protocol_model_1 = require("./model/limit-order-protocol.model");
|
|
5
|
+
var limit_order_protocol_const_1 = require("./limit-order-protocol.const");
|
|
6
|
+
var LimitOrderPredicateBuilder = /** @class */ (function () {
|
|
7
|
+
function LimitOrderPredicateBuilder(facade) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
this.facade = facade;
|
|
10
|
+
this.and = function () {
|
|
11
|
+
var predicates = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
predicates[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.and, [
|
|
16
|
+
predicates.map(function () { return _this.facade.contractAddress; }),
|
|
17
|
+
predicates,
|
|
18
|
+
]);
|
|
19
|
+
};
|
|
20
|
+
this.or = function () {
|
|
21
|
+
var predicates = [];
|
|
22
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
23
|
+
predicates[_i] = arguments[_i];
|
|
24
|
+
}
|
|
25
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.or, [
|
|
26
|
+
predicates.map(function () { return _this.facade.contractAddress; }),
|
|
27
|
+
predicates,
|
|
28
|
+
]);
|
|
29
|
+
};
|
|
30
|
+
this.eq = function (value, address, callData) {
|
|
31
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.eq, [
|
|
32
|
+
value,
|
|
33
|
+
address,
|
|
34
|
+
callData,
|
|
35
|
+
]);
|
|
36
|
+
};
|
|
37
|
+
this.lt = function (value, address, callData) {
|
|
38
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.lt, [
|
|
39
|
+
value,
|
|
40
|
+
address,
|
|
41
|
+
callData,
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
this.gt = function (value, address, callData) {
|
|
45
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.gt, [
|
|
46
|
+
value,
|
|
47
|
+
address,
|
|
48
|
+
callData,
|
|
49
|
+
]);
|
|
50
|
+
};
|
|
51
|
+
this.nonceEquals = function (makerAddress, makerNonce) {
|
|
52
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.nonceEquals, [makerAddress, makerNonce]);
|
|
53
|
+
};
|
|
54
|
+
this.timestampBelow = function (timestamp) {
|
|
55
|
+
return _this.facade.getContractCallData(limit_order_protocol_model_1.LimitOrderProtocolMethods.timestampBelow, [limit_order_protocol_const_1.ZX + timestamp.toString(16)]);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return LimitOrderPredicateBuilder;
|
|
59
|
+
}());
|
|
60
|
+
exports.LimitOrderPredicateBuilder = LimitOrderPredicateBuilder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export var PROTOCOL_NAME: string;
|
|
3
|
+
export var PROTOCOL_VERSION: string;
|
|
4
|
+
export var ZX: string;
|
|
5
|
+
export var ZERO_ADDRESS: string;
|
|
6
|
+
export var CALL_RESULTS_PREFIX: string;
|
|
7
|
+
export var EIP712_DOMAIN: {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}[];
|
|
11
|
+
export var ORDER_STRUCTURE: {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}[];
|
|
15
|
+
export var RFQ_ORDER_STRUCTURE: {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RFQ_ORDER_STRUCTURE = exports.ORDER_STRUCTURE = exports.EIP712_DOMAIN = exports.ERC20_ABI = exports.LIMIT_ORDER_PROTOCOL_ABI = exports.CALL_RESULTS_PREFIX = exports.ZERO_ADDRESS = exports.ZX = exports.PROTOCOL_VERSION = exports.PROTOCOL_NAME = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var LimitOrderProtocol_json_1 = tslib_1.__importDefault(require("./abi/LimitOrderProtocol.json"));
|
|
6
|
+
var ERC20ABI_json_1 = tslib_1.__importDefault(require("./abi/ERC20ABI.json"));
|
|
7
|
+
exports.PROTOCOL_NAME = '1inch Limit Order Protocol';
|
|
8
|
+
exports.PROTOCOL_VERSION = '2';
|
|
9
|
+
exports.ZX = '0x';
|
|
10
|
+
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
11
|
+
exports.CALL_RESULTS_PREFIX = 'CALL_RESULTS_';
|
|
12
|
+
exports.LIMIT_ORDER_PROTOCOL_ABI = LimitOrderProtocol_json_1.default;
|
|
13
|
+
exports.ERC20_ABI = ERC20ABI_json_1.default;
|
|
14
|
+
exports.EIP712_DOMAIN = [
|
|
15
|
+
{ name: 'name', type: 'string' },
|
|
16
|
+
{ name: 'version', type: 'string' },
|
|
17
|
+
{ name: 'chainId', type: 'uint256' },
|
|
18
|
+
{ name: 'verifyingContract', type: 'address' },
|
|
19
|
+
];
|
|
20
|
+
exports.ORDER_STRUCTURE = [
|
|
21
|
+
{ name: 'salt', type: 'uint256' },
|
|
22
|
+
{ name: 'makerAsset', type: 'address' },
|
|
23
|
+
{ name: 'takerAsset', type: 'address' },
|
|
24
|
+
{ name: 'maker', type: 'address' },
|
|
25
|
+
{ name: 'receiver', type: 'address' },
|
|
26
|
+
{ name: 'allowedSender', type: 'address' },
|
|
27
|
+
{ name: 'makingAmount', type: 'uint256' },
|
|
28
|
+
{ name: 'takingAmount', type: 'uint256' },
|
|
29
|
+
{ name: 'makerAssetData', type: 'bytes' },
|
|
30
|
+
{ name: 'takerAssetData', type: 'bytes' },
|
|
31
|
+
{ name: 'getMakerAmount', type: 'bytes' },
|
|
32
|
+
{ name: 'getTakerAmount', type: 'bytes' },
|
|
33
|
+
{ name: 'predicate', type: 'bytes' },
|
|
34
|
+
{ name: 'permit', type: 'bytes' },
|
|
35
|
+
{ name: 'interaction', type: 'bytes' },
|
|
36
|
+
];
|
|
37
|
+
exports.RFQ_ORDER_STRUCTURE = [
|
|
38
|
+
{ name: 'info', type: 'uint256' },
|
|
39
|
+
{ name: 'makerAsset', type: 'address' },
|
|
40
|
+
{ name: 'takerAsset', type: 'address' },
|
|
41
|
+
{ name: 'maker', type: 'address' },
|
|
42
|
+
{ name: 'allowedSender', type: 'address' },
|
|
43
|
+
{ name: 'makingAmount', type: 'uint256' },
|
|
44
|
+
{ name: 'takingAmount', type: 'uint256' },
|
|
45
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export class LimitOrderProtocolFacade {
|
|
3
|
+
constructor(contractAddress: any, providerConnector: any);
|
|
4
|
+
contractAddress: any;
|
|
5
|
+
providerConnector: any;
|
|
6
|
+
fillLimitOrder(order: any, signature: any, makerAmount: any, takerAmount: any, thresholdAmount: any): any;
|
|
7
|
+
fillOrderToWithPermit(params: any): any;
|
|
8
|
+
fillRFQOrder(order: any, signature: any, makerAmount: any, takerAmount: any): any;
|
|
9
|
+
cancelLimitOrder(order: any): any;
|
|
10
|
+
cancelRFQOrder(orderInfo: any): any;
|
|
11
|
+
nonce(makerAddress: any): any;
|
|
12
|
+
advanceNonce(count: any): any;
|
|
13
|
+
increaseNonce(): any;
|
|
14
|
+
checkPredicate(order: any): any;
|
|
15
|
+
remaining(orderHash: any): any;
|
|
16
|
+
simulateCalls(tokens: any, data: any): any;
|
|
17
|
+
domainSeparator(): any;
|
|
18
|
+
getContractCallData(methodName: any, methodParams?: any[]): any;
|
|
19
|
+
parseRemainingResponse(response: any): bignumber_1.BigNumber | null;
|
|
20
|
+
parseSimulateTransferResponse(response: any): boolean | null;
|
|
21
|
+
parseSimulateTransferError(error: any): boolean | null;
|
|
22
|
+
parseContractResponse(response: any): any;
|
|
23
|
+
isMsgContainsCorrectCode(message: any): boolean | null;
|
|
24
|
+
stringifyError(error: any): string;
|
|
25
|
+
}
|
|
26
|
+
import bignumber_1 = require("@ethersproject/bignumber");
|