@cetusprotocol/aggregator-sdk 0.4.4 → 0.6.0
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/README.md +24 -8
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +334 -216
- package/dist/index.mjs +333 -216
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -89,8 +89,8 @@ var require_bn = __commonJS({
|
|
|
89
89
|
ctor.prototype = new TempCtor();
|
|
90
90
|
ctor.prototype.constructor = ctor;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
if (
|
|
92
|
+
function BN8(number, base, endian) {
|
|
93
|
+
if (BN8.isBN(number)) {
|
|
94
94
|
return number;
|
|
95
95
|
}
|
|
96
96
|
this.negative = 0;
|
|
@@ -106,12 +106,12 @@ var require_bn = __commonJS({
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
if (typeof module2 === "object") {
|
|
109
|
-
module2.exports =
|
|
109
|
+
module2.exports = BN8;
|
|
110
110
|
} else {
|
|
111
|
-
exports2.BN =
|
|
111
|
+
exports2.BN = BN8;
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
BN8.BN = BN8;
|
|
114
|
+
BN8.wordSize = 26;
|
|
115
115
|
var Buffer2;
|
|
116
116
|
try {
|
|
117
117
|
if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
|
|
@@ -121,21 +121,21 @@ var require_bn = __commonJS({
|
|
|
121
121
|
}
|
|
122
122
|
} catch (e) {
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
if (num instanceof
|
|
124
|
+
BN8.isBN = function isBN(num) {
|
|
125
|
+
if (num instanceof BN8) {
|
|
126
126
|
return true;
|
|
127
127
|
}
|
|
128
|
-
return num !== null && typeof num === "object" && num.constructor.wordSize ===
|
|
128
|
+
return num !== null && typeof num === "object" && num.constructor.wordSize === BN8.wordSize && Array.isArray(num.words);
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
BN8.max = function max2(left, right) {
|
|
131
131
|
if (left.cmp(right) > 0) return left;
|
|
132
132
|
return right;
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
BN8.min = function min2(left, right) {
|
|
135
135
|
if (left.cmp(right) < 0) return left;
|
|
136
136
|
return right;
|
|
137
137
|
};
|
|
138
|
-
|
|
138
|
+
BN8.prototype._init = function init(number, base, endian) {
|
|
139
139
|
if (typeof number === "number") {
|
|
140
140
|
return this._initNumber(number, base, endian);
|
|
141
141
|
}
|
|
@@ -163,7 +163,7 @@ var require_bn = __commonJS({
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
BN8.prototype._initNumber = function _initNumber(number, base, endian) {
|
|
167
167
|
if (number < 0) {
|
|
168
168
|
this.negative = 1;
|
|
169
169
|
number = -number;
|
|
@@ -189,7 +189,7 @@ var require_bn = __commonJS({
|
|
|
189
189
|
if (endian !== "le") return;
|
|
190
190
|
this._initArray(this.toArray(), base, endian);
|
|
191
191
|
};
|
|
192
|
-
|
|
192
|
+
BN8.prototype._initArray = function _initArray(number, base, endian) {
|
|
193
193
|
assert(typeof number.length === "number");
|
|
194
194
|
if (number.length <= 0) {
|
|
195
195
|
this.words = [0];
|
|
@@ -247,7 +247,7 @@ var require_bn = __commonJS({
|
|
|
247
247
|
}
|
|
248
248
|
return r;
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
BN8.prototype._parseHex = function _parseHex(number, start, endian) {
|
|
251
251
|
this.length = Math.ceil((number.length - start) / 6);
|
|
252
252
|
this.words = new Array(this.length);
|
|
253
253
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -303,7 +303,7 @@ var require_bn = __commonJS({
|
|
|
303
303
|
}
|
|
304
304
|
return r;
|
|
305
305
|
}
|
|
306
|
-
|
|
306
|
+
BN8.prototype._parseBase = function _parseBase(number, base, start) {
|
|
307
307
|
this.words = [0];
|
|
308
308
|
this.length = 1;
|
|
309
309
|
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
|
|
@@ -339,7 +339,7 @@ var require_bn = __commonJS({
|
|
|
339
339
|
}
|
|
340
340
|
this._strip();
|
|
341
341
|
};
|
|
342
|
-
|
|
342
|
+
BN8.prototype.copy = function copy(dest) {
|
|
343
343
|
dest.words = new Array(this.length);
|
|
344
344
|
for (var i = 0; i < this.length; i++) {
|
|
345
345
|
dest.words[i] = this.words[i];
|
|
@@ -354,27 +354,27 @@ var require_bn = __commonJS({
|
|
|
354
354
|
dest.negative = src.negative;
|
|
355
355
|
dest.red = src.red;
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
BN8.prototype._move = function _move(dest) {
|
|
358
358
|
move(dest, this);
|
|
359
359
|
};
|
|
360
|
-
|
|
361
|
-
var r = new
|
|
360
|
+
BN8.prototype.clone = function clone2() {
|
|
361
|
+
var r = new BN8(null);
|
|
362
362
|
this.copy(r);
|
|
363
363
|
return r;
|
|
364
364
|
};
|
|
365
|
-
|
|
365
|
+
BN8.prototype._expand = function _expand(size) {
|
|
366
366
|
while (this.length < size) {
|
|
367
367
|
this.words[this.length++] = 0;
|
|
368
368
|
}
|
|
369
369
|
return this;
|
|
370
370
|
};
|
|
371
|
-
|
|
371
|
+
BN8.prototype._strip = function strip() {
|
|
372
372
|
while (this.length > 1 && this.words[this.length - 1] === 0) {
|
|
373
373
|
this.length--;
|
|
374
374
|
}
|
|
375
375
|
return this._normSign();
|
|
376
376
|
};
|
|
377
|
-
|
|
377
|
+
BN8.prototype._normSign = function _normSign() {
|
|
378
378
|
if (this.length === 1 && this.words[0] === 0) {
|
|
379
379
|
this.negative = 0;
|
|
380
380
|
}
|
|
@@ -382,12 +382,12 @@ var require_bn = __commonJS({
|
|
|
382
382
|
};
|
|
383
383
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
384
384
|
try {
|
|
385
|
-
|
|
385
|
+
BN8.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
386
386
|
} catch (e) {
|
|
387
|
-
|
|
387
|
+
BN8.prototype.inspect = inspect;
|
|
388
388
|
}
|
|
389
389
|
} else {
|
|
390
|
-
|
|
390
|
+
BN8.prototype.inspect = inspect;
|
|
391
391
|
}
|
|
392
392
|
function inspect() {
|
|
393
393
|
return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
|
|
@@ -498,7 +498,7 @@ var require_bn = __commonJS({
|
|
|
498
498
|
52521875,
|
|
499
499
|
60466176
|
|
500
500
|
];
|
|
501
|
-
|
|
501
|
+
BN8.prototype.toString = function toString(base, padding) {
|
|
502
502
|
base = base || 10;
|
|
503
503
|
padding = padding | 0 || 1;
|
|
504
504
|
var out;
|
|
@@ -560,7 +560,7 @@ var require_bn = __commonJS({
|
|
|
560
560
|
}
|
|
561
561
|
assert(false, "Base should be between 2 and 36");
|
|
562
562
|
};
|
|
563
|
-
|
|
563
|
+
BN8.prototype.toNumber = function toNumber() {
|
|
564
564
|
var ret = this.words[0];
|
|
565
565
|
if (this.length === 2) {
|
|
566
566
|
ret += this.words[1] * 67108864;
|
|
@@ -571,15 +571,15 @@ var require_bn = __commonJS({
|
|
|
571
571
|
}
|
|
572
572
|
return this.negative !== 0 ? -ret : ret;
|
|
573
573
|
};
|
|
574
|
-
|
|
574
|
+
BN8.prototype.toJSON = function toJSON() {
|
|
575
575
|
return this.toString(16, 2);
|
|
576
576
|
};
|
|
577
577
|
if (Buffer2) {
|
|
578
|
-
|
|
578
|
+
BN8.prototype.toBuffer = function toBuffer(endian, length) {
|
|
579
579
|
return this.toArrayLike(Buffer2, endian, length);
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
|
-
|
|
582
|
+
BN8.prototype.toArray = function toArray(endian, length) {
|
|
583
583
|
return this.toArrayLike(Array, endian, length);
|
|
584
584
|
};
|
|
585
585
|
var allocate = function allocate2(ArrayType, size) {
|
|
@@ -588,7 +588,7 @@ var require_bn = __commonJS({
|
|
|
588
588
|
}
|
|
589
589
|
return new ArrayType(size);
|
|
590
590
|
};
|
|
591
|
-
|
|
591
|
+
BN8.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
|
|
592
592
|
this._strip();
|
|
593
593
|
var byteLength = this.byteLength();
|
|
594
594
|
var reqLength = length || Math.max(1, byteLength);
|
|
@@ -599,7 +599,7 @@ var require_bn = __commonJS({
|
|
|
599
599
|
this["_toArrayLike" + postfix](res, byteLength);
|
|
600
600
|
return res;
|
|
601
601
|
};
|
|
602
|
-
|
|
602
|
+
BN8.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
|
|
603
603
|
var position = 0;
|
|
604
604
|
var carry = 0;
|
|
605
605
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -629,7 +629,7 @@ var require_bn = __commonJS({
|
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
};
|
|
632
|
-
|
|
632
|
+
BN8.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
|
|
633
633
|
var position = res.length - 1;
|
|
634
634
|
var carry = 0;
|
|
635
635
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -660,11 +660,11 @@ var require_bn = __commonJS({
|
|
|
660
660
|
}
|
|
661
661
|
};
|
|
662
662
|
if (Math.clz32) {
|
|
663
|
-
|
|
663
|
+
BN8.prototype._countBits = function _countBits(w) {
|
|
664
664
|
return 32 - Math.clz32(w);
|
|
665
665
|
};
|
|
666
666
|
} else {
|
|
667
|
-
|
|
667
|
+
BN8.prototype._countBits = function _countBits(w) {
|
|
668
668
|
var t = w;
|
|
669
669
|
var r = 0;
|
|
670
670
|
if (t >= 4096) {
|
|
@@ -686,7 +686,7 @@ var require_bn = __commonJS({
|
|
|
686
686
|
return r + t;
|
|
687
687
|
};
|
|
688
688
|
}
|
|
689
|
-
|
|
689
|
+
BN8.prototype._zeroBits = function _zeroBits(w) {
|
|
690
690
|
if (w === 0) return 26;
|
|
691
691
|
var t = w;
|
|
692
692
|
var r = 0;
|
|
@@ -711,7 +711,7 @@ var require_bn = __commonJS({
|
|
|
711
711
|
}
|
|
712
712
|
return r;
|
|
713
713
|
};
|
|
714
|
-
|
|
714
|
+
BN8.prototype.bitLength = function bitLength() {
|
|
715
715
|
var w = this.words[this.length - 1];
|
|
716
716
|
var hi = this._countBits(w);
|
|
717
717
|
return (this.length - 1) * 26 + hi;
|
|
@@ -725,7 +725,7 @@ var require_bn = __commonJS({
|
|
|
725
725
|
}
|
|
726
726
|
return w;
|
|
727
727
|
}
|
|
728
|
-
|
|
728
|
+
BN8.prototype.zeroBits = function zeroBits() {
|
|
729
729
|
if (this.isZero()) return 0;
|
|
730
730
|
var r = 0;
|
|
731
731
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -735,34 +735,34 @@ var require_bn = __commonJS({
|
|
|
735
735
|
}
|
|
736
736
|
return r;
|
|
737
737
|
};
|
|
738
|
-
|
|
738
|
+
BN8.prototype.byteLength = function byteLength() {
|
|
739
739
|
return Math.ceil(this.bitLength() / 8);
|
|
740
740
|
};
|
|
741
|
-
|
|
741
|
+
BN8.prototype.toTwos = function toTwos(width) {
|
|
742
742
|
if (this.negative !== 0) {
|
|
743
743
|
return this.abs().inotn(width).iaddn(1);
|
|
744
744
|
}
|
|
745
745
|
return this.clone();
|
|
746
746
|
};
|
|
747
|
-
|
|
747
|
+
BN8.prototype.fromTwos = function fromTwos(width) {
|
|
748
748
|
if (this.testn(width - 1)) {
|
|
749
749
|
return this.notn(width).iaddn(1).ineg();
|
|
750
750
|
}
|
|
751
751
|
return this.clone();
|
|
752
752
|
};
|
|
753
|
-
|
|
753
|
+
BN8.prototype.isNeg = function isNeg() {
|
|
754
754
|
return this.negative !== 0;
|
|
755
755
|
};
|
|
756
|
-
|
|
756
|
+
BN8.prototype.neg = function neg() {
|
|
757
757
|
return this.clone().ineg();
|
|
758
758
|
};
|
|
759
|
-
|
|
759
|
+
BN8.prototype.ineg = function ineg() {
|
|
760
760
|
if (!this.isZero()) {
|
|
761
761
|
this.negative ^= 1;
|
|
762
762
|
}
|
|
763
763
|
return this;
|
|
764
764
|
};
|
|
765
|
-
|
|
765
|
+
BN8.prototype.iuor = function iuor(num) {
|
|
766
766
|
while (this.length < num.length) {
|
|
767
767
|
this.words[this.length++] = 0;
|
|
768
768
|
}
|
|
@@ -771,19 +771,19 @@ var require_bn = __commonJS({
|
|
|
771
771
|
}
|
|
772
772
|
return this._strip();
|
|
773
773
|
};
|
|
774
|
-
|
|
774
|
+
BN8.prototype.ior = function ior(num) {
|
|
775
775
|
assert((this.negative | num.negative) === 0);
|
|
776
776
|
return this.iuor(num);
|
|
777
777
|
};
|
|
778
|
-
|
|
778
|
+
BN8.prototype.or = function or(num) {
|
|
779
779
|
if (this.length > num.length) return this.clone().ior(num);
|
|
780
780
|
return num.clone().ior(this);
|
|
781
781
|
};
|
|
782
|
-
|
|
782
|
+
BN8.prototype.uor = function uor(num) {
|
|
783
783
|
if (this.length > num.length) return this.clone().iuor(num);
|
|
784
784
|
return num.clone().iuor(this);
|
|
785
785
|
};
|
|
786
|
-
|
|
786
|
+
BN8.prototype.iuand = function iuand(num) {
|
|
787
787
|
var b;
|
|
788
788
|
if (this.length > num.length) {
|
|
789
789
|
b = num;
|
|
@@ -796,19 +796,19 @@ var require_bn = __commonJS({
|
|
|
796
796
|
this.length = b.length;
|
|
797
797
|
return this._strip();
|
|
798
798
|
};
|
|
799
|
-
|
|
799
|
+
BN8.prototype.iand = function iand(num) {
|
|
800
800
|
assert((this.negative | num.negative) === 0);
|
|
801
801
|
return this.iuand(num);
|
|
802
802
|
};
|
|
803
|
-
|
|
803
|
+
BN8.prototype.and = function and(num) {
|
|
804
804
|
if (this.length > num.length) return this.clone().iand(num);
|
|
805
805
|
return num.clone().iand(this);
|
|
806
806
|
};
|
|
807
|
-
|
|
807
|
+
BN8.prototype.uand = function uand(num) {
|
|
808
808
|
if (this.length > num.length) return this.clone().iuand(num);
|
|
809
809
|
return num.clone().iuand(this);
|
|
810
810
|
};
|
|
811
|
-
|
|
811
|
+
BN8.prototype.iuxor = function iuxor(num) {
|
|
812
812
|
var a;
|
|
813
813
|
var b;
|
|
814
814
|
if (this.length > num.length) {
|
|
@@ -829,19 +829,19 @@ var require_bn = __commonJS({
|
|
|
829
829
|
this.length = a.length;
|
|
830
830
|
return this._strip();
|
|
831
831
|
};
|
|
832
|
-
|
|
832
|
+
BN8.prototype.ixor = function ixor(num) {
|
|
833
833
|
assert((this.negative | num.negative) === 0);
|
|
834
834
|
return this.iuxor(num);
|
|
835
835
|
};
|
|
836
|
-
|
|
836
|
+
BN8.prototype.xor = function xor(num) {
|
|
837
837
|
if (this.length > num.length) return this.clone().ixor(num);
|
|
838
838
|
return num.clone().ixor(this);
|
|
839
839
|
};
|
|
840
|
-
|
|
840
|
+
BN8.prototype.uxor = function uxor(num) {
|
|
841
841
|
if (this.length > num.length) return this.clone().iuxor(num);
|
|
842
842
|
return num.clone().iuxor(this);
|
|
843
843
|
};
|
|
844
|
-
|
|
844
|
+
BN8.prototype.inotn = function inotn(width) {
|
|
845
845
|
assert(typeof width === "number" && width >= 0);
|
|
846
846
|
var bytesNeeded = Math.ceil(width / 26) | 0;
|
|
847
847
|
var bitsLeft = width % 26;
|
|
@@ -857,10 +857,10 @@ var require_bn = __commonJS({
|
|
|
857
857
|
}
|
|
858
858
|
return this._strip();
|
|
859
859
|
};
|
|
860
|
-
|
|
860
|
+
BN8.prototype.notn = function notn(width) {
|
|
861
861
|
return this.clone().inotn(width);
|
|
862
862
|
};
|
|
863
|
-
|
|
863
|
+
BN8.prototype.setn = function setn(bit, val) {
|
|
864
864
|
assert(typeof bit === "number" && bit >= 0);
|
|
865
865
|
var off = bit / 26 | 0;
|
|
866
866
|
var wbit = bit % 26;
|
|
@@ -872,7 +872,7 @@ var require_bn = __commonJS({
|
|
|
872
872
|
}
|
|
873
873
|
return this._strip();
|
|
874
874
|
};
|
|
875
|
-
|
|
875
|
+
BN8.prototype.iadd = function iadd(num) {
|
|
876
876
|
var r;
|
|
877
877
|
if (this.negative !== 0 && num.negative === 0) {
|
|
878
878
|
this.negative = 0;
|
|
@@ -915,7 +915,7 @@ var require_bn = __commonJS({
|
|
|
915
915
|
}
|
|
916
916
|
return this;
|
|
917
917
|
};
|
|
918
|
-
|
|
918
|
+
BN8.prototype.add = function add2(num) {
|
|
919
919
|
var res;
|
|
920
920
|
if (num.negative !== 0 && this.negative === 0) {
|
|
921
921
|
num.negative = 0;
|
|
@@ -931,7 +931,7 @@ var require_bn = __commonJS({
|
|
|
931
931
|
if (this.length > num.length) return this.clone().iadd(num);
|
|
932
932
|
return num.clone().iadd(this);
|
|
933
933
|
};
|
|
934
|
-
|
|
934
|
+
BN8.prototype.isub = function isub(num) {
|
|
935
935
|
if (num.negative !== 0) {
|
|
936
936
|
num.negative = 0;
|
|
937
937
|
var r = this.iadd(num);
|
|
@@ -980,7 +980,7 @@ var require_bn = __commonJS({
|
|
|
980
980
|
}
|
|
981
981
|
return this._strip();
|
|
982
982
|
};
|
|
983
|
-
|
|
983
|
+
BN8.prototype.sub = function sub2(num) {
|
|
984
984
|
return this.clone().isub(num);
|
|
985
985
|
};
|
|
986
986
|
function smallMulTo(self, num, out) {
|
|
@@ -1608,7 +1608,7 @@ var require_bn = __commonJS({
|
|
|
1608
1608
|
function jumboMulTo(self, num, out) {
|
|
1609
1609
|
return bigMulTo(self, num, out);
|
|
1610
1610
|
}
|
|
1611
|
-
|
|
1611
|
+
BN8.prototype.mulTo = function mulTo(num, out) {
|
|
1612
1612
|
var res;
|
|
1613
1613
|
var len = this.length + num.length;
|
|
1614
1614
|
if (this.length === 10 && num.length === 10) {
|
|
@@ -1622,20 +1622,20 @@ var require_bn = __commonJS({
|
|
|
1622
1622
|
}
|
|
1623
1623
|
return res;
|
|
1624
1624
|
};
|
|
1625
|
-
|
|
1626
|
-
var out = new
|
|
1625
|
+
BN8.prototype.mul = function mul2(num) {
|
|
1626
|
+
var out = new BN8(null);
|
|
1627
1627
|
out.words = new Array(this.length + num.length);
|
|
1628
1628
|
return this.mulTo(num, out);
|
|
1629
1629
|
};
|
|
1630
|
-
|
|
1631
|
-
var out = new
|
|
1630
|
+
BN8.prototype.mulf = function mulf(num) {
|
|
1631
|
+
var out = new BN8(null);
|
|
1632
1632
|
out.words = new Array(this.length + num.length);
|
|
1633
1633
|
return jumboMulTo(this, num, out);
|
|
1634
1634
|
};
|
|
1635
|
-
|
|
1635
|
+
BN8.prototype.imul = function imul(num) {
|
|
1636
1636
|
return this.clone().mulTo(num, this);
|
|
1637
1637
|
};
|
|
1638
|
-
|
|
1638
|
+
BN8.prototype.imuln = function imuln(num) {
|
|
1639
1639
|
var isNegNum = num < 0;
|
|
1640
1640
|
if (isNegNum) num = -num;
|
|
1641
1641
|
assert(typeof num === "number");
|
|
@@ -1655,18 +1655,18 @@ var require_bn = __commonJS({
|
|
|
1655
1655
|
}
|
|
1656
1656
|
return isNegNum ? this.ineg() : this;
|
|
1657
1657
|
};
|
|
1658
|
-
|
|
1658
|
+
BN8.prototype.muln = function muln(num) {
|
|
1659
1659
|
return this.clone().imuln(num);
|
|
1660
1660
|
};
|
|
1661
|
-
|
|
1661
|
+
BN8.prototype.sqr = function sqr() {
|
|
1662
1662
|
return this.mul(this);
|
|
1663
1663
|
};
|
|
1664
|
-
|
|
1664
|
+
BN8.prototype.isqr = function isqr() {
|
|
1665
1665
|
return this.imul(this.clone());
|
|
1666
1666
|
};
|
|
1667
|
-
|
|
1667
|
+
BN8.prototype.pow = function pow2(num) {
|
|
1668
1668
|
var w = toBitArray(num);
|
|
1669
|
-
if (w.length === 0) return new
|
|
1669
|
+
if (w.length === 0) return new BN8(1);
|
|
1670
1670
|
var res = this;
|
|
1671
1671
|
for (var i = 0; i < w.length; i++, res = res.sqr()) {
|
|
1672
1672
|
if (w[i] !== 0) break;
|
|
@@ -1679,7 +1679,7 @@ var require_bn = __commonJS({
|
|
|
1679
1679
|
}
|
|
1680
1680
|
return res;
|
|
1681
1681
|
};
|
|
1682
|
-
|
|
1682
|
+
BN8.prototype.iushln = function iushln(bits) {
|
|
1683
1683
|
assert(typeof bits === "number" && bits >= 0);
|
|
1684
1684
|
var r = bits % 26;
|
|
1685
1685
|
var s = (bits - r) / 26;
|
|
@@ -1709,11 +1709,11 @@ var require_bn = __commonJS({
|
|
|
1709
1709
|
}
|
|
1710
1710
|
return this._strip();
|
|
1711
1711
|
};
|
|
1712
|
-
|
|
1712
|
+
BN8.prototype.ishln = function ishln(bits) {
|
|
1713
1713
|
assert(this.negative === 0);
|
|
1714
1714
|
return this.iushln(bits);
|
|
1715
1715
|
};
|
|
1716
|
-
|
|
1716
|
+
BN8.prototype.iushrn = function iushrn(bits, hint, extended) {
|
|
1717
1717
|
assert(typeof bits === "number" && bits >= 0);
|
|
1718
1718
|
var h;
|
|
1719
1719
|
if (hint) {
|
|
@@ -1757,23 +1757,23 @@ var require_bn = __commonJS({
|
|
|
1757
1757
|
}
|
|
1758
1758
|
return this._strip();
|
|
1759
1759
|
};
|
|
1760
|
-
|
|
1760
|
+
BN8.prototype.ishrn = function ishrn(bits, hint, extended) {
|
|
1761
1761
|
assert(this.negative === 0);
|
|
1762
1762
|
return this.iushrn(bits, hint, extended);
|
|
1763
1763
|
};
|
|
1764
|
-
|
|
1764
|
+
BN8.prototype.shln = function shln(bits) {
|
|
1765
1765
|
return this.clone().ishln(bits);
|
|
1766
1766
|
};
|
|
1767
|
-
|
|
1767
|
+
BN8.prototype.ushln = function ushln(bits) {
|
|
1768
1768
|
return this.clone().iushln(bits);
|
|
1769
1769
|
};
|
|
1770
|
-
|
|
1770
|
+
BN8.prototype.shrn = function shrn(bits) {
|
|
1771
1771
|
return this.clone().ishrn(bits);
|
|
1772
1772
|
};
|
|
1773
|
-
|
|
1773
|
+
BN8.prototype.ushrn = function ushrn(bits) {
|
|
1774
1774
|
return this.clone().iushrn(bits);
|
|
1775
1775
|
};
|
|
1776
|
-
|
|
1776
|
+
BN8.prototype.testn = function testn(bit) {
|
|
1777
1777
|
assert(typeof bit === "number" && bit >= 0);
|
|
1778
1778
|
var r = bit % 26;
|
|
1779
1779
|
var s = (bit - r) / 26;
|
|
@@ -1782,7 +1782,7 @@ var require_bn = __commonJS({
|
|
|
1782
1782
|
var w = this.words[s];
|
|
1783
1783
|
return !!(w & q);
|
|
1784
1784
|
};
|
|
1785
|
-
|
|
1785
|
+
BN8.prototype.imaskn = function imaskn(bits) {
|
|
1786
1786
|
assert(typeof bits === "number" && bits >= 0);
|
|
1787
1787
|
var r = bits % 26;
|
|
1788
1788
|
var s = (bits - r) / 26;
|
|
@@ -1800,10 +1800,10 @@ var require_bn = __commonJS({
|
|
|
1800
1800
|
}
|
|
1801
1801
|
return this._strip();
|
|
1802
1802
|
};
|
|
1803
|
-
|
|
1803
|
+
BN8.prototype.maskn = function maskn(bits) {
|
|
1804
1804
|
return this.clone().imaskn(bits);
|
|
1805
1805
|
};
|
|
1806
|
-
|
|
1806
|
+
BN8.prototype.iaddn = function iaddn(num) {
|
|
1807
1807
|
assert(typeof num === "number");
|
|
1808
1808
|
assert(num < 67108864);
|
|
1809
1809
|
if (num < 0) return this.isubn(-num);
|
|
@@ -1820,7 +1820,7 @@ var require_bn = __commonJS({
|
|
|
1820
1820
|
}
|
|
1821
1821
|
return this._iaddn(num);
|
|
1822
1822
|
};
|
|
1823
|
-
|
|
1823
|
+
BN8.prototype._iaddn = function _iaddn(num) {
|
|
1824
1824
|
this.words[0] += num;
|
|
1825
1825
|
for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
|
|
1826
1826
|
this.words[i] -= 67108864;
|
|
@@ -1833,7 +1833,7 @@ var require_bn = __commonJS({
|
|
|
1833
1833
|
this.length = Math.max(this.length, i + 1);
|
|
1834
1834
|
return this;
|
|
1835
1835
|
};
|
|
1836
|
-
|
|
1836
|
+
BN8.prototype.isubn = function isubn(num) {
|
|
1837
1837
|
assert(typeof num === "number");
|
|
1838
1838
|
assert(num < 67108864);
|
|
1839
1839
|
if (num < 0) return this.iaddn(-num);
|
|
@@ -1855,20 +1855,20 @@ var require_bn = __commonJS({
|
|
|
1855
1855
|
}
|
|
1856
1856
|
return this._strip();
|
|
1857
1857
|
};
|
|
1858
|
-
|
|
1858
|
+
BN8.prototype.addn = function addn(num) {
|
|
1859
1859
|
return this.clone().iaddn(num);
|
|
1860
1860
|
};
|
|
1861
|
-
|
|
1861
|
+
BN8.prototype.subn = function subn(num) {
|
|
1862
1862
|
return this.clone().isubn(num);
|
|
1863
1863
|
};
|
|
1864
|
-
|
|
1864
|
+
BN8.prototype.iabs = function iabs() {
|
|
1865
1865
|
this.negative = 0;
|
|
1866
1866
|
return this;
|
|
1867
1867
|
};
|
|
1868
|
-
|
|
1868
|
+
BN8.prototype.abs = function abs2() {
|
|
1869
1869
|
return this.clone().iabs();
|
|
1870
1870
|
};
|
|
1871
|
-
|
|
1871
|
+
BN8.prototype._ishlnsubmul = function _ishlnsubmul(num, mul2, shift) {
|
|
1872
1872
|
var len = num.length + shift;
|
|
1873
1873
|
var i;
|
|
1874
1874
|
this._expand(len);
|
|
@@ -1897,7 +1897,7 @@ var require_bn = __commonJS({
|
|
|
1897
1897
|
this.negative = 1;
|
|
1898
1898
|
return this._strip();
|
|
1899
1899
|
};
|
|
1900
|
-
|
|
1900
|
+
BN8.prototype._wordDiv = function _wordDiv(num, mode) {
|
|
1901
1901
|
var shift = this.length - num.length;
|
|
1902
1902
|
var a = this.clone();
|
|
1903
1903
|
var b = num;
|
|
@@ -1912,7 +1912,7 @@ var require_bn = __commonJS({
|
|
|
1912
1912
|
var m = a.length - b.length;
|
|
1913
1913
|
var q;
|
|
1914
1914
|
if (mode !== "mod") {
|
|
1915
|
-
q = new
|
|
1915
|
+
q = new BN8(null);
|
|
1916
1916
|
q.length = m + 1;
|
|
1917
1917
|
q.words = new Array(q.length);
|
|
1918
1918
|
for (var i = 0; i < q.length; i++) {
|
|
@@ -1954,12 +1954,12 @@ var require_bn = __commonJS({
|
|
|
1954
1954
|
mod: a
|
|
1955
1955
|
};
|
|
1956
1956
|
};
|
|
1957
|
-
|
|
1957
|
+
BN8.prototype.divmod = function divmod(num, mode, positive) {
|
|
1958
1958
|
assert(!num.isZero());
|
|
1959
1959
|
if (this.isZero()) {
|
|
1960
1960
|
return {
|
|
1961
|
-
div: new
|
|
1962
|
-
mod: new
|
|
1961
|
+
div: new BN8(0),
|
|
1962
|
+
mod: new BN8(0)
|
|
1963
1963
|
};
|
|
1964
1964
|
}
|
|
1965
1965
|
var div2, mod2, res;
|
|
@@ -2004,7 +2004,7 @@ var require_bn = __commonJS({
|
|
|
2004
2004
|
}
|
|
2005
2005
|
if (num.length > this.length || this.cmp(num) < 0) {
|
|
2006
2006
|
return {
|
|
2007
|
-
div: new
|
|
2007
|
+
div: new BN8(0),
|
|
2008
2008
|
mod: this
|
|
2009
2009
|
};
|
|
2010
2010
|
}
|
|
@@ -2018,26 +2018,26 @@ var require_bn = __commonJS({
|
|
|
2018
2018
|
if (mode === "mod") {
|
|
2019
2019
|
return {
|
|
2020
2020
|
div: null,
|
|
2021
|
-
mod: new
|
|
2021
|
+
mod: new BN8(this.modrn(num.words[0]))
|
|
2022
2022
|
};
|
|
2023
2023
|
}
|
|
2024
2024
|
return {
|
|
2025
2025
|
div: this.divn(num.words[0]),
|
|
2026
|
-
mod: new
|
|
2026
|
+
mod: new BN8(this.modrn(num.words[0]))
|
|
2027
2027
|
};
|
|
2028
2028
|
}
|
|
2029
2029
|
return this._wordDiv(num, mode);
|
|
2030
2030
|
};
|
|
2031
|
-
|
|
2031
|
+
BN8.prototype.div = function div2(num) {
|
|
2032
2032
|
return this.divmod(num, "div", false).div;
|
|
2033
2033
|
};
|
|
2034
|
-
|
|
2034
|
+
BN8.prototype.mod = function mod2(num) {
|
|
2035
2035
|
return this.divmod(num, "mod", false).mod;
|
|
2036
2036
|
};
|
|
2037
|
-
|
|
2037
|
+
BN8.prototype.umod = function umod(num) {
|
|
2038
2038
|
return this.divmod(num, "mod", true).mod;
|
|
2039
2039
|
};
|
|
2040
|
-
|
|
2040
|
+
BN8.prototype.divRound = function divRound(num) {
|
|
2041
2041
|
var dm = this.divmod(num);
|
|
2042
2042
|
if (dm.mod.isZero()) return dm.div;
|
|
2043
2043
|
var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
|
|
@@ -2047,7 +2047,7 @@ var require_bn = __commonJS({
|
|
|
2047
2047
|
if (cmp2 < 0 || r2 === 1 && cmp2 === 0) return dm.div;
|
|
2048
2048
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
|
2049
2049
|
};
|
|
2050
|
-
|
|
2050
|
+
BN8.prototype.modrn = function modrn(num) {
|
|
2051
2051
|
var isNegNum = num < 0;
|
|
2052
2052
|
if (isNegNum) num = -num;
|
|
2053
2053
|
assert(num <= 67108863);
|
|
@@ -2058,10 +2058,10 @@ var require_bn = __commonJS({
|
|
|
2058
2058
|
}
|
|
2059
2059
|
return isNegNum ? -acc : acc;
|
|
2060
2060
|
};
|
|
2061
|
-
|
|
2061
|
+
BN8.prototype.modn = function modn(num) {
|
|
2062
2062
|
return this.modrn(num);
|
|
2063
2063
|
};
|
|
2064
|
-
|
|
2064
|
+
BN8.prototype.idivn = function idivn(num) {
|
|
2065
2065
|
var isNegNum = num < 0;
|
|
2066
2066
|
if (isNegNum) num = -num;
|
|
2067
2067
|
assert(num <= 67108863);
|
|
@@ -2074,10 +2074,10 @@ var require_bn = __commonJS({
|
|
|
2074
2074
|
this._strip();
|
|
2075
2075
|
return isNegNum ? this.ineg() : this;
|
|
2076
2076
|
};
|
|
2077
|
-
|
|
2077
|
+
BN8.prototype.divn = function divn(num) {
|
|
2078
2078
|
return this.clone().idivn(num);
|
|
2079
2079
|
};
|
|
2080
|
-
|
|
2080
|
+
BN8.prototype.egcd = function egcd(p) {
|
|
2081
2081
|
assert(p.negative === 0);
|
|
2082
2082
|
assert(!p.isZero());
|
|
2083
2083
|
var x = this;
|
|
@@ -2087,10 +2087,10 @@ var require_bn = __commonJS({
|
|
|
2087
2087
|
} else {
|
|
2088
2088
|
x = x.clone();
|
|
2089
2089
|
}
|
|
2090
|
-
var A = new
|
|
2091
|
-
var B = new
|
|
2092
|
-
var C = new
|
|
2093
|
-
var D = new
|
|
2090
|
+
var A = new BN8(1);
|
|
2091
|
+
var B = new BN8(0);
|
|
2092
|
+
var C = new BN8(0);
|
|
2093
|
+
var D = new BN8(1);
|
|
2094
2094
|
var g = 0;
|
|
2095
2095
|
while (x.isEven() && y.isEven()) {
|
|
2096
2096
|
x.iushrn(1);
|
|
@@ -2140,7 +2140,7 @@ var require_bn = __commonJS({
|
|
|
2140
2140
|
gcd: y.iushln(g)
|
|
2141
2141
|
};
|
|
2142
2142
|
};
|
|
2143
|
-
|
|
2143
|
+
BN8.prototype._invmp = function _invmp(p) {
|
|
2144
2144
|
assert(p.negative === 0);
|
|
2145
2145
|
assert(!p.isZero());
|
|
2146
2146
|
var a = this;
|
|
@@ -2150,8 +2150,8 @@ var require_bn = __commonJS({
|
|
|
2150
2150
|
} else {
|
|
2151
2151
|
a = a.clone();
|
|
2152
2152
|
}
|
|
2153
|
-
var x1 = new
|
|
2154
|
-
var x2 = new
|
|
2153
|
+
var x1 = new BN8(1);
|
|
2154
|
+
var x2 = new BN8(0);
|
|
2155
2155
|
var delta = b.clone();
|
|
2156
2156
|
while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
|
|
2157
2157
|
for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
|
|
@@ -2193,7 +2193,7 @@ var require_bn = __commonJS({
|
|
|
2193
2193
|
}
|
|
2194
2194
|
return res;
|
|
2195
2195
|
};
|
|
2196
|
-
|
|
2196
|
+
BN8.prototype.gcd = function gcd(num) {
|
|
2197
2197
|
if (this.isZero()) return num.abs();
|
|
2198
2198
|
if (num.isZero()) return this.abs();
|
|
2199
2199
|
var a = this.clone();
|
|
@@ -2223,19 +2223,19 @@ var require_bn = __commonJS({
|
|
|
2223
2223
|
} while (true);
|
|
2224
2224
|
return b.iushln(shift);
|
|
2225
2225
|
};
|
|
2226
|
-
|
|
2226
|
+
BN8.prototype.invm = function invm(num) {
|
|
2227
2227
|
return this.egcd(num).a.umod(num);
|
|
2228
2228
|
};
|
|
2229
|
-
|
|
2229
|
+
BN8.prototype.isEven = function isEven() {
|
|
2230
2230
|
return (this.words[0] & 1) === 0;
|
|
2231
2231
|
};
|
|
2232
|
-
|
|
2232
|
+
BN8.prototype.isOdd = function isOdd2() {
|
|
2233
2233
|
return (this.words[0] & 1) === 1;
|
|
2234
2234
|
};
|
|
2235
|
-
|
|
2235
|
+
BN8.prototype.andln = function andln(num) {
|
|
2236
2236
|
return this.words[0] & num;
|
|
2237
2237
|
};
|
|
2238
|
-
|
|
2238
|
+
BN8.prototype.bincn = function bincn(bit) {
|
|
2239
2239
|
assert(typeof bit === "number");
|
|
2240
2240
|
var r = bit % 26;
|
|
2241
2241
|
var s = (bit - r) / 26;
|
|
@@ -2259,10 +2259,10 @@ var require_bn = __commonJS({
|
|
|
2259
2259
|
}
|
|
2260
2260
|
return this;
|
|
2261
2261
|
};
|
|
2262
|
-
|
|
2262
|
+
BN8.prototype.isZero = function isZero() {
|
|
2263
2263
|
return this.length === 1 && this.words[0] === 0;
|
|
2264
2264
|
};
|
|
2265
|
-
|
|
2265
|
+
BN8.prototype.cmpn = function cmpn(num) {
|
|
2266
2266
|
var negative = num < 0;
|
|
2267
2267
|
if (this.negative !== 0 && !negative) return -1;
|
|
2268
2268
|
if (this.negative === 0 && negative) return 1;
|
|
@@ -2281,14 +2281,14 @@ var require_bn = __commonJS({
|
|
|
2281
2281
|
if (this.negative !== 0) return -res | 0;
|
|
2282
2282
|
return res;
|
|
2283
2283
|
};
|
|
2284
|
-
|
|
2284
|
+
BN8.prototype.cmp = function cmp2(num) {
|
|
2285
2285
|
if (this.negative !== 0 && num.negative === 0) return -1;
|
|
2286
2286
|
if (this.negative === 0 && num.negative !== 0) return 1;
|
|
2287
2287
|
var res = this.ucmp(num);
|
|
2288
2288
|
if (this.negative !== 0) return -res | 0;
|
|
2289
2289
|
return res;
|
|
2290
2290
|
};
|
|
2291
|
-
|
|
2291
|
+
BN8.prototype.ucmp = function ucmp(num) {
|
|
2292
2292
|
if (this.length > num.length) return 1;
|
|
2293
2293
|
if (this.length < num.length) return -1;
|
|
2294
2294
|
var res = 0;
|
|
@@ -2305,112 +2305,112 @@ var require_bn = __commonJS({
|
|
|
2305
2305
|
}
|
|
2306
2306
|
return res;
|
|
2307
2307
|
};
|
|
2308
|
-
|
|
2308
|
+
BN8.prototype.gtn = function gtn(num) {
|
|
2309
2309
|
return this.cmpn(num) === 1;
|
|
2310
2310
|
};
|
|
2311
|
-
|
|
2311
|
+
BN8.prototype.gt = function gt(num) {
|
|
2312
2312
|
return this.cmp(num) === 1;
|
|
2313
2313
|
};
|
|
2314
|
-
|
|
2314
|
+
BN8.prototype.gten = function gten(num) {
|
|
2315
2315
|
return this.cmpn(num) >= 0;
|
|
2316
2316
|
};
|
|
2317
|
-
|
|
2317
|
+
BN8.prototype.gte = function gte(num) {
|
|
2318
2318
|
return this.cmp(num) >= 0;
|
|
2319
2319
|
};
|
|
2320
|
-
|
|
2320
|
+
BN8.prototype.ltn = function ltn(num) {
|
|
2321
2321
|
return this.cmpn(num) === -1;
|
|
2322
2322
|
};
|
|
2323
|
-
|
|
2323
|
+
BN8.prototype.lt = function lt(num) {
|
|
2324
2324
|
return this.cmp(num) === -1;
|
|
2325
2325
|
};
|
|
2326
|
-
|
|
2326
|
+
BN8.prototype.lten = function lten(num) {
|
|
2327
2327
|
return this.cmpn(num) <= 0;
|
|
2328
2328
|
};
|
|
2329
|
-
|
|
2329
|
+
BN8.prototype.lte = function lte(num) {
|
|
2330
2330
|
return this.cmp(num) <= 0;
|
|
2331
2331
|
};
|
|
2332
|
-
|
|
2332
|
+
BN8.prototype.eqn = function eqn(num) {
|
|
2333
2333
|
return this.cmpn(num) === 0;
|
|
2334
2334
|
};
|
|
2335
|
-
|
|
2335
|
+
BN8.prototype.eq = function eq(num) {
|
|
2336
2336
|
return this.cmp(num) === 0;
|
|
2337
2337
|
};
|
|
2338
|
-
|
|
2338
|
+
BN8.red = function red(num) {
|
|
2339
2339
|
return new Red(num);
|
|
2340
2340
|
};
|
|
2341
|
-
|
|
2341
|
+
BN8.prototype.toRed = function toRed(ctx) {
|
|
2342
2342
|
assert(!this.red, "Already a number in reduction context");
|
|
2343
2343
|
assert(this.negative === 0, "red works only with positives");
|
|
2344
2344
|
return ctx.convertTo(this)._forceRed(ctx);
|
|
2345
2345
|
};
|
|
2346
|
-
|
|
2346
|
+
BN8.prototype.fromRed = function fromRed() {
|
|
2347
2347
|
assert(this.red, "fromRed works only with numbers in reduction context");
|
|
2348
2348
|
return this.red.convertFrom(this);
|
|
2349
2349
|
};
|
|
2350
|
-
|
|
2350
|
+
BN8.prototype._forceRed = function _forceRed(ctx) {
|
|
2351
2351
|
this.red = ctx;
|
|
2352
2352
|
return this;
|
|
2353
2353
|
};
|
|
2354
|
-
|
|
2354
|
+
BN8.prototype.forceRed = function forceRed(ctx) {
|
|
2355
2355
|
assert(!this.red, "Already a number in reduction context");
|
|
2356
2356
|
return this._forceRed(ctx);
|
|
2357
2357
|
};
|
|
2358
|
-
|
|
2358
|
+
BN8.prototype.redAdd = function redAdd(num) {
|
|
2359
2359
|
assert(this.red, "redAdd works only with red numbers");
|
|
2360
2360
|
return this.red.add(this, num);
|
|
2361
2361
|
};
|
|
2362
|
-
|
|
2362
|
+
BN8.prototype.redIAdd = function redIAdd(num) {
|
|
2363
2363
|
assert(this.red, "redIAdd works only with red numbers");
|
|
2364
2364
|
return this.red.iadd(this, num);
|
|
2365
2365
|
};
|
|
2366
|
-
|
|
2366
|
+
BN8.prototype.redSub = function redSub(num) {
|
|
2367
2367
|
assert(this.red, "redSub works only with red numbers");
|
|
2368
2368
|
return this.red.sub(this, num);
|
|
2369
2369
|
};
|
|
2370
|
-
|
|
2370
|
+
BN8.prototype.redISub = function redISub(num) {
|
|
2371
2371
|
assert(this.red, "redISub works only with red numbers");
|
|
2372
2372
|
return this.red.isub(this, num);
|
|
2373
2373
|
};
|
|
2374
|
-
|
|
2374
|
+
BN8.prototype.redShl = function redShl(num) {
|
|
2375
2375
|
assert(this.red, "redShl works only with red numbers");
|
|
2376
2376
|
return this.red.shl(this, num);
|
|
2377
2377
|
};
|
|
2378
|
-
|
|
2378
|
+
BN8.prototype.redMul = function redMul(num) {
|
|
2379
2379
|
assert(this.red, "redMul works only with red numbers");
|
|
2380
2380
|
this.red._verify2(this, num);
|
|
2381
2381
|
return this.red.mul(this, num);
|
|
2382
2382
|
};
|
|
2383
|
-
|
|
2383
|
+
BN8.prototype.redIMul = function redIMul(num) {
|
|
2384
2384
|
assert(this.red, "redMul works only with red numbers");
|
|
2385
2385
|
this.red._verify2(this, num);
|
|
2386
2386
|
return this.red.imul(this, num);
|
|
2387
2387
|
};
|
|
2388
|
-
|
|
2388
|
+
BN8.prototype.redSqr = function redSqr() {
|
|
2389
2389
|
assert(this.red, "redSqr works only with red numbers");
|
|
2390
2390
|
this.red._verify1(this);
|
|
2391
2391
|
return this.red.sqr(this);
|
|
2392
2392
|
};
|
|
2393
|
-
|
|
2393
|
+
BN8.prototype.redISqr = function redISqr() {
|
|
2394
2394
|
assert(this.red, "redISqr works only with red numbers");
|
|
2395
2395
|
this.red._verify1(this);
|
|
2396
2396
|
return this.red.isqr(this);
|
|
2397
2397
|
};
|
|
2398
|
-
|
|
2398
|
+
BN8.prototype.redSqrt = function redSqrt() {
|
|
2399
2399
|
assert(this.red, "redSqrt works only with red numbers");
|
|
2400
2400
|
this.red._verify1(this);
|
|
2401
2401
|
return this.red.sqrt(this);
|
|
2402
2402
|
};
|
|
2403
|
-
|
|
2403
|
+
BN8.prototype.redInvm = function redInvm() {
|
|
2404
2404
|
assert(this.red, "redInvm works only with red numbers");
|
|
2405
2405
|
this.red._verify1(this);
|
|
2406
2406
|
return this.red.invm(this);
|
|
2407
2407
|
};
|
|
2408
|
-
|
|
2408
|
+
BN8.prototype.redNeg = function redNeg() {
|
|
2409
2409
|
assert(this.red, "redNeg works only with red numbers");
|
|
2410
2410
|
this.red._verify1(this);
|
|
2411
2411
|
return this.red.neg(this);
|
|
2412
2412
|
};
|
|
2413
|
-
|
|
2413
|
+
BN8.prototype.redPow = function redPow(num) {
|
|
2414
2414
|
assert(this.red && !num.red, "redPow(normalNum)");
|
|
2415
2415
|
this.red._verify1(this);
|
|
2416
2416
|
return this.red.pow(this, num);
|
|
@@ -2423,13 +2423,13 @@ var require_bn = __commonJS({
|
|
|
2423
2423
|
};
|
|
2424
2424
|
function MPrime(name, p) {
|
|
2425
2425
|
this.name = name;
|
|
2426
|
-
this.p = new
|
|
2426
|
+
this.p = new BN8(p, 16);
|
|
2427
2427
|
this.n = this.p.bitLength();
|
|
2428
|
-
this.k = new
|
|
2428
|
+
this.k = new BN8(1).iushln(this.n).isub(this.p);
|
|
2429
2429
|
this.tmp = this._tmp();
|
|
2430
2430
|
}
|
|
2431
2431
|
MPrime.prototype._tmp = function _tmp() {
|
|
2432
|
-
var tmp = new
|
|
2432
|
+
var tmp = new BN8(null);
|
|
2433
2433
|
tmp.words = new Array(Math.ceil(this.n / 13));
|
|
2434
2434
|
return tmp;
|
|
2435
2435
|
};
|
|
@@ -2555,7 +2555,7 @@ var require_bn = __commonJS({
|
|
|
2555
2555
|
}
|
|
2556
2556
|
return num;
|
|
2557
2557
|
};
|
|
2558
|
-
|
|
2558
|
+
BN8._prime = function prime(name) {
|
|
2559
2559
|
if (primes[name]) return primes[name];
|
|
2560
2560
|
var prime2;
|
|
2561
2561
|
if (name === "k256") {
|
|
@@ -2574,7 +2574,7 @@ var require_bn = __commonJS({
|
|
|
2574
2574
|
};
|
|
2575
2575
|
function Red(m) {
|
|
2576
2576
|
if (typeof m === "string") {
|
|
2577
|
-
var prime =
|
|
2577
|
+
var prime = BN8._prime(m);
|
|
2578
2578
|
this.m = prime.p;
|
|
2579
2579
|
this.prime = prime;
|
|
2580
2580
|
} else {
|
|
@@ -2660,7 +2660,7 @@ var require_bn = __commonJS({
|
|
|
2660
2660
|
var mod3 = this.m.andln(3);
|
|
2661
2661
|
assert(mod3 % 2 === 1);
|
|
2662
2662
|
if (mod3 === 3) {
|
|
2663
|
-
var pow2 = this.m.add(new
|
|
2663
|
+
var pow2 = this.m.add(new BN8(1)).iushrn(2);
|
|
2664
2664
|
return this.pow(a, pow2);
|
|
2665
2665
|
}
|
|
2666
2666
|
var q = this.m.subn(1);
|
|
@@ -2670,11 +2670,11 @@ var require_bn = __commonJS({
|
|
|
2670
2670
|
q.iushrn(1);
|
|
2671
2671
|
}
|
|
2672
2672
|
assert(!q.isZero());
|
|
2673
|
-
var one = new
|
|
2673
|
+
var one = new BN8(1).toRed(this);
|
|
2674
2674
|
var nOne = one.redNeg();
|
|
2675
2675
|
var lpow = this.m.subn(1).iushrn(1);
|
|
2676
2676
|
var z = this.m.bitLength();
|
|
2677
|
-
z = new
|
|
2677
|
+
z = new BN8(2 * z * z).toRed(this);
|
|
2678
2678
|
while (this.pow(z, lpow).cmp(nOne) !== 0) {
|
|
2679
2679
|
z.redIAdd(nOne);
|
|
2680
2680
|
}
|
|
@@ -2688,7 +2688,7 @@ var require_bn = __commonJS({
|
|
|
2688
2688
|
tmp = tmp.redSqr();
|
|
2689
2689
|
}
|
|
2690
2690
|
assert(i < m);
|
|
2691
|
-
var b = this.pow(c, new
|
|
2691
|
+
var b = this.pow(c, new BN8(1).iushln(m - i - 1));
|
|
2692
2692
|
r = r.redMul(b);
|
|
2693
2693
|
c = b.redSqr();
|
|
2694
2694
|
t = t.redMul(c);
|
|
@@ -2706,11 +2706,11 @@ var require_bn = __commonJS({
|
|
|
2706
2706
|
}
|
|
2707
2707
|
};
|
|
2708
2708
|
Red.prototype.pow = function pow2(a, num) {
|
|
2709
|
-
if (num.isZero()) return new
|
|
2709
|
+
if (num.isZero()) return new BN8(1).toRed(this);
|
|
2710
2710
|
if (num.cmpn(1) === 0) return a.clone();
|
|
2711
2711
|
var windowSize = 4;
|
|
2712
2712
|
var wnd = new Array(1 << windowSize);
|
|
2713
|
-
wnd[0] = new
|
|
2713
|
+
wnd[0] = new BN8(1).toRed(this);
|
|
2714
2714
|
wnd[1] = a;
|
|
2715
2715
|
for (var i = 2; i < wnd.length; i++) {
|
|
2716
2716
|
wnd[i] = this.mul(wnd[i - 1], a);
|
|
@@ -2754,7 +2754,7 @@ var require_bn = __commonJS({
|
|
|
2754
2754
|
res.red = null;
|
|
2755
2755
|
return res;
|
|
2756
2756
|
};
|
|
2757
|
-
|
|
2757
|
+
BN8.mont = function mont(num) {
|
|
2758
2758
|
return new Mont(num);
|
|
2759
2759
|
};
|
|
2760
2760
|
function Mont(m) {
|
|
@@ -2763,7 +2763,7 @@ var require_bn = __commonJS({
|
|
|
2763
2763
|
if (this.shift % 26 !== 0) {
|
|
2764
2764
|
this.shift += 26 - this.shift % 26;
|
|
2765
2765
|
}
|
|
2766
|
-
this.r = new
|
|
2766
|
+
this.r = new BN8(1).iushln(this.shift);
|
|
2767
2767
|
this.r2 = this.imod(this.r.sqr());
|
|
2768
2768
|
this.rinv = this.r._invmp(this.m);
|
|
2769
2769
|
this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
|
|
@@ -2797,7 +2797,7 @@ var require_bn = __commonJS({
|
|
|
2797
2797
|
return res._forceRed(this);
|
|
2798
2798
|
};
|
|
2799
2799
|
Mont.prototype.mul = function mul2(a, b) {
|
|
2800
|
-
if (a.isZero() || b.isZero()) return new
|
|
2800
|
+
if (a.isZero() || b.isZero()) return new BN8(0)._forceRed(this);
|
|
2801
2801
|
var t = a.mul(b);
|
|
2802
2802
|
var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
|
|
2803
2803
|
var u = t.isub(c).iushrn(this.shift);
|
|
@@ -6045,12 +6045,12 @@ var Bluemove = class {
|
|
|
6045
6045
|
// src/transaction/deepbook_v3.ts
|
|
6046
6046
|
var DeepbookV3 = class {
|
|
6047
6047
|
constructor(env) {
|
|
6048
|
-
this.deepbookV3Config = env === 0 /* Mainnet */ ? "
|
|
6048
|
+
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x699d455ab8c5e02075b4345ea1f91be55bf46064ae6026cc2528e701ce3ac135" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6049
6049
|
}
|
|
6050
6050
|
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6051
6051
|
return __async(this, null, function* () {
|
|
6052
6052
|
const { direction, from, target } = path;
|
|
6053
|
-
const [func, coinAType, coinBType] = direction ? ["
|
|
6053
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6054
6054
|
let deepFee;
|
|
6055
6055
|
if (deepbookv3DeepFee) {
|
|
6056
6056
|
deepFee = deepbookv3DeepFee;
|
|
@@ -6483,6 +6483,36 @@ var Obric = class {
|
|
|
6483
6483
|
}
|
|
6484
6484
|
};
|
|
6485
6485
|
|
|
6486
|
+
// src/transaction/hawal.ts
|
|
6487
|
+
var HaWAL = class {
|
|
6488
|
+
constructor(env) {
|
|
6489
|
+
if (env !== 0 /* Mainnet */) {
|
|
6490
|
+
throw new Error("HaWAL only supported on mainnet");
|
|
6491
|
+
}
|
|
6492
|
+
this.staking = env === 0 /* Mainnet */ ? "0x10b9d30c28448939ce6c4d6c6e0ffce4a7f8a4ada8248bdad09ef8b70e4a3904" : "0x0";
|
|
6493
|
+
this.validator = env === 0 /* Mainnet */ ? "0x7b3ba6de2ae58283f60d5b8dc04bb9e90e4796b3b2e0dea75569f491275242e7" : "0x0";
|
|
6494
|
+
}
|
|
6495
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6496
|
+
return __async(this, null, function* () {
|
|
6497
|
+
const { direction } = path;
|
|
6498
|
+
const func = direction ? "swap_a2b" : "swap_b2a";
|
|
6499
|
+
const args = [
|
|
6500
|
+
txb.object(this.staking),
|
|
6501
|
+
txb.object(path.id),
|
|
6502
|
+
inputCoin,
|
|
6503
|
+
txb.object(this.validator)
|
|
6504
|
+
];
|
|
6505
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6506
|
+
const res = txb.moveCall({
|
|
6507
|
+
target: `${publishedAt}::hawal::${func}`,
|
|
6508
|
+
typeArguments: [],
|
|
6509
|
+
arguments: args
|
|
6510
|
+
});
|
|
6511
|
+
return res;
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6514
|
+
};
|
|
6515
|
+
|
|
6486
6516
|
// src/client.ts
|
|
6487
6517
|
var CETUS = "CETUS";
|
|
6488
6518
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6506,6 +6536,7 @@ var SPRINGSUI = "SPRINGSUI";
|
|
|
6506
6536
|
var STEAMM = "STEAMM";
|
|
6507
6537
|
var METASTABLE = "METASTABLE";
|
|
6508
6538
|
var OBRIC = "OBRIC";
|
|
6539
|
+
var HAWAL = "HAWAL";
|
|
6509
6540
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6510
6541
|
function isBuilderRouterSwapParams(params) {
|
|
6511
6542
|
return Array.isArray(params.routers);
|
|
@@ -6515,7 +6546,7 @@ function isBuilderFastRouterSwapParams(params) {
|
|
|
6515
6546
|
}
|
|
6516
6547
|
var _AggregatorClient = class _AggregatorClient {
|
|
6517
6548
|
constructor(params) {
|
|
6518
|
-
var _a;
|
|
6549
|
+
var _a, _b;
|
|
6519
6550
|
this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
|
|
6520
6551
|
this.client = params.client || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
|
|
6521
6552
|
this.signer = params.signer || "";
|
|
@@ -6529,6 +6560,17 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6529
6560
|
config2.wormholeStateId
|
|
6530
6561
|
);
|
|
6531
6562
|
this.apiKey = params.apiKey || "";
|
|
6563
|
+
this.partner = params.partner;
|
|
6564
|
+
if (params.overlayFeeRate) {
|
|
6565
|
+
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= 0.01) {
|
|
6566
|
+
this.overlayFeeRate = params.overlayFeeRate * 1e6;
|
|
6567
|
+
} else {
|
|
6568
|
+
throw new Error("Overlay fee rate must be between 0 and 0.01");
|
|
6569
|
+
}
|
|
6570
|
+
} else {
|
|
6571
|
+
this.overlayFeeRate = 0;
|
|
6572
|
+
}
|
|
6573
|
+
this.overlayFeeReceiver = (_b = params.overlayFeeReceiver) != null ? _b : "0x0";
|
|
6532
6574
|
}
|
|
6533
6575
|
newPythClients(pythUrls) {
|
|
6534
6576
|
if (!pythUrls.includes("https://hermes.pyth.network")) {
|
|
@@ -6581,10 +6623,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6581
6623
|
}
|
|
6582
6624
|
findRouters(params) {
|
|
6583
6625
|
return __async(this, null, function* () {
|
|
6584
|
-
return getRouterResult(this.endpoint, this.apiKey, params);
|
|
6626
|
+
return getRouterResult(this.endpoint, this.apiKey, params, this.overlayFeeRate, this.overlayFeeReceiver);
|
|
6585
6627
|
});
|
|
6586
6628
|
}
|
|
6587
|
-
executeFlexibleInputSwap(txb, inputCoin, routers,
|
|
6629
|
+
executeFlexibleInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6588
6630
|
return __async(this, null, function* () {
|
|
6589
6631
|
if (routers.length === 0) {
|
|
6590
6632
|
throw new Error("No router found");
|
|
@@ -6626,21 +6668,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6626
6668
|
);
|
|
6627
6669
|
}
|
|
6628
6670
|
outputCoins.push(lastCoin);
|
|
6629
|
-
const
|
|
6630
|
-
this.
|
|
6671
|
+
const aggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6672
|
+
this.publishedAtV2Extend(),
|
|
6631
6673
|
packages
|
|
6632
6674
|
);
|
|
6633
6675
|
const mergedTargetCoin = this.checkCoinThresholdAndMergeCoin(
|
|
6634
6676
|
txb,
|
|
6635
6677
|
outputCoins,
|
|
6636
6678
|
outputCoinType,
|
|
6637
|
-
|
|
6638
|
-
|
|
6679
|
+
expectedAmountOut,
|
|
6680
|
+
amountLimit,
|
|
6681
|
+
aggregatorV2ExtendPublishedAt
|
|
6639
6682
|
);
|
|
6640
6683
|
return mergedTargetCoin;
|
|
6641
6684
|
});
|
|
6642
6685
|
}
|
|
6643
|
-
expectInputSwap(txb, inputCoin, routers,
|
|
6686
|
+
expectInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6644
6687
|
return __async(this, null, function* () {
|
|
6645
6688
|
if (routers.length === 0) {
|
|
6646
6689
|
throw new Error("No router found");
|
|
@@ -6672,20 +6715,25 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6672
6715
|
this.publishedAtV2(),
|
|
6673
6716
|
packages
|
|
6674
6717
|
);
|
|
6718
|
+
const aggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6719
|
+
this.publishedAtV2Extend(),
|
|
6720
|
+
packages
|
|
6721
|
+
);
|
|
6675
6722
|
this.transferOrDestoryCoin(
|
|
6676
6723
|
txb,
|
|
6677
6724
|
inputCoin,
|
|
6678
6725
|
inputCoinType,
|
|
6679
|
-
|
|
6726
|
+
aggregatorV2PublishedAt
|
|
6680
6727
|
);
|
|
6681
|
-
const
|
|
6728
|
+
const mergedTargetCoins = this.checkCoinThresholdAndMergeCoin(
|
|
6682
6729
|
txb,
|
|
6683
6730
|
outputCoins,
|
|
6684
6731
|
outputCoinType,
|
|
6685
|
-
|
|
6686
|
-
|
|
6732
|
+
expectedAmountOut,
|
|
6733
|
+
amountLimit,
|
|
6734
|
+
aggregatorV2ExtendPublishedAt
|
|
6687
6735
|
);
|
|
6688
|
-
return
|
|
6736
|
+
return mergedTargetCoins;
|
|
6689
6737
|
});
|
|
6690
6738
|
}
|
|
6691
6739
|
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
@@ -6764,7 +6812,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6764
6812
|
}
|
|
6765
6813
|
routerSwap(params) {
|
|
6766
6814
|
return __async(this, null, function* () {
|
|
6767
|
-
const { routers, inputCoin, slippage, txb,
|
|
6815
|
+
const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
|
|
6816
|
+
if (slippage > 1 || slippage < 0) {
|
|
6817
|
+
throw new Error("Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)");
|
|
6818
|
+
}
|
|
6768
6819
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6769
6820
|
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6770
6821
|
const amountIn = routerData.reduce(
|
|
@@ -6775,8 +6826,18 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6775
6826
|
(acc, router) => acc.add(router.amountOut),
|
|
6776
6827
|
new import_bn5.default(0)
|
|
6777
6828
|
);
|
|
6829
|
+
let overlayFee = new import_bn5.default(0);
|
|
6830
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6831
|
+
if (byAmountIn) {
|
|
6832
|
+
overlayFee = amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6));
|
|
6833
|
+
} else {
|
|
6834
|
+
overlayFee = amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6));
|
|
6835
|
+
}
|
|
6836
|
+
}
|
|
6837
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(overlayFee) : amountOut;
|
|
6838
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(overlayFee);
|
|
6778
6839
|
const amountLimit = CalculateAmountLimitBN(
|
|
6779
|
-
byAmountIn ?
|
|
6840
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6780
6841
|
byAmountIn,
|
|
6781
6842
|
slippage
|
|
6782
6843
|
);
|
|
@@ -6792,16 +6853,23 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6792
6853
|
txb,
|
|
6793
6854
|
inputCoin,
|
|
6794
6855
|
routerData,
|
|
6795
|
-
|
|
6856
|
+
amountOut.toString(),
|
|
6857
|
+
amountLimit.toString(),
|
|
6796
6858
|
priceInfoObjectIds,
|
|
6797
|
-
partner,
|
|
6859
|
+
partner != null ? partner : this.partner,
|
|
6798
6860
|
deepbookv3DeepFee,
|
|
6799
6861
|
packages
|
|
6800
6862
|
);
|
|
6801
6863
|
return targetCoin2;
|
|
6802
6864
|
}
|
|
6865
|
+
const overlayFeeCoin = txb.splitCoins(inputCoin, [
|
|
6866
|
+
overlayFee.toString()
|
|
6867
|
+
]);
|
|
6868
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6869
|
+
txb.transferObjects([overlayFeeCoin], this.overlayFeeReceiver);
|
|
6870
|
+
}
|
|
6803
6871
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6804
|
-
amountLimit.toString()
|
|
6872
|
+
amountLimit.sub(overlayFee).toString()
|
|
6805
6873
|
]);
|
|
6806
6874
|
this.transferOrDestoryCoin(
|
|
6807
6875
|
txb,
|
|
@@ -6813,14 +6881,14 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6813
6881
|
txb,
|
|
6814
6882
|
splitedInputCoins[0],
|
|
6815
6883
|
routerData,
|
|
6816
|
-
partner
|
|
6884
|
+
partner != null ? partner : this.partner
|
|
6817
6885
|
);
|
|
6818
6886
|
return targetCoin;
|
|
6819
6887
|
});
|
|
6820
6888
|
}
|
|
6821
6889
|
fixableRouterSwap(params) {
|
|
6822
6890
|
return __async(this, null, function* () {
|
|
6823
|
-
const { routers, inputCoin, slippage, txb,
|
|
6891
|
+
const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
|
|
6824
6892
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6825
6893
|
const byAmountIn = params.routers.byAmountIn;
|
|
6826
6894
|
const amountIn = routerData.reduce(
|
|
@@ -6831,16 +6899,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6831
6899
|
(acc, router) => acc.add(router.amountOut),
|
|
6832
6900
|
new import_bn5.default(0)
|
|
6833
6901
|
);
|
|
6902
|
+
let overlayFee = 0;
|
|
6903
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6904
|
+
if (byAmountIn) {
|
|
6905
|
+
overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6906
|
+
} else {
|
|
6907
|
+
overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6908
|
+
}
|
|
6909
|
+
}
|
|
6910
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
|
|
6911
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(new import_bn5.default(overlayFee));
|
|
6834
6912
|
const amountLimit = CalculateAmountLimitBN(
|
|
6835
|
-
byAmountIn ?
|
|
6913
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6836
6914
|
byAmountIn,
|
|
6837
6915
|
slippage
|
|
6838
6916
|
);
|
|
6839
6917
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6840
|
-
getAggregatorV2PublishedAt(
|
|
6841
|
-
this.publishedAtV2(),
|
|
6842
|
-
packages
|
|
6843
|
-
);
|
|
6844
6918
|
const priceIDs = findPythPriceIDs(routerData);
|
|
6845
6919
|
const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
|
|
6846
6920
|
if (byAmountIn) {
|
|
@@ -6848,9 +6922,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6848
6922
|
txb,
|
|
6849
6923
|
inputCoin,
|
|
6850
6924
|
routerData,
|
|
6851
|
-
|
|
6925
|
+
expectedAmountOut.toString(),
|
|
6926
|
+
amountLimit.toString(),
|
|
6852
6927
|
priceInfoObjectIds,
|
|
6853
|
-
partner,
|
|
6928
|
+
partner != null ? partner : this.partner,
|
|
6854
6929
|
deepbookv3DeepFee,
|
|
6855
6930
|
packages
|
|
6856
6931
|
);
|
|
@@ -6860,7 +6935,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6860
6935
|
txb,
|
|
6861
6936
|
inputCoin,
|
|
6862
6937
|
routerData,
|
|
6863
|
-
partner
|
|
6938
|
+
partner != null ? partner : this.partner
|
|
6864
6939
|
);
|
|
6865
6940
|
return targetCoin;
|
|
6866
6941
|
});
|
|
@@ -6890,12 +6965,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6890
6965
|
new import_bn5.default(0)
|
|
6891
6966
|
);
|
|
6892
6967
|
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6968
|
+
let overlayFee = 0;
|
|
6969
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6970
|
+
if (byAmountIn) {
|
|
6971
|
+
overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6972
|
+
} else {
|
|
6973
|
+
overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6976
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
|
|
6977
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(new import_bn5.default(overlayFee));
|
|
6893
6978
|
const amountLimit = CalculateAmountLimit(
|
|
6894
|
-
byAmountIn ?
|
|
6979
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6895
6980
|
byAmountIn,
|
|
6896
6981
|
slippage
|
|
6897
6982
|
);
|
|
6898
|
-
const amount = byAmountIn ?
|
|
6983
|
+
const amount = byAmountIn ? expectedAmountIn : amountLimit;
|
|
6899
6984
|
const buildFromCoinRes = buildInputCoin(
|
|
6900
6985
|
txb,
|
|
6901
6986
|
fromCoins,
|
|
@@ -6918,7 +7003,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6918
7003
|
slippage,
|
|
6919
7004
|
byAmountIn,
|
|
6920
7005
|
txb,
|
|
6921
|
-
partner,
|
|
7006
|
+
partner: partner != null ? partner : this.partner,
|
|
6922
7007
|
deepbookv3DeepFee: deepCoin
|
|
6923
7008
|
} : {
|
|
6924
7009
|
routers: params.routers,
|
|
@@ -6926,7 +7011,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6926
7011
|
slippage,
|
|
6927
7012
|
byAmountIn,
|
|
6928
7013
|
txb,
|
|
6929
|
-
partner,
|
|
7014
|
+
partner: partner != null ? partner : this.partner,
|
|
6930
7015
|
deepbookv3DeepFee: deepCoin
|
|
6931
7016
|
};
|
|
6932
7017
|
const targetCoin = yield this.routerSwap(routerSwapParams);
|
|
@@ -6968,7 +7053,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6968
7053
|
// Include deepbookv3, scallop, bluefin
|
|
6969
7054
|
publishedAtV2Extend() {
|
|
6970
7055
|
if (this.env === 0 /* Mainnet */) {
|
|
6971
|
-
return "
|
|
7056
|
+
return "0x39402d188b7231036e52266ebafad14413b4bf3daea4ac17115989444e6cd516";
|
|
6972
7057
|
} else {
|
|
6973
7058
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6974
7059
|
}
|
|
@@ -6987,7 +7072,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6987
7072
|
arguments: [coin]
|
|
6988
7073
|
});
|
|
6989
7074
|
}
|
|
6990
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType,
|
|
7075
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, expectedAmountOut, threshold, aggregatorV2ExtendPublishedAt) {
|
|
6991
7076
|
let targetCoin = coins[0];
|
|
6992
7077
|
if (coins.length > 1) {
|
|
6993
7078
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6998,11 +7083,29 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6998
7083
|
});
|
|
6999
7084
|
targetCoin = coins[0];
|
|
7000
7085
|
}
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7086
|
+
if (this.overlayFeeRate === 0 || this.overlayFeeReceiver === "0x0") {
|
|
7087
|
+
txb.moveCall({
|
|
7088
|
+
target: `${aggregatorV2ExtendPublishedAt}::utils::check_coin_threshold_v1`,
|
|
7089
|
+
typeArguments: [coinType],
|
|
7090
|
+
arguments: [
|
|
7091
|
+
targetCoin,
|
|
7092
|
+
txb.pure.u64(expectedAmountOut),
|
|
7093
|
+
txb.pure.u64(threshold)
|
|
7094
|
+
]
|
|
7095
|
+
});
|
|
7096
|
+
} else {
|
|
7097
|
+
txb.moveCall({
|
|
7098
|
+
target: `${aggregatorV2ExtendPublishedAt}::utils::check_coin_threshold_v2`,
|
|
7099
|
+
typeArguments: [coinType],
|
|
7100
|
+
arguments: [
|
|
7101
|
+
targetCoin,
|
|
7102
|
+
txb.pure.u64(expectedAmountOut),
|
|
7103
|
+
txb.pure.u64(threshold),
|
|
7104
|
+
txb.pure.u64(this.overlayFeeRate),
|
|
7105
|
+
txb.pure.address(this.overlayFeeReceiver)
|
|
7106
|
+
]
|
|
7107
|
+
});
|
|
7108
|
+
}
|
|
7006
7109
|
return targetCoin;
|
|
7007
7110
|
}
|
|
7008
7111
|
newDex(provider, pythPriceIDs, partner) {
|
|
@@ -7051,6 +7154,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7051
7154
|
return new Metastable(this.env, pythPriceIDs);
|
|
7052
7155
|
case OBRIC:
|
|
7053
7156
|
return new Obric(this.env, pythPriceIDs);
|
|
7157
|
+
case HAWAL:
|
|
7158
|
+
return new HaWAL(this.env);
|
|
7054
7159
|
default:
|
|
7055
7160
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7056
7161
|
}
|
|
@@ -7144,7 +7249,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7144
7249
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7145
7250
|
}
|
|
7146
7251
|
};
|
|
7147
|
-
var
|
|
7252
|
+
var AggregatorClient23 = _AggregatorClient;
|
|
7148
7253
|
function findPythPriceIDs(routes) {
|
|
7149
7254
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7150
7255
|
for (const route of routes) {
|
|
@@ -7319,8 +7424,9 @@ function processEndpoint(endpoint) {
|
|
|
7319
7424
|
}
|
|
7320
7425
|
|
|
7321
7426
|
// src/api.ts
|
|
7322
|
-
var
|
|
7323
|
-
|
|
7427
|
+
var import_bn7 = __toESM(require_bn());
|
|
7428
|
+
var SDK_VERSION = 1000600;
|
|
7429
|
+
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7324
7430
|
return __async(this, null, function* () {
|
|
7325
7431
|
let response;
|
|
7326
7432
|
if (params.liquidityChanges && params.liquidityChanges.length > 0) {
|
|
@@ -7367,6 +7473,17 @@ function getRouterResult(endpoint, apiKey, params) {
|
|
|
7367
7473
|
}
|
|
7368
7474
|
if (data.data != null) {
|
|
7369
7475
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7476
|
+
if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
|
|
7477
|
+
if (params.byAmountIn) {
|
|
7478
|
+
const overlayFeeAmount = res.amountOut.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
|
|
7479
|
+
res.overlayFee = Number(overlayFeeAmount.toString());
|
|
7480
|
+
res.amountOut = res.amountOut.sub(overlayFeeAmount);
|
|
7481
|
+
} else {
|
|
7482
|
+
const overlayFeeAmount = res.amountIn.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
|
|
7483
|
+
res.overlayFee = Number(overlayFeeAmount.toString());
|
|
7484
|
+
res.amountIn = res.amountIn.add(overlayFeeAmount);
|
|
7485
|
+
}
|
|
7486
|
+
}
|
|
7370
7487
|
return res;
|
|
7371
7488
|
}
|
|
7372
7489
|
return {
|
|
@@ -7517,7 +7634,7 @@ exports.AFTERMATH = AFTERMATH;
|
|
|
7517
7634
|
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7518
7635
|
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7519
7636
|
exports.ALPHAFI = ALPHAFI;
|
|
7520
|
-
exports.AggregatorClient =
|
|
7637
|
+
exports.AggregatorClient = AggregatorClient23;
|
|
7521
7638
|
exports.BLUEFIN = BLUEFIN;
|
|
7522
7639
|
exports.BLUEMOVE = BLUEMOVE;
|
|
7523
7640
|
exports.CETUS = CETUS;
|
|
@@ -7530,6 +7647,7 @@ exports.FLOWXV2 = FLOWXV2;
|
|
|
7530
7647
|
exports.FLOWXV3 = FLOWXV3;
|
|
7531
7648
|
exports.HAEDAL = HAEDAL;
|
|
7532
7649
|
exports.HAEDALPMM = HAEDALPMM;
|
|
7650
|
+
exports.HAWAL = HAWAL;
|
|
7533
7651
|
exports.KRIYA = KRIYA;
|
|
7534
7652
|
exports.KRIYAV3 = KRIYAV3;
|
|
7535
7653
|
exports.METASTABLE = METASTABLE;
|