@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.mjs
CHANGED
|
@@ -87,8 +87,8 @@ var require_bn = __commonJS({
|
|
|
87
87
|
ctor.prototype = new TempCtor();
|
|
88
88
|
ctor.prototype.constructor = ctor;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
if (
|
|
90
|
+
function BN8(number, base, endian) {
|
|
91
|
+
if (BN8.isBN(number)) {
|
|
92
92
|
return number;
|
|
93
93
|
}
|
|
94
94
|
this.negative = 0;
|
|
@@ -104,12 +104,12 @@ var require_bn = __commonJS({
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if (typeof module2 === "object") {
|
|
107
|
-
module2.exports =
|
|
107
|
+
module2.exports = BN8;
|
|
108
108
|
} else {
|
|
109
|
-
exports2.BN =
|
|
109
|
+
exports2.BN = BN8;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
BN8.BN = BN8;
|
|
112
|
+
BN8.wordSize = 26;
|
|
113
113
|
var Buffer2;
|
|
114
114
|
try {
|
|
115
115
|
if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
|
|
@@ -119,21 +119,21 @@ var require_bn = __commonJS({
|
|
|
119
119
|
}
|
|
120
120
|
} catch (e) {
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
if (num instanceof
|
|
122
|
+
BN8.isBN = function isBN(num) {
|
|
123
|
+
if (num instanceof BN8) {
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
|
-
return num !== null && typeof num === "object" && num.constructor.wordSize ===
|
|
126
|
+
return num !== null && typeof num === "object" && num.constructor.wordSize === BN8.wordSize && Array.isArray(num.words);
|
|
127
127
|
};
|
|
128
|
-
|
|
128
|
+
BN8.max = function max2(left, right) {
|
|
129
129
|
if (left.cmp(right) > 0) return left;
|
|
130
130
|
return right;
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
BN8.min = function min2(left, right) {
|
|
133
133
|
if (left.cmp(right) < 0) return left;
|
|
134
134
|
return right;
|
|
135
135
|
};
|
|
136
|
-
|
|
136
|
+
BN8.prototype._init = function init(number, base, endian) {
|
|
137
137
|
if (typeof number === "number") {
|
|
138
138
|
return this._initNumber(number, base, endian);
|
|
139
139
|
}
|
|
@@ -161,7 +161,7 @@ var require_bn = __commonJS({
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
|
-
|
|
164
|
+
BN8.prototype._initNumber = function _initNumber(number, base, endian) {
|
|
165
165
|
if (number < 0) {
|
|
166
166
|
this.negative = 1;
|
|
167
167
|
number = -number;
|
|
@@ -187,7 +187,7 @@ var require_bn = __commonJS({
|
|
|
187
187
|
if (endian !== "le") return;
|
|
188
188
|
this._initArray(this.toArray(), base, endian);
|
|
189
189
|
};
|
|
190
|
-
|
|
190
|
+
BN8.prototype._initArray = function _initArray(number, base, endian) {
|
|
191
191
|
assert(typeof number.length === "number");
|
|
192
192
|
if (number.length <= 0) {
|
|
193
193
|
this.words = [0];
|
|
@@ -245,7 +245,7 @@ var require_bn = __commonJS({
|
|
|
245
245
|
}
|
|
246
246
|
return r;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
BN8.prototype._parseHex = function _parseHex(number, start, endian) {
|
|
249
249
|
this.length = Math.ceil((number.length - start) / 6);
|
|
250
250
|
this.words = new Array(this.length);
|
|
251
251
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -301,7 +301,7 @@ var require_bn = __commonJS({
|
|
|
301
301
|
}
|
|
302
302
|
return r;
|
|
303
303
|
}
|
|
304
|
-
|
|
304
|
+
BN8.prototype._parseBase = function _parseBase(number, base, start) {
|
|
305
305
|
this.words = [0];
|
|
306
306
|
this.length = 1;
|
|
307
307
|
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
|
|
@@ -337,7 +337,7 @@ var require_bn = __commonJS({
|
|
|
337
337
|
}
|
|
338
338
|
this._strip();
|
|
339
339
|
};
|
|
340
|
-
|
|
340
|
+
BN8.prototype.copy = function copy(dest) {
|
|
341
341
|
dest.words = new Array(this.length);
|
|
342
342
|
for (var i = 0; i < this.length; i++) {
|
|
343
343
|
dest.words[i] = this.words[i];
|
|
@@ -352,27 +352,27 @@ var require_bn = __commonJS({
|
|
|
352
352
|
dest.negative = src.negative;
|
|
353
353
|
dest.red = src.red;
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
BN8.prototype._move = function _move(dest) {
|
|
356
356
|
move(dest, this);
|
|
357
357
|
};
|
|
358
|
-
|
|
359
|
-
var r = new
|
|
358
|
+
BN8.prototype.clone = function clone2() {
|
|
359
|
+
var r = new BN8(null);
|
|
360
360
|
this.copy(r);
|
|
361
361
|
return r;
|
|
362
362
|
};
|
|
363
|
-
|
|
363
|
+
BN8.prototype._expand = function _expand(size) {
|
|
364
364
|
while (this.length < size) {
|
|
365
365
|
this.words[this.length++] = 0;
|
|
366
366
|
}
|
|
367
367
|
return this;
|
|
368
368
|
};
|
|
369
|
-
|
|
369
|
+
BN8.prototype._strip = function strip() {
|
|
370
370
|
while (this.length > 1 && this.words[this.length - 1] === 0) {
|
|
371
371
|
this.length--;
|
|
372
372
|
}
|
|
373
373
|
return this._normSign();
|
|
374
374
|
};
|
|
375
|
-
|
|
375
|
+
BN8.prototype._normSign = function _normSign() {
|
|
376
376
|
if (this.length === 1 && this.words[0] === 0) {
|
|
377
377
|
this.negative = 0;
|
|
378
378
|
}
|
|
@@ -380,12 +380,12 @@ var require_bn = __commonJS({
|
|
|
380
380
|
};
|
|
381
381
|
if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") {
|
|
382
382
|
try {
|
|
383
|
-
|
|
383
|
+
BN8.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect;
|
|
384
384
|
} catch (e) {
|
|
385
|
-
|
|
385
|
+
BN8.prototype.inspect = inspect;
|
|
386
386
|
}
|
|
387
387
|
} else {
|
|
388
|
-
|
|
388
|
+
BN8.prototype.inspect = inspect;
|
|
389
389
|
}
|
|
390
390
|
function inspect() {
|
|
391
391
|
return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">";
|
|
@@ -496,7 +496,7 @@ var require_bn = __commonJS({
|
|
|
496
496
|
52521875,
|
|
497
497
|
60466176
|
|
498
498
|
];
|
|
499
|
-
|
|
499
|
+
BN8.prototype.toString = function toString(base, padding) {
|
|
500
500
|
base = base || 10;
|
|
501
501
|
padding = padding | 0 || 1;
|
|
502
502
|
var out;
|
|
@@ -558,7 +558,7 @@ var require_bn = __commonJS({
|
|
|
558
558
|
}
|
|
559
559
|
assert(false, "Base should be between 2 and 36");
|
|
560
560
|
};
|
|
561
|
-
|
|
561
|
+
BN8.prototype.toNumber = function toNumber() {
|
|
562
562
|
var ret = this.words[0];
|
|
563
563
|
if (this.length === 2) {
|
|
564
564
|
ret += this.words[1] * 67108864;
|
|
@@ -569,15 +569,15 @@ var require_bn = __commonJS({
|
|
|
569
569
|
}
|
|
570
570
|
return this.negative !== 0 ? -ret : ret;
|
|
571
571
|
};
|
|
572
|
-
|
|
572
|
+
BN8.prototype.toJSON = function toJSON() {
|
|
573
573
|
return this.toString(16, 2);
|
|
574
574
|
};
|
|
575
575
|
if (Buffer2) {
|
|
576
|
-
|
|
576
|
+
BN8.prototype.toBuffer = function toBuffer(endian, length) {
|
|
577
577
|
return this.toArrayLike(Buffer2, endian, length);
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
|
-
|
|
580
|
+
BN8.prototype.toArray = function toArray(endian, length) {
|
|
581
581
|
return this.toArrayLike(Array, endian, length);
|
|
582
582
|
};
|
|
583
583
|
var allocate = function allocate2(ArrayType, size) {
|
|
@@ -586,7 +586,7 @@ var require_bn = __commonJS({
|
|
|
586
586
|
}
|
|
587
587
|
return new ArrayType(size);
|
|
588
588
|
};
|
|
589
|
-
|
|
589
|
+
BN8.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {
|
|
590
590
|
this._strip();
|
|
591
591
|
var byteLength = this.byteLength();
|
|
592
592
|
var reqLength = length || Math.max(1, byteLength);
|
|
@@ -597,7 +597,7 @@ var require_bn = __commonJS({
|
|
|
597
597
|
this["_toArrayLike" + postfix](res, byteLength);
|
|
598
598
|
return res;
|
|
599
599
|
};
|
|
600
|
-
|
|
600
|
+
BN8.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {
|
|
601
601
|
var position = 0;
|
|
602
602
|
var carry = 0;
|
|
603
603
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -627,7 +627,7 @@ var require_bn = __commonJS({
|
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
|
-
|
|
630
|
+
BN8.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {
|
|
631
631
|
var position = res.length - 1;
|
|
632
632
|
var carry = 0;
|
|
633
633
|
for (var i = 0, shift = 0; i < this.length; i++) {
|
|
@@ -658,11 +658,11 @@ var require_bn = __commonJS({
|
|
|
658
658
|
}
|
|
659
659
|
};
|
|
660
660
|
if (Math.clz32) {
|
|
661
|
-
|
|
661
|
+
BN8.prototype._countBits = function _countBits(w) {
|
|
662
662
|
return 32 - Math.clz32(w);
|
|
663
663
|
};
|
|
664
664
|
} else {
|
|
665
|
-
|
|
665
|
+
BN8.prototype._countBits = function _countBits(w) {
|
|
666
666
|
var t = w;
|
|
667
667
|
var r = 0;
|
|
668
668
|
if (t >= 4096) {
|
|
@@ -684,7 +684,7 @@ var require_bn = __commonJS({
|
|
|
684
684
|
return r + t;
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
|
-
|
|
687
|
+
BN8.prototype._zeroBits = function _zeroBits(w) {
|
|
688
688
|
if (w === 0) return 26;
|
|
689
689
|
var t = w;
|
|
690
690
|
var r = 0;
|
|
@@ -709,7 +709,7 @@ var require_bn = __commonJS({
|
|
|
709
709
|
}
|
|
710
710
|
return r;
|
|
711
711
|
};
|
|
712
|
-
|
|
712
|
+
BN8.prototype.bitLength = function bitLength() {
|
|
713
713
|
var w = this.words[this.length - 1];
|
|
714
714
|
var hi = this._countBits(w);
|
|
715
715
|
return (this.length - 1) * 26 + hi;
|
|
@@ -723,7 +723,7 @@ var require_bn = __commonJS({
|
|
|
723
723
|
}
|
|
724
724
|
return w;
|
|
725
725
|
}
|
|
726
|
-
|
|
726
|
+
BN8.prototype.zeroBits = function zeroBits() {
|
|
727
727
|
if (this.isZero()) return 0;
|
|
728
728
|
var r = 0;
|
|
729
729
|
for (var i = 0; i < this.length; i++) {
|
|
@@ -733,34 +733,34 @@ var require_bn = __commonJS({
|
|
|
733
733
|
}
|
|
734
734
|
return r;
|
|
735
735
|
};
|
|
736
|
-
|
|
736
|
+
BN8.prototype.byteLength = function byteLength() {
|
|
737
737
|
return Math.ceil(this.bitLength() / 8);
|
|
738
738
|
};
|
|
739
|
-
|
|
739
|
+
BN8.prototype.toTwos = function toTwos(width) {
|
|
740
740
|
if (this.negative !== 0) {
|
|
741
741
|
return this.abs().inotn(width).iaddn(1);
|
|
742
742
|
}
|
|
743
743
|
return this.clone();
|
|
744
744
|
};
|
|
745
|
-
|
|
745
|
+
BN8.prototype.fromTwos = function fromTwos(width) {
|
|
746
746
|
if (this.testn(width - 1)) {
|
|
747
747
|
return this.notn(width).iaddn(1).ineg();
|
|
748
748
|
}
|
|
749
749
|
return this.clone();
|
|
750
750
|
};
|
|
751
|
-
|
|
751
|
+
BN8.prototype.isNeg = function isNeg() {
|
|
752
752
|
return this.negative !== 0;
|
|
753
753
|
};
|
|
754
|
-
|
|
754
|
+
BN8.prototype.neg = function neg() {
|
|
755
755
|
return this.clone().ineg();
|
|
756
756
|
};
|
|
757
|
-
|
|
757
|
+
BN8.prototype.ineg = function ineg() {
|
|
758
758
|
if (!this.isZero()) {
|
|
759
759
|
this.negative ^= 1;
|
|
760
760
|
}
|
|
761
761
|
return this;
|
|
762
762
|
};
|
|
763
|
-
|
|
763
|
+
BN8.prototype.iuor = function iuor(num) {
|
|
764
764
|
while (this.length < num.length) {
|
|
765
765
|
this.words[this.length++] = 0;
|
|
766
766
|
}
|
|
@@ -769,19 +769,19 @@ var require_bn = __commonJS({
|
|
|
769
769
|
}
|
|
770
770
|
return this._strip();
|
|
771
771
|
};
|
|
772
|
-
|
|
772
|
+
BN8.prototype.ior = function ior(num) {
|
|
773
773
|
assert((this.negative | num.negative) === 0);
|
|
774
774
|
return this.iuor(num);
|
|
775
775
|
};
|
|
776
|
-
|
|
776
|
+
BN8.prototype.or = function or(num) {
|
|
777
777
|
if (this.length > num.length) return this.clone().ior(num);
|
|
778
778
|
return num.clone().ior(this);
|
|
779
779
|
};
|
|
780
|
-
|
|
780
|
+
BN8.prototype.uor = function uor(num) {
|
|
781
781
|
if (this.length > num.length) return this.clone().iuor(num);
|
|
782
782
|
return num.clone().iuor(this);
|
|
783
783
|
};
|
|
784
|
-
|
|
784
|
+
BN8.prototype.iuand = function iuand(num) {
|
|
785
785
|
var b;
|
|
786
786
|
if (this.length > num.length) {
|
|
787
787
|
b = num;
|
|
@@ -794,19 +794,19 @@ var require_bn = __commonJS({
|
|
|
794
794
|
this.length = b.length;
|
|
795
795
|
return this._strip();
|
|
796
796
|
};
|
|
797
|
-
|
|
797
|
+
BN8.prototype.iand = function iand(num) {
|
|
798
798
|
assert((this.negative | num.negative) === 0);
|
|
799
799
|
return this.iuand(num);
|
|
800
800
|
};
|
|
801
|
-
|
|
801
|
+
BN8.prototype.and = function and(num) {
|
|
802
802
|
if (this.length > num.length) return this.clone().iand(num);
|
|
803
803
|
return num.clone().iand(this);
|
|
804
804
|
};
|
|
805
|
-
|
|
805
|
+
BN8.prototype.uand = function uand(num) {
|
|
806
806
|
if (this.length > num.length) return this.clone().iuand(num);
|
|
807
807
|
return num.clone().iuand(this);
|
|
808
808
|
};
|
|
809
|
-
|
|
809
|
+
BN8.prototype.iuxor = function iuxor(num) {
|
|
810
810
|
var a;
|
|
811
811
|
var b;
|
|
812
812
|
if (this.length > num.length) {
|
|
@@ -827,19 +827,19 @@ var require_bn = __commonJS({
|
|
|
827
827
|
this.length = a.length;
|
|
828
828
|
return this._strip();
|
|
829
829
|
};
|
|
830
|
-
|
|
830
|
+
BN8.prototype.ixor = function ixor(num) {
|
|
831
831
|
assert((this.negative | num.negative) === 0);
|
|
832
832
|
return this.iuxor(num);
|
|
833
833
|
};
|
|
834
|
-
|
|
834
|
+
BN8.prototype.xor = function xor(num) {
|
|
835
835
|
if (this.length > num.length) return this.clone().ixor(num);
|
|
836
836
|
return num.clone().ixor(this);
|
|
837
837
|
};
|
|
838
|
-
|
|
838
|
+
BN8.prototype.uxor = function uxor(num) {
|
|
839
839
|
if (this.length > num.length) return this.clone().iuxor(num);
|
|
840
840
|
return num.clone().iuxor(this);
|
|
841
841
|
};
|
|
842
|
-
|
|
842
|
+
BN8.prototype.inotn = function inotn(width) {
|
|
843
843
|
assert(typeof width === "number" && width >= 0);
|
|
844
844
|
var bytesNeeded = Math.ceil(width / 26) | 0;
|
|
845
845
|
var bitsLeft = width % 26;
|
|
@@ -855,10 +855,10 @@ var require_bn = __commonJS({
|
|
|
855
855
|
}
|
|
856
856
|
return this._strip();
|
|
857
857
|
};
|
|
858
|
-
|
|
858
|
+
BN8.prototype.notn = function notn(width) {
|
|
859
859
|
return this.clone().inotn(width);
|
|
860
860
|
};
|
|
861
|
-
|
|
861
|
+
BN8.prototype.setn = function setn(bit, val) {
|
|
862
862
|
assert(typeof bit === "number" && bit >= 0);
|
|
863
863
|
var off = bit / 26 | 0;
|
|
864
864
|
var wbit = bit % 26;
|
|
@@ -870,7 +870,7 @@ var require_bn = __commonJS({
|
|
|
870
870
|
}
|
|
871
871
|
return this._strip();
|
|
872
872
|
};
|
|
873
|
-
|
|
873
|
+
BN8.prototype.iadd = function iadd(num) {
|
|
874
874
|
var r;
|
|
875
875
|
if (this.negative !== 0 && num.negative === 0) {
|
|
876
876
|
this.negative = 0;
|
|
@@ -913,7 +913,7 @@ var require_bn = __commonJS({
|
|
|
913
913
|
}
|
|
914
914
|
return this;
|
|
915
915
|
};
|
|
916
|
-
|
|
916
|
+
BN8.prototype.add = function add2(num) {
|
|
917
917
|
var res;
|
|
918
918
|
if (num.negative !== 0 && this.negative === 0) {
|
|
919
919
|
num.negative = 0;
|
|
@@ -929,7 +929,7 @@ var require_bn = __commonJS({
|
|
|
929
929
|
if (this.length > num.length) return this.clone().iadd(num);
|
|
930
930
|
return num.clone().iadd(this);
|
|
931
931
|
};
|
|
932
|
-
|
|
932
|
+
BN8.prototype.isub = function isub(num) {
|
|
933
933
|
if (num.negative !== 0) {
|
|
934
934
|
num.negative = 0;
|
|
935
935
|
var r = this.iadd(num);
|
|
@@ -978,7 +978,7 @@ var require_bn = __commonJS({
|
|
|
978
978
|
}
|
|
979
979
|
return this._strip();
|
|
980
980
|
};
|
|
981
|
-
|
|
981
|
+
BN8.prototype.sub = function sub2(num) {
|
|
982
982
|
return this.clone().isub(num);
|
|
983
983
|
};
|
|
984
984
|
function smallMulTo(self, num, out) {
|
|
@@ -1606,7 +1606,7 @@ var require_bn = __commonJS({
|
|
|
1606
1606
|
function jumboMulTo(self, num, out) {
|
|
1607
1607
|
return bigMulTo(self, num, out);
|
|
1608
1608
|
}
|
|
1609
|
-
|
|
1609
|
+
BN8.prototype.mulTo = function mulTo(num, out) {
|
|
1610
1610
|
var res;
|
|
1611
1611
|
var len = this.length + num.length;
|
|
1612
1612
|
if (this.length === 10 && num.length === 10) {
|
|
@@ -1620,20 +1620,20 @@ var require_bn = __commonJS({
|
|
|
1620
1620
|
}
|
|
1621
1621
|
return res;
|
|
1622
1622
|
};
|
|
1623
|
-
|
|
1624
|
-
var out = new
|
|
1623
|
+
BN8.prototype.mul = function mul2(num) {
|
|
1624
|
+
var out = new BN8(null);
|
|
1625
1625
|
out.words = new Array(this.length + num.length);
|
|
1626
1626
|
return this.mulTo(num, out);
|
|
1627
1627
|
};
|
|
1628
|
-
|
|
1629
|
-
var out = new
|
|
1628
|
+
BN8.prototype.mulf = function mulf(num) {
|
|
1629
|
+
var out = new BN8(null);
|
|
1630
1630
|
out.words = new Array(this.length + num.length);
|
|
1631
1631
|
return jumboMulTo(this, num, out);
|
|
1632
1632
|
};
|
|
1633
|
-
|
|
1633
|
+
BN8.prototype.imul = function imul(num) {
|
|
1634
1634
|
return this.clone().mulTo(num, this);
|
|
1635
1635
|
};
|
|
1636
|
-
|
|
1636
|
+
BN8.prototype.imuln = function imuln(num) {
|
|
1637
1637
|
var isNegNum = num < 0;
|
|
1638
1638
|
if (isNegNum) num = -num;
|
|
1639
1639
|
assert(typeof num === "number");
|
|
@@ -1653,18 +1653,18 @@ var require_bn = __commonJS({
|
|
|
1653
1653
|
}
|
|
1654
1654
|
return isNegNum ? this.ineg() : this;
|
|
1655
1655
|
};
|
|
1656
|
-
|
|
1656
|
+
BN8.prototype.muln = function muln(num) {
|
|
1657
1657
|
return this.clone().imuln(num);
|
|
1658
1658
|
};
|
|
1659
|
-
|
|
1659
|
+
BN8.prototype.sqr = function sqr() {
|
|
1660
1660
|
return this.mul(this);
|
|
1661
1661
|
};
|
|
1662
|
-
|
|
1662
|
+
BN8.prototype.isqr = function isqr() {
|
|
1663
1663
|
return this.imul(this.clone());
|
|
1664
1664
|
};
|
|
1665
|
-
|
|
1665
|
+
BN8.prototype.pow = function pow2(num) {
|
|
1666
1666
|
var w = toBitArray(num);
|
|
1667
|
-
if (w.length === 0) return new
|
|
1667
|
+
if (w.length === 0) return new BN8(1);
|
|
1668
1668
|
var res = this;
|
|
1669
1669
|
for (var i = 0; i < w.length; i++, res = res.sqr()) {
|
|
1670
1670
|
if (w[i] !== 0) break;
|
|
@@ -1677,7 +1677,7 @@ var require_bn = __commonJS({
|
|
|
1677
1677
|
}
|
|
1678
1678
|
return res;
|
|
1679
1679
|
};
|
|
1680
|
-
|
|
1680
|
+
BN8.prototype.iushln = function iushln(bits) {
|
|
1681
1681
|
assert(typeof bits === "number" && bits >= 0);
|
|
1682
1682
|
var r = bits % 26;
|
|
1683
1683
|
var s = (bits - r) / 26;
|
|
@@ -1707,11 +1707,11 @@ var require_bn = __commonJS({
|
|
|
1707
1707
|
}
|
|
1708
1708
|
return this._strip();
|
|
1709
1709
|
};
|
|
1710
|
-
|
|
1710
|
+
BN8.prototype.ishln = function ishln(bits) {
|
|
1711
1711
|
assert(this.negative === 0);
|
|
1712
1712
|
return this.iushln(bits);
|
|
1713
1713
|
};
|
|
1714
|
-
|
|
1714
|
+
BN8.prototype.iushrn = function iushrn(bits, hint, extended) {
|
|
1715
1715
|
assert(typeof bits === "number" && bits >= 0);
|
|
1716
1716
|
var h;
|
|
1717
1717
|
if (hint) {
|
|
@@ -1755,23 +1755,23 @@ var require_bn = __commonJS({
|
|
|
1755
1755
|
}
|
|
1756
1756
|
return this._strip();
|
|
1757
1757
|
};
|
|
1758
|
-
|
|
1758
|
+
BN8.prototype.ishrn = function ishrn(bits, hint, extended) {
|
|
1759
1759
|
assert(this.negative === 0);
|
|
1760
1760
|
return this.iushrn(bits, hint, extended);
|
|
1761
1761
|
};
|
|
1762
|
-
|
|
1762
|
+
BN8.prototype.shln = function shln(bits) {
|
|
1763
1763
|
return this.clone().ishln(bits);
|
|
1764
1764
|
};
|
|
1765
|
-
|
|
1765
|
+
BN8.prototype.ushln = function ushln(bits) {
|
|
1766
1766
|
return this.clone().iushln(bits);
|
|
1767
1767
|
};
|
|
1768
|
-
|
|
1768
|
+
BN8.prototype.shrn = function shrn(bits) {
|
|
1769
1769
|
return this.clone().ishrn(bits);
|
|
1770
1770
|
};
|
|
1771
|
-
|
|
1771
|
+
BN8.prototype.ushrn = function ushrn(bits) {
|
|
1772
1772
|
return this.clone().iushrn(bits);
|
|
1773
1773
|
};
|
|
1774
|
-
|
|
1774
|
+
BN8.prototype.testn = function testn(bit) {
|
|
1775
1775
|
assert(typeof bit === "number" && bit >= 0);
|
|
1776
1776
|
var r = bit % 26;
|
|
1777
1777
|
var s = (bit - r) / 26;
|
|
@@ -1780,7 +1780,7 @@ var require_bn = __commonJS({
|
|
|
1780
1780
|
var w = this.words[s];
|
|
1781
1781
|
return !!(w & q);
|
|
1782
1782
|
};
|
|
1783
|
-
|
|
1783
|
+
BN8.prototype.imaskn = function imaskn(bits) {
|
|
1784
1784
|
assert(typeof bits === "number" && bits >= 0);
|
|
1785
1785
|
var r = bits % 26;
|
|
1786
1786
|
var s = (bits - r) / 26;
|
|
@@ -1798,10 +1798,10 @@ var require_bn = __commonJS({
|
|
|
1798
1798
|
}
|
|
1799
1799
|
return this._strip();
|
|
1800
1800
|
};
|
|
1801
|
-
|
|
1801
|
+
BN8.prototype.maskn = function maskn(bits) {
|
|
1802
1802
|
return this.clone().imaskn(bits);
|
|
1803
1803
|
};
|
|
1804
|
-
|
|
1804
|
+
BN8.prototype.iaddn = function iaddn(num) {
|
|
1805
1805
|
assert(typeof num === "number");
|
|
1806
1806
|
assert(num < 67108864);
|
|
1807
1807
|
if (num < 0) return this.isubn(-num);
|
|
@@ -1818,7 +1818,7 @@ var require_bn = __commonJS({
|
|
|
1818
1818
|
}
|
|
1819
1819
|
return this._iaddn(num);
|
|
1820
1820
|
};
|
|
1821
|
-
|
|
1821
|
+
BN8.prototype._iaddn = function _iaddn(num) {
|
|
1822
1822
|
this.words[0] += num;
|
|
1823
1823
|
for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) {
|
|
1824
1824
|
this.words[i] -= 67108864;
|
|
@@ -1831,7 +1831,7 @@ var require_bn = __commonJS({
|
|
|
1831
1831
|
this.length = Math.max(this.length, i + 1);
|
|
1832
1832
|
return this;
|
|
1833
1833
|
};
|
|
1834
|
-
|
|
1834
|
+
BN8.prototype.isubn = function isubn(num) {
|
|
1835
1835
|
assert(typeof num === "number");
|
|
1836
1836
|
assert(num < 67108864);
|
|
1837
1837
|
if (num < 0) return this.iaddn(-num);
|
|
@@ -1853,20 +1853,20 @@ var require_bn = __commonJS({
|
|
|
1853
1853
|
}
|
|
1854
1854
|
return this._strip();
|
|
1855
1855
|
};
|
|
1856
|
-
|
|
1856
|
+
BN8.prototype.addn = function addn(num) {
|
|
1857
1857
|
return this.clone().iaddn(num);
|
|
1858
1858
|
};
|
|
1859
|
-
|
|
1859
|
+
BN8.prototype.subn = function subn(num) {
|
|
1860
1860
|
return this.clone().isubn(num);
|
|
1861
1861
|
};
|
|
1862
|
-
|
|
1862
|
+
BN8.prototype.iabs = function iabs() {
|
|
1863
1863
|
this.negative = 0;
|
|
1864
1864
|
return this;
|
|
1865
1865
|
};
|
|
1866
|
-
|
|
1866
|
+
BN8.prototype.abs = function abs2() {
|
|
1867
1867
|
return this.clone().iabs();
|
|
1868
1868
|
};
|
|
1869
|
-
|
|
1869
|
+
BN8.prototype._ishlnsubmul = function _ishlnsubmul(num, mul2, shift) {
|
|
1870
1870
|
var len = num.length + shift;
|
|
1871
1871
|
var i;
|
|
1872
1872
|
this._expand(len);
|
|
@@ -1895,7 +1895,7 @@ var require_bn = __commonJS({
|
|
|
1895
1895
|
this.negative = 1;
|
|
1896
1896
|
return this._strip();
|
|
1897
1897
|
};
|
|
1898
|
-
|
|
1898
|
+
BN8.prototype._wordDiv = function _wordDiv(num, mode) {
|
|
1899
1899
|
var shift = this.length - num.length;
|
|
1900
1900
|
var a = this.clone();
|
|
1901
1901
|
var b = num;
|
|
@@ -1910,7 +1910,7 @@ var require_bn = __commonJS({
|
|
|
1910
1910
|
var m = a.length - b.length;
|
|
1911
1911
|
var q;
|
|
1912
1912
|
if (mode !== "mod") {
|
|
1913
|
-
q = new
|
|
1913
|
+
q = new BN8(null);
|
|
1914
1914
|
q.length = m + 1;
|
|
1915
1915
|
q.words = new Array(q.length);
|
|
1916
1916
|
for (var i = 0; i < q.length; i++) {
|
|
@@ -1952,12 +1952,12 @@ var require_bn = __commonJS({
|
|
|
1952
1952
|
mod: a
|
|
1953
1953
|
};
|
|
1954
1954
|
};
|
|
1955
|
-
|
|
1955
|
+
BN8.prototype.divmod = function divmod(num, mode, positive) {
|
|
1956
1956
|
assert(!num.isZero());
|
|
1957
1957
|
if (this.isZero()) {
|
|
1958
1958
|
return {
|
|
1959
|
-
div: new
|
|
1960
|
-
mod: new
|
|
1959
|
+
div: new BN8(0),
|
|
1960
|
+
mod: new BN8(0)
|
|
1961
1961
|
};
|
|
1962
1962
|
}
|
|
1963
1963
|
var div2, mod2, res;
|
|
@@ -2002,7 +2002,7 @@ var require_bn = __commonJS({
|
|
|
2002
2002
|
}
|
|
2003
2003
|
if (num.length > this.length || this.cmp(num) < 0) {
|
|
2004
2004
|
return {
|
|
2005
|
-
div: new
|
|
2005
|
+
div: new BN8(0),
|
|
2006
2006
|
mod: this
|
|
2007
2007
|
};
|
|
2008
2008
|
}
|
|
@@ -2016,26 +2016,26 @@ var require_bn = __commonJS({
|
|
|
2016
2016
|
if (mode === "mod") {
|
|
2017
2017
|
return {
|
|
2018
2018
|
div: null,
|
|
2019
|
-
mod: new
|
|
2019
|
+
mod: new BN8(this.modrn(num.words[0]))
|
|
2020
2020
|
};
|
|
2021
2021
|
}
|
|
2022
2022
|
return {
|
|
2023
2023
|
div: this.divn(num.words[0]),
|
|
2024
|
-
mod: new
|
|
2024
|
+
mod: new BN8(this.modrn(num.words[0]))
|
|
2025
2025
|
};
|
|
2026
2026
|
}
|
|
2027
2027
|
return this._wordDiv(num, mode);
|
|
2028
2028
|
};
|
|
2029
|
-
|
|
2029
|
+
BN8.prototype.div = function div2(num) {
|
|
2030
2030
|
return this.divmod(num, "div", false).div;
|
|
2031
2031
|
};
|
|
2032
|
-
|
|
2032
|
+
BN8.prototype.mod = function mod2(num) {
|
|
2033
2033
|
return this.divmod(num, "mod", false).mod;
|
|
2034
2034
|
};
|
|
2035
|
-
|
|
2035
|
+
BN8.prototype.umod = function umod(num) {
|
|
2036
2036
|
return this.divmod(num, "mod", true).mod;
|
|
2037
2037
|
};
|
|
2038
|
-
|
|
2038
|
+
BN8.prototype.divRound = function divRound(num) {
|
|
2039
2039
|
var dm = this.divmod(num);
|
|
2040
2040
|
if (dm.mod.isZero()) return dm.div;
|
|
2041
2041
|
var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
|
|
@@ -2045,7 +2045,7 @@ var require_bn = __commonJS({
|
|
|
2045
2045
|
if (cmp2 < 0 || r2 === 1 && cmp2 === 0) return dm.div;
|
|
2046
2046
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
|
2047
2047
|
};
|
|
2048
|
-
|
|
2048
|
+
BN8.prototype.modrn = function modrn(num) {
|
|
2049
2049
|
var isNegNum = num < 0;
|
|
2050
2050
|
if (isNegNum) num = -num;
|
|
2051
2051
|
assert(num <= 67108863);
|
|
@@ -2056,10 +2056,10 @@ var require_bn = __commonJS({
|
|
|
2056
2056
|
}
|
|
2057
2057
|
return isNegNum ? -acc : acc;
|
|
2058
2058
|
};
|
|
2059
|
-
|
|
2059
|
+
BN8.prototype.modn = function modn(num) {
|
|
2060
2060
|
return this.modrn(num);
|
|
2061
2061
|
};
|
|
2062
|
-
|
|
2062
|
+
BN8.prototype.idivn = function idivn(num) {
|
|
2063
2063
|
var isNegNum = num < 0;
|
|
2064
2064
|
if (isNegNum) num = -num;
|
|
2065
2065
|
assert(num <= 67108863);
|
|
@@ -2072,10 +2072,10 @@ var require_bn = __commonJS({
|
|
|
2072
2072
|
this._strip();
|
|
2073
2073
|
return isNegNum ? this.ineg() : this;
|
|
2074
2074
|
};
|
|
2075
|
-
|
|
2075
|
+
BN8.prototype.divn = function divn(num) {
|
|
2076
2076
|
return this.clone().idivn(num);
|
|
2077
2077
|
};
|
|
2078
|
-
|
|
2078
|
+
BN8.prototype.egcd = function egcd(p) {
|
|
2079
2079
|
assert(p.negative === 0);
|
|
2080
2080
|
assert(!p.isZero());
|
|
2081
2081
|
var x = this;
|
|
@@ -2085,10 +2085,10 @@ var require_bn = __commonJS({
|
|
|
2085
2085
|
} else {
|
|
2086
2086
|
x = x.clone();
|
|
2087
2087
|
}
|
|
2088
|
-
var A = new
|
|
2089
|
-
var B = new
|
|
2090
|
-
var C = new
|
|
2091
|
-
var D = new
|
|
2088
|
+
var A = new BN8(1);
|
|
2089
|
+
var B = new BN8(0);
|
|
2090
|
+
var C = new BN8(0);
|
|
2091
|
+
var D = new BN8(1);
|
|
2092
2092
|
var g = 0;
|
|
2093
2093
|
while (x.isEven() && y.isEven()) {
|
|
2094
2094
|
x.iushrn(1);
|
|
@@ -2138,7 +2138,7 @@ var require_bn = __commonJS({
|
|
|
2138
2138
|
gcd: y.iushln(g)
|
|
2139
2139
|
};
|
|
2140
2140
|
};
|
|
2141
|
-
|
|
2141
|
+
BN8.prototype._invmp = function _invmp(p) {
|
|
2142
2142
|
assert(p.negative === 0);
|
|
2143
2143
|
assert(!p.isZero());
|
|
2144
2144
|
var a = this;
|
|
@@ -2148,8 +2148,8 @@ var require_bn = __commonJS({
|
|
|
2148
2148
|
} else {
|
|
2149
2149
|
a = a.clone();
|
|
2150
2150
|
}
|
|
2151
|
-
var x1 = new
|
|
2152
|
-
var x2 = new
|
|
2151
|
+
var x1 = new BN8(1);
|
|
2152
|
+
var x2 = new BN8(0);
|
|
2153
2153
|
var delta = b.clone();
|
|
2154
2154
|
while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
|
|
2155
2155
|
for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1) ;
|
|
@@ -2191,7 +2191,7 @@ var require_bn = __commonJS({
|
|
|
2191
2191
|
}
|
|
2192
2192
|
return res;
|
|
2193
2193
|
};
|
|
2194
|
-
|
|
2194
|
+
BN8.prototype.gcd = function gcd(num) {
|
|
2195
2195
|
if (this.isZero()) return num.abs();
|
|
2196
2196
|
if (num.isZero()) return this.abs();
|
|
2197
2197
|
var a = this.clone();
|
|
@@ -2221,19 +2221,19 @@ var require_bn = __commonJS({
|
|
|
2221
2221
|
} while (true);
|
|
2222
2222
|
return b.iushln(shift);
|
|
2223
2223
|
};
|
|
2224
|
-
|
|
2224
|
+
BN8.prototype.invm = function invm(num) {
|
|
2225
2225
|
return this.egcd(num).a.umod(num);
|
|
2226
2226
|
};
|
|
2227
|
-
|
|
2227
|
+
BN8.prototype.isEven = function isEven() {
|
|
2228
2228
|
return (this.words[0] & 1) === 0;
|
|
2229
2229
|
};
|
|
2230
|
-
|
|
2230
|
+
BN8.prototype.isOdd = function isOdd2() {
|
|
2231
2231
|
return (this.words[0] & 1) === 1;
|
|
2232
2232
|
};
|
|
2233
|
-
|
|
2233
|
+
BN8.prototype.andln = function andln(num) {
|
|
2234
2234
|
return this.words[0] & num;
|
|
2235
2235
|
};
|
|
2236
|
-
|
|
2236
|
+
BN8.prototype.bincn = function bincn(bit) {
|
|
2237
2237
|
assert(typeof bit === "number");
|
|
2238
2238
|
var r = bit % 26;
|
|
2239
2239
|
var s = (bit - r) / 26;
|
|
@@ -2257,10 +2257,10 @@ var require_bn = __commonJS({
|
|
|
2257
2257
|
}
|
|
2258
2258
|
return this;
|
|
2259
2259
|
};
|
|
2260
|
-
|
|
2260
|
+
BN8.prototype.isZero = function isZero() {
|
|
2261
2261
|
return this.length === 1 && this.words[0] === 0;
|
|
2262
2262
|
};
|
|
2263
|
-
|
|
2263
|
+
BN8.prototype.cmpn = function cmpn(num) {
|
|
2264
2264
|
var negative = num < 0;
|
|
2265
2265
|
if (this.negative !== 0 && !negative) return -1;
|
|
2266
2266
|
if (this.negative === 0 && negative) return 1;
|
|
@@ -2279,14 +2279,14 @@ var require_bn = __commonJS({
|
|
|
2279
2279
|
if (this.negative !== 0) return -res | 0;
|
|
2280
2280
|
return res;
|
|
2281
2281
|
};
|
|
2282
|
-
|
|
2282
|
+
BN8.prototype.cmp = function cmp2(num) {
|
|
2283
2283
|
if (this.negative !== 0 && num.negative === 0) return -1;
|
|
2284
2284
|
if (this.negative === 0 && num.negative !== 0) return 1;
|
|
2285
2285
|
var res = this.ucmp(num);
|
|
2286
2286
|
if (this.negative !== 0) return -res | 0;
|
|
2287
2287
|
return res;
|
|
2288
2288
|
};
|
|
2289
|
-
|
|
2289
|
+
BN8.prototype.ucmp = function ucmp(num) {
|
|
2290
2290
|
if (this.length > num.length) return 1;
|
|
2291
2291
|
if (this.length < num.length) return -1;
|
|
2292
2292
|
var res = 0;
|
|
@@ -2303,112 +2303,112 @@ var require_bn = __commonJS({
|
|
|
2303
2303
|
}
|
|
2304
2304
|
return res;
|
|
2305
2305
|
};
|
|
2306
|
-
|
|
2306
|
+
BN8.prototype.gtn = function gtn(num) {
|
|
2307
2307
|
return this.cmpn(num) === 1;
|
|
2308
2308
|
};
|
|
2309
|
-
|
|
2309
|
+
BN8.prototype.gt = function gt(num) {
|
|
2310
2310
|
return this.cmp(num) === 1;
|
|
2311
2311
|
};
|
|
2312
|
-
|
|
2312
|
+
BN8.prototype.gten = function gten(num) {
|
|
2313
2313
|
return this.cmpn(num) >= 0;
|
|
2314
2314
|
};
|
|
2315
|
-
|
|
2315
|
+
BN8.prototype.gte = function gte(num) {
|
|
2316
2316
|
return this.cmp(num) >= 0;
|
|
2317
2317
|
};
|
|
2318
|
-
|
|
2318
|
+
BN8.prototype.ltn = function ltn(num) {
|
|
2319
2319
|
return this.cmpn(num) === -1;
|
|
2320
2320
|
};
|
|
2321
|
-
|
|
2321
|
+
BN8.prototype.lt = function lt(num) {
|
|
2322
2322
|
return this.cmp(num) === -1;
|
|
2323
2323
|
};
|
|
2324
|
-
|
|
2324
|
+
BN8.prototype.lten = function lten(num) {
|
|
2325
2325
|
return this.cmpn(num) <= 0;
|
|
2326
2326
|
};
|
|
2327
|
-
|
|
2327
|
+
BN8.prototype.lte = function lte(num) {
|
|
2328
2328
|
return this.cmp(num) <= 0;
|
|
2329
2329
|
};
|
|
2330
|
-
|
|
2330
|
+
BN8.prototype.eqn = function eqn(num) {
|
|
2331
2331
|
return this.cmpn(num) === 0;
|
|
2332
2332
|
};
|
|
2333
|
-
|
|
2333
|
+
BN8.prototype.eq = function eq(num) {
|
|
2334
2334
|
return this.cmp(num) === 0;
|
|
2335
2335
|
};
|
|
2336
|
-
|
|
2336
|
+
BN8.red = function red(num) {
|
|
2337
2337
|
return new Red(num);
|
|
2338
2338
|
};
|
|
2339
|
-
|
|
2339
|
+
BN8.prototype.toRed = function toRed(ctx) {
|
|
2340
2340
|
assert(!this.red, "Already a number in reduction context");
|
|
2341
2341
|
assert(this.negative === 0, "red works only with positives");
|
|
2342
2342
|
return ctx.convertTo(this)._forceRed(ctx);
|
|
2343
2343
|
};
|
|
2344
|
-
|
|
2344
|
+
BN8.prototype.fromRed = function fromRed() {
|
|
2345
2345
|
assert(this.red, "fromRed works only with numbers in reduction context");
|
|
2346
2346
|
return this.red.convertFrom(this);
|
|
2347
2347
|
};
|
|
2348
|
-
|
|
2348
|
+
BN8.prototype._forceRed = function _forceRed(ctx) {
|
|
2349
2349
|
this.red = ctx;
|
|
2350
2350
|
return this;
|
|
2351
2351
|
};
|
|
2352
|
-
|
|
2352
|
+
BN8.prototype.forceRed = function forceRed(ctx) {
|
|
2353
2353
|
assert(!this.red, "Already a number in reduction context");
|
|
2354
2354
|
return this._forceRed(ctx);
|
|
2355
2355
|
};
|
|
2356
|
-
|
|
2356
|
+
BN8.prototype.redAdd = function redAdd(num) {
|
|
2357
2357
|
assert(this.red, "redAdd works only with red numbers");
|
|
2358
2358
|
return this.red.add(this, num);
|
|
2359
2359
|
};
|
|
2360
|
-
|
|
2360
|
+
BN8.prototype.redIAdd = function redIAdd(num) {
|
|
2361
2361
|
assert(this.red, "redIAdd works only with red numbers");
|
|
2362
2362
|
return this.red.iadd(this, num);
|
|
2363
2363
|
};
|
|
2364
|
-
|
|
2364
|
+
BN8.prototype.redSub = function redSub(num) {
|
|
2365
2365
|
assert(this.red, "redSub works only with red numbers");
|
|
2366
2366
|
return this.red.sub(this, num);
|
|
2367
2367
|
};
|
|
2368
|
-
|
|
2368
|
+
BN8.prototype.redISub = function redISub(num) {
|
|
2369
2369
|
assert(this.red, "redISub works only with red numbers");
|
|
2370
2370
|
return this.red.isub(this, num);
|
|
2371
2371
|
};
|
|
2372
|
-
|
|
2372
|
+
BN8.prototype.redShl = function redShl(num) {
|
|
2373
2373
|
assert(this.red, "redShl works only with red numbers");
|
|
2374
2374
|
return this.red.shl(this, num);
|
|
2375
2375
|
};
|
|
2376
|
-
|
|
2376
|
+
BN8.prototype.redMul = function redMul(num) {
|
|
2377
2377
|
assert(this.red, "redMul works only with red numbers");
|
|
2378
2378
|
this.red._verify2(this, num);
|
|
2379
2379
|
return this.red.mul(this, num);
|
|
2380
2380
|
};
|
|
2381
|
-
|
|
2381
|
+
BN8.prototype.redIMul = function redIMul(num) {
|
|
2382
2382
|
assert(this.red, "redMul works only with red numbers");
|
|
2383
2383
|
this.red._verify2(this, num);
|
|
2384
2384
|
return this.red.imul(this, num);
|
|
2385
2385
|
};
|
|
2386
|
-
|
|
2386
|
+
BN8.prototype.redSqr = function redSqr() {
|
|
2387
2387
|
assert(this.red, "redSqr works only with red numbers");
|
|
2388
2388
|
this.red._verify1(this);
|
|
2389
2389
|
return this.red.sqr(this);
|
|
2390
2390
|
};
|
|
2391
|
-
|
|
2391
|
+
BN8.prototype.redISqr = function redISqr() {
|
|
2392
2392
|
assert(this.red, "redISqr works only with red numbers");
|
|
2393
2393
|
this.red._verify1(this);
|
|
2394
2394
|
return this.red.isqr(this);
|
|
2395
2395
|
};
|
|
2396
|
-
|
|
2396
|
+
BN8.prototype.redSqrt = function redSqrt() {
|
|
2397
2397
|
assert(this.red, "redSqrt works only with red numbers");
|
|
2398
2398
|
this.red._verify1(this);
|
|
2399
2399
|
return this.red.sqrt(this);
|
|
2400
2400
|
};
|
|
2401
|
-
|
|
2401
|
+
BN8.prototype.redInvm = function redInvm() {
|
|
2402
2402
|
assert(this.red, "redInvm works only with red numbers");
|
|
2403
2403
|
this.red._verify1(this);
|
|
2404
2404
|
return this.red.invm(this);
|
|
2405
2405
|
};
|
|
2406
|
-
|
|
2406
|
+
BN8.prototype.redNeg = function redNeg() {
|
|
2407
2407
|
assert(this.red, "redNeg works only with red numbers");
|
|
2408
2408
|
this.red._verify1(this);
|
|
2409
2409
|
return this.red.neg(this);
|
|
2410
2410
|
};
|
|
2411
|
-
|
|
2411
|
+
BN8.prototype.redPow = function redPow(num) {
|
|
2412
2412
|
assert(this.red && !num.red, "redPow(normalNum)");
|
|
2413
2413
|
this.red._verify1(this);
|
|
2414
2414
|
return this.red.pow(this, num);
|
|
@@ -2421,13 +2421,13 @@ var require_bn = __commonJS({
|
|
|
2421
2421
|
};
|
|
2422
2422
|
function MPrime(name, p) {
|
|
2423
2423
|
this.name = name;
|
|
2424
|
-
this.p = new
|
|
2424
|
+
this.p = new BN8(p, 16);
|
|
2425
2425
|
this.n = this.p.bitLength();
|
|
2426
|
-
this.k = new
|
|
2426
|
+
this.k = new BN8(1).iushln(this.n).isub(this.p);
|
|
2427
2427
|
this.tmp = this._tmp();
|
|
2428
2428
|
}
|
|
2429
2429
|
MPrime.prototype._tmp = function _tmp() {
|
|
2430
|
-
var tmp = new
|
|
2430
|
+
var tmp = new BN8(null);
|
|
2431
2431
|
tmp.words = new Array(Math.ceil(this.n / 13));
|
|
2432
2432
|
return tmp;
|
|
2433
2433
|
};
|
|
@@ -2553,7 +2553,7 @@ var require_bn = __commonJS({
|
|
|
2553
2553
|
}
|
|
2554
2554
|
return num;
|
|
2555
2555
|
};
|
|
2556
|
-
|
|
2556
|
+
BN8._prime = function prime(name) {
|
|
2557
2557
|
if (primes[name]) return primes[name];
|
|
2558
2558
|
var prime2;
|
|
2559
2559
|
if (name === "k256") {
|
|
@@ -2572,7 +2572,7 @@ var require_bn = __commonJS({
|
|
|
2572
2572
|
};
|
|
2573
2573
|
function Red(m) {
|
|
2574
2574
|
if (typeof m === "string") {
|
|
2575
|
-
var prime =
|
|
2575
|
+
var prime = BN8._prime(m);
|
|
2576
2576
|
this.m = prime.p;
|
|
2577
2577
|
this.prime = prime;
|
|
2578
2578
|
} else {
|
|
@@ -2658,7 +2658,7 @@ var require_bn = __commonJS({
|
|
|
2658
2658
|
var mod3 = this.m.andln(3);
|
|
2659
2659
|
assert(mod3 % 2 === 1);
|
|
2660
2660
|
if (mod3 === 3) {
|
|
2661
|
-
var pow2 = this.m.add(new
|
|
2661
|
+
var pow2 = this.m.add(new BN8(1)).iushrn(2);
|
|
2662
2662
|
return this.pow(a, pow2);
|
|
2663
2663
|
}
|
|
2664
2664
|
var q = this.m.subn(1);
|
|
@@ -2668,11 +2668,11 @@ var require_bn = __commonJS({
|
|
|
2668
2668
|
q.iushrn(1);
|
|
2669
2669
|
}
|
|
2670
2670
|
assert(!q.isZero());
|
|
2671
|
-
var one = new
|
|
2671
|
+
var one = new BN8(1).toRed(this);
|
|
2672
2672
|
var nOne = one.redNeg();
|
|
2673
2673
|
var lpow = this.m.subn(1).iushrn(1);
|
|
2674
2674
|
var z = this.m.bitLength();
|
|
2675
|
-
z = new
|
|
2675
|
+
z = new BN8(2 * z * z).toRed(this);
|
|
2676
2676
|
while (this.pow(z, lpow).cmp(nOne) !== 0) {
|
|
2677
2677
|
z.redIAdd(nOne);
|
|
2678
2678
|
}
|
|
@@ -2686,7 +2686,7 @@ var require_bn = __commonJS({
|
|
|
2686
2686
|
tmp = tmp.redSqr();
|
|
2687
2687
|
}
|
|
2688
2688
|
assert(i < m);
|
|
2689
|
-
var b = this.pow(c, new
|
|
2689
|
+
var b = this.pow(c, new BN8(1).iushln(m - i - 1));
|
|
2690
2690
|
r = r.redMul(b);
|
|
2691
2691
|
c = b.redSqr();
|
|
2692
2692
|
t = t.redMul(c);
|
|
@@ -2704,11 +2704,11 @@ var require_bn = __commonJS({
|
|
|
2704
2704
|
}
|
|
2705
2705
|
};
|
|
2706
2706
|
Red.prototype.pow = function pow2(a, num) {
|
|
2707
|
-
if (num.isZero()) return new
|
|
2707
|
+
if (num.isZero()) return new BN8(1).toRed(this);
|
|
2708
2708
|
if (num.cmpn(1) === 0) return a.clone();
|
|
2709
2709
|
var windowSize = 4;
|
|
2710
2710
|
var wnd = new Array(1 << windowSize);
|
|
2711
|
-
wnd[0] = new
|
|
2711
|
+
wnd[0] = new BN8(1).toRed(this);
|
|
2712
2712
|
wnd[1] = a;
|
|
2713
2713
|
for (var i = 2; i < wnd.length; i++) {
|
|
2714
2714
|
wnd[i] = this.mul(wnd[i - 1], a);
|
|
@@ -2752,7 +2752,7 @@ var require_bn = __commonJS({
|
|
|
2752
2752
|
res.red = null;
|
|
2753
2753
|
return res;
|
|
2754
2754
|
};
|
|
2755
|
-
|
|
2755
|
+
BN8.mont = function mont(num) {
|
|
2756
2756
|
return new Mont(num);
|
|
2757
2757
|
};
|
|
2758
2758
|
function Mont(m) {
|
|
@@ -2761,7 +2761,7 @@ var require_bn = __commonJS({
|
|
|
2761
2761
|
if (this.shift % 26 !== 0) {
|
|
2762
2762
|
this.shift += 26 - this.shift % 26;
|
|
2763
2763
|
}
|
|
2764
|
-
this.r = new
|
|
2764
|
+
this.r = new BN8(1).iushln(this.shift);
|
|
2765
2765
|
this.r2 = this.imod(this.r.sqr());
|
|
2766
2766
|
this.rinv = this.r._invmp(this.m);
|
|
2767
2767
|
this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
|
|
@@ -2795,7 +2795,7 @@ var require_bn = __commonJS({
|
|
|
2795
2795
|
return res._forceRed(this);
|
|
2796
2796
|
};
|
|
2797
2797
|
Mont.prototype.mul = function mul2(a, b) {
|
|
2798
|
-
if (a.isZero() || b.isZero()) return new
|
|
2798
|
+
if (a.isZero() || b.isZero()) return new BN8(0)._forceRed(this);
|
|
2799
2799
|
var t = a.mul(b);
|
|
2800
2800
|
var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
|
|
2801
2801
|
var u = t.isub(c).iushrn(this.shift);
|
|
@@ -6043,12 +6043,12 @@ var Bluemove = class {
|
|
|
6043
6043
|
// src/transaction/deepbook_v3.ts
|
|
6044
6044
|
var DeepbookV3 = class {
|
|
6045
6045
|
constructor(env) {
|
|
6046
|
-
this.deepbookV3Config = env === 0 /* Mainnet */ ? "
|
|
6046
|
+
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x699d455ab8c5e02075b4345ea1f91be55bf46064ae6026cc2528e701ce3ac135" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6047
6047
|
}
|
|
6048
6048
|
swap(client, txb, path, inputCoin, packages, deepbookv3DeepFee) {
|
|
6049
6049
|
return __async(this, null, function* () {
|
|
6050
6050
|
const { direction, from, target } = path;
|
|
6051
|
-
const [func, coinAType, coinBType] = direction ? ["
|
|
6051
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6052
6052
|
let deepFee;
|
|
6053
6053
|
if (deepbookv3DeepFee) {
|
|
6054
6054
|
deepFee = deepbookv3DeepFee;
|
|
@@ -6481,6 +6481,36 @@ var Obric = class {
|
|
|
6481
6481
|
}
|
|
6482
6482
|
};
|
|
6483
6483
|
|
|
6484
|
+
// src/transaction/hawal.ts
|
|
6485
|
+
var HaWAL = class {
|
|
6486
|
+
constructor(env) {
|
|
6487
|
+
if (env !== 0 /* Mainnet */) {
|
|
6488
|
+
throw new Error("HaWAL only supported on mainnet");
|
|
6489
|
+
}
|
|
6490
|
+
this.staking = env === 0 /* Mainnet */ ? "0x10b9d30c28448939ce6c4d6c6e0ffce4a7f8a4ada8248bdad09ef8b70e4a3904" : "0x0";
|
|
6491
|
+
this.validator = env === 0 /* Mainnet */ ? "0x7b3ba6de2ae58283f60d5b8dc04bb9e90e4796b3b2e0dea75569f491275242e7" : "0x0";
|
|
6492
|
+
}
|
|
6493
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6494
|
+
return __async(this, null, function* () {
|
|
6495
|
+
const { direction } = path;
|
|
6496
|
+
const func = direction ? "swap_a2b" : "swap_b2a";
|
|
6497
|
+
const args = [
|
|
6498
|
+
txb.object(this.staking),
|
|
6499
|
+
txb.object(path.id),
|
|
6500
|
+
inputCoin,
|
|
6501
|
+
txb.object(this.validator)
|
|
6502
|
+
];
|
|
6503
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6504
|
+
const res = txb.moveCall({
|
|
6505
|
+
target: `${publishedAt}::hawal::${func}`,
|
|
6506
|
+
typeArguments: [],
|
|
6507
|
+
arguments: args
|
|
6508
|
+
});
|
|
6509
|
+
return res;
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6512
|
+
};
|
|
6513
|
+
|
|
6484
6514
|
// src/client.ts
|
|
6485
6515
|
var CETUS = "CETUS";
|
|
6486
6516
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6504,6 +6534,7 @@ var SPRINGSUI = "SPRINGSUI";
|
|
|
6504
6534
|
var STEAMM = "STEAMM";
|
|
6505
6535
|
var METASTABLE = "METASTABLE";
|
|
6506
6536
|
var OBRIC = "OBRIC";
|
|
6537
|
+
var HAWAL = "HAWAL";
|
|
6507
6538
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6508
6539
|
function isBuilderRouterSwapParams(params) {
|
|
6509
6540
|
return Array.isArray(params.routers);
|
|
@@ -6513,7 +6544,7 @@ function isBuilderFastRouterSwapParams(params) {
|
|
|
6513
6544
|
}
|
|
6514
6545
|
var _AggregatorClient = class _AggregatorClient {
|
|
6515
6546
|
constructor(params) {
|
|
6516
|
-
var _a;
|
|
6547
|
+
var _a, _b;
|
|
6517
6548
|
this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
|
|
6518
6549
|
this.client = params.client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
6519
6550
|
this.signer = params.signer || "";
|
|
@@ -6527,6 +6558,17 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6527
6558
|
config2.wormholeStateId
|
|
6528
6559
|
);
|
|
6529
6560
|
this.apiKey = params.apiKey || "";
|
|
6561
|
+
this.partner = params.partner;
|
|
6562
|
+
if (params.overlayFeeRate) {
|
|
6563
|
+
if (params.overlayFeeRate > 0 && params.overlayFeeRate <= 0.01) {
|
|
6564
|
+
this.overlayFeeRate = params.overlayFeeRate * 1e6;
|
|
6565
|
+
} else {
|
|
6566
|
+
throw new Error("Overlay fee rate must be between 0 and 0.01");
|
|
6567
|
+
}
|
|
6568
|
+
} else {
|
|
6569
|
+
this.overlayFeeRate = 0;
|
|
6570
|
+
}
|
|
6571
|
+
this.overlayFeeReceiver = (_b = params.overlayFeeReceiver) != null ? _b : "0x0";
|
|
6530
6572
|
}
|
|
6531
6573
|
newPythClients(pythUrls) {
|
|
6532
6574
|
if (!pythUrls.includes("https://hermes.pyth.network")) {
|
|
@@ -6579,10 +6621,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6579
6621
|
}
|
|
6580
6622
|
findRouters(params) {
|
|
6581
6623
|
return __async(this, null, function* () {
|
|
6582
|
-
return getRouterResult(this.endpoint, this.apiKey, params);
|
|
6624
|
+
return getRouterResult(this.endpoint, this.apiKey, params, this.overlayFeeRate, this.overlayFeeReceiver);
|
|
6583
6625
|
});
|
|
6584
6626
|
}
|
|
6585
|
-
executeFlexibleInputSwap(txb, inputCoin, routers,
|
|
6627
|
+
executeFlexibleInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6586
6628
|
return __async(this, null, function* () {
|
|
6587
6629
|
if (routers.length === 0) {
|
|
6588
6630
|
throw new Error("No router found");
|
|
@@ -6624,21 +6666,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6624
6666
|
);
|
|
6625
6667
|
}
|
|
6626
6668
|
outputCoins.push(lastCoin);
|
|
6627
|
-
const
|
|
6628
|
-
this.
|
|
6669
|
+
const aggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6670
|
+
this.publishedAtV2Extend(),
|
|
6629
6671
|
packages
|
|
6630
6672
|
);
|
|
6631
6673
|
const mergedTargetCoin = this.checkCoinThresholdAndMergeCoin(
|
|
6632
6674
|
txb,
|
|
6633
6675
|
outputCoins,
|
|
6634
6676
|
outputCoinType,
|
|
6635
|
-
|
|
6636
|
-
|
|
6677
|
+
expectedAmountOut,
|
|
6678
|
+
amountLimit,
|
|
6679
|
+
aggregatorV2ExtendPublishedAt
|
|
6637
6680
|
);
|
|
6638
6681
|
return mergedTargetCoin;
|
|
6639
6682
|
});
|
|
6640
6683
|
}
|
|
6641
|
-
expectInputSwap(txb, inputCoin, routers,
|
|
6684
|
+
expectInputSwap(txb, inputCoin, routers, expectedAmountOut, amountLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6642
6685
|
return __async(this, null, function* () {
|
|
6643
6686
|
if (routers.length === 0) {
|
|
6644
6687
|
throw new Error("No router found");
|
|
@@ -6670,20 +6713,25 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6670
6713
|
this.publishedAtV2(),
|
|
6671
6714
|
packages
|
|
6672
6715
|
);
|
|
6716
|
+
const aggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6717
|
+
this.publishedAtV2Extend(),
|
|
6718
|
+
packages
|
|
6719
|
+
);
|
|
6673
6720
|
this.transferOrDestoryCoin(
|
|
6674
6721
|
txb,
|
|
6675
6722
|
inputCoin,
|
|
6676
6723
|
inputCoinType,
|
|
6677
|
-
|
|
6724
|
+
aggregatorV2PublishedAt
|
|
6678
6725
|
);
|
|
6679
|
-
const
|
|
6726
|
+
const mergedTargetCoins = this.checkCoinThresholdAndMergeCoin(
|
|
6680
6727
|
txb,
|
|
6681
6728
|
outputCoins,
|
|
6682
6729
|
outputCoinType,
|
|
6683
|
-
|
|
6684
|
-
|
|
6730
|
+
expectedAmountOut,
|
|
6731
|
+
amountLimit,
|
|
6732
|
+
aggregatorV2ExtendPublishedAt
|
|
6685
6733
|
);
|
|
6686
|
-
return
|
|
6734
|
+
return mergedTargetCoins;
|
|
6687
6735
|
});
|
|
6688
6736
|
}
|
|
6689
6737
|
expectOutputSwap(txb, inputCoin, routers, partner, packages) {
|
|
@@ -6762,7 +6810,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6762
6810
|
}
|
|
6763
6811
|
routerSwap(params) {
|
|
6764
6812
|
return __async(this, null, function* () {
|
|
6765
|
-
const { routers, inputCoin, slippage, txb,
|
|
6813
|
+
const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
|
|
6814
|
+
if (slippage > 1 || slippage < 0) {
|
|
6815
|
+
throw new Error("Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)");
|
|
6816
|
+
}
|
|
6766
6817
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6767
6818
|
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6768
6819
|
const amountIn = routerData.reduce(
|
|
@@ -6773,8 +6824,18 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6773
6824
|
(acc, router) => acc.add(router.amountOut),
|
|
6774
6825
|
new import_bn5.default(0)
|
|
6775
6826
|
);
|
|
6827
|
+
let overlayFee = new import_bn5.default(0);
|
|
6828
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6829
|
+
if (byAmountIn) {
|
|
6830
|
+
overlayFee = amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6));
|
|
6831
|
+
} else {
|
|
6832
|
+
overlayFee = amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6));
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(overlayFee) : amountOut;
|
|
6836
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(overlayFee);
|
|
6776
6837
|
const amountLimit = CalculateAmountLimitBN(
|
|
6777
|
-
byAmountIn ?
|
|
6838
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6778
6839
|
byAmountIn,
|
|
6779
6840
|
slippage
|
|
6780
6841
|
);
|
|
@@ -6790,16 +6851,23 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6790
6851
|
txb,
|
|
6791
6852
|
inputCoin,
|
|
6792
6853
|
routerData,
|
|
6793
|
-
|
|
6854
|
+
amountOut.toString(),
|
|
6855
|
+
amountLimit.toString(),
|
|
6794
6856
|
priceInfoObjectIds,
|
|
6795
|
-
partner,
|
|
6857
|
+
partner != null ? partner : this.partner,
|
|
6796
6858
|
deepbookv3DeepFee,
|
|
6797
6859
|
packages
|
|
6798
6860
|
);
|
|
6799
6861
|
return targetCoin2;
|
|
6800
6862
|
}
|
|
6863
|
+
const overlayFeeCoin = txb.splitCoins(inputCoin, [
|
|
6864
|
+
overlayFee.toString()
|
|
6865
|
+
]);
|
|
6866
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6867
|
+
txb.transferObjects([overlayFeeCoin], this.overlayFeeReceiver);
|
|
6868
|
+
}
|
|
6801
6869
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6802
|
-
amountLimit.toString()
|
|
6870
|
+
amountLimit.sub(overlayFee).toString()
|
|
6803
6871
|
]);
|
|
6804
6872
|
this.transferOrDestoryCoin(
|
|
6805
6873
|
txb,
|
|
@@ -6811,14 +6879,14 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6811
6879
|
txb,
|
|
6812
6880
|
splitedInputCoins[0],
|
|
6813
6881
|
routerData,
|
|
6814
|
-
partner
|
|
6882
|
+
partner != null ? partner : this.partner
|
|
6815
6883
|
);
|
|
6816
6884
|
return targetCoin;
|
|
6817
6885
|
});
|
|
6818
6886
|
}
|
|
6819
6887
|
fixableRouterSwap(params) {
|
|
6820
6888
|
return __async(this, null, function* () {
|
|
6821
|
-
const { routers, inputCoin, slippage, txb,
|
|
6889
|
+
const { routers, inputCoin, slippage, txb, deepbookv3DeepFee, partner } = params;
|
|
6822
6890
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6823
6891
|
const byAmountIn = params.routers.byAmountIn;
|
|
6824
6892
|
const amountIn = routerData.reduce(
|
|
@@ -6829,16 +6897,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6829
6897
|
(acc, router) => acc.add(router.amountOut),
|
|
6830
6898
|
new import_bn5.default(0)
|
|
6831
6899
|
);
|
|
6900
|
+
let overlayFee = 0;
|
|
6901
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6902
|
+
if (byAmountIn) {
|
|
6903
|
+
overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6904
|
+
} else {
|
|
6905
|
+
overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
|
|
6909
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(new import_bn5.default(overlayFee));
|
|
6832
6910
|
const amountLimit = CalculateAmountLimitBN(
|
|
6833
|
-
byAmountIn ?
|
|
6911
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6834
6912
|
byAmountIn,
|
|
6835
6913
|
slippage
|
|
6836
6914
|
);
|
|
6837
6915
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6838
|
-
getAggregatorV2PublishedAt(
|
|
6839
|
-
this.publishedAtV2(),
|
|
6840
|
-
packages
|
|
6841
|
-
);
|
|
6842
6916
|
const priceIDs = findPythPriceIDs(routerData);
|
|
6843
6917
|
const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
|
|
6844
6918
|
if (byAmountIn) {
|
|
@@ -6846,9 +6920,10 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6846
6920
|
txb,
|
|
6847
6921
|
inputCoin,
|
|
6848
6922
|
routerData,
|
|
6849
|
-
|
|
6923
|
+
expectedAmountOut.toString(),
|
|
6924
|
+
amountLimit.toString(),
|
|
6850
6925
|
priceInfoObjectIds,
|
|
6851
|
-
partner,
|
|
6926
|
+
partner != null ? partner : this.partner,
|
|
6852
6927
|
deepbookv3DeepFee,
|
|
6853
6928
|
packages
|
|
6854
6929
|
);
|
|
@@ -6858,7 +6933,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6858
6933
|
txb,
|
|
6859
6934
|
inputCoin,
|
|
6860
6935
|
routerData,
|
|
6861
|
-
partner
|
|
6936
|
+
partner != null ? partner : this.partner
|
|
6862
6937
|
);
|
|
6863
6938
|
return targetCoin;
|
|
6864
6939
|
});
|
|
@@ -6888,12 +6963,22 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6888
6963
|
new import_bn5.default(0)
|
|
6889
6964
|
);
|
|
6890
6965
|
const byAmountIn = isBuilderFastRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6966
|
+
let overlayFee = 0;
|
|
6967
|
+
if (this.overlayFeeRate > 0 && this.overlayFeeReceiver !== "0x0") {
|
|
6968
|
+
if (byAmountIn) {
|
|
6969
|
+
overlayFee = Number(amountOut.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6970
|
+
} else {
|
|
6971
|
+
overlayFee = Number(amountIn.mul(new import_bn5.default(this.overlayFeeRate)).div(new import_bn5.default(1e6)).toString());
|
|
6972
|
+
}
|
|
6973
|
+
}
|
|
6974
|
+
const expectedAmountOut = byAmountIn ? amountOut.sub(new import_bn5.default(overlayFee)) : amountOut;
|
|
6975
|
+
const expectedAmountIn = byAmountIn ? amountIn : amountIn.add(new import_bn5.default(overlayFee));
|
|
6891
6976
|
const amountLimit = CalculateAmountLimit(
|
|
6892
|
-
byAmountIn ?
|
|
6977
|
+
byAmountIn ? expectedAmountOut : expectedAmountIn,
|
|
6893
6978
|
byAmountIn,
|
|
6894
6979
|
slippage
|
|
6895
6980
|
);
|
|
6896
|
-
const amount = byAmountIn ?
|
|
6981
|
+
const amount = byAmountIn ? expectedAmountIn : amountLimit;
|
|
6897
6982
|
const buildFromCoinRes = buildInputCoin(
|
|
6898
6983
|
txb,
|
|
6899
6984
|
fromCoins,
|
|
@@ -6916,7 +7001,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6916
7001
|
slippage,
|
|
6917
7002
|
byAmountIn,
|
|
6918
7003
|
txb,
|
|
6919
|
-
partner,
|
|
7004
|
+
partner: partner != null ? partner : this.partner,
|
|
6920
7005
|
deepbookv3DeepFee: deepCoin
|
|
6921
7006
|
} : {
|
|
6922
7007
|
routers: params.routers,
|
|
@@ -6924,7 +7009,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6924
7009
|
slippage,
|
|
6925
7010
|
byAmountIn,
|
|
6926
7011
|
txb,
|
|
6927
|
-
partner,
|
|
7012
|
+
partner: partner != null ? partner : this.partner,
|
|
6928
7013
|
deepbookv3DeepFee: deepCoin
|
|
6929
7014
|
};
|
|
6930
7015
|
const targetCoin = yield this.routerSwap(routerSwapParams);
|
|
@@ -6966,7 +7051,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6966
7051
|
// Include deepbookv3, scallop, bluefin
|
|
6967
7052
|
publishedAtV2Extend() {
|
|
6968
7053
|
if (this.env === 0 /* Mainnet */) {
|
|
6969
|
-
return "
|
|
7054
|
+
return "0x39402d188b7231036e52266ebafad14413b4bf3daea4ac17115989444e6cd516";
|
|
6970
7055
|
} else {
|
|
6971
7056
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6972
7057
|
}
|
|
@@ -6985,7 +7070,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6985
7070
|
arguments: [coin]
|
|
6986
7071
|
});
|
|
6987
7072
|
}
|
|
6988
|
-
checkCoinThresholdAndMergeCoin(txb, coins, coinType,
|
|
7073
|
+
checkCoinThresholdAndMergeCoin(txb, coins, coinType, expectedAmountOut, threshold, aggregatorV2ExtendPublishedAt) {
|
|
6989
7074
|
let targetCoin = coins[0];
|
|
6990
7075
|
if (coins.length > 1) {
|
|
6991
7076
|
let vec = txb.makeMoveVec({ elements: coins.slice(1) });
|
|
@@ -6996,11 +7081,29 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6996
7081
|
});
|
|
6997
7082
|
targetCoin = coins[0];
|
|
6998
7083
|
}
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7084
|
+
if (this.overlayFeeRate === 0 || this.overlayFeeReceiver === "0x0") {
|
|
7085
|
+
txb.moveCall({
|
|
7086
|
+
target: `${aggregatorV2ExtendPublishedAt}::utils::check_coin_threshold_v1`,
|
|
7087
|
+
typeArguments: [coinType],
|
|
7088
|
+
arguments: [
|
|
7089
|
+
targetCoin,
|
|
7090
|
+
txb.pure.u64(expectedAmountOut),
|
|
7091
|
+
txb.pure.u64(threshold)
|
|
7092
|
+
]
|
|
7093
|
+
});
|
|
7094
|
+
} else {
|
|
7095
|
+
txb.moveCall({
|
|
7096
|
+
target: `${aggregatorV2ExtendPublishedAt}::utils::check_coin_threshold_v2`,
|
|
7097
|
+
typeArguments: [coinType],
|
|
7098
|
+
arguments: [
|
|
7099
|
+
targetCoin,
|
|
7100
|
+
txb.pure.u64(expectedAmountOut),
|
|
7101
|
+
txb.pure.u64(threshold),
|
|
7102
|
+
txb.pure.u64(this.overlayFeeRate),
|
|
7103
|
+
txb.pure.address(this.overlayFeeReceiver)
|
|
7104
|
+
]
|
|
7105
|
+
});
|
|
7106
|
+
}
|
|
7004
7107
|
return targetCoin;
|
|
7005
7108
|
}
|
|
7006
7109
|
newDex(provider, pythPriceIDs, partner) {
|
|
@@ -7049,6 +7152,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7049
7152
|
return new Metastable(this.env, pythPriceIDs);
|
|
7050
7153
|
case OBRIC:
|
|
7051
7154
|
return new Obric(this.env, pythPriceIDs);
|
|
7155
|
+
case HAWAL:
|
|
7156
|
+
return new HaWAL(this.env);
|
|
7052
7157
|
default:
|
|
7053
7158
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7054
7159
|
}
|
|
@@ -7142,7 +7247,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7142
7247
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7143
7248
|
}
|
|
7144
7249
|
};
|
|
7145
|
-
var
|
|
7250
|
+
var AggregatorClient23 = _AggregatorClient;
|
|
7146
7251
|
function findPythPriceIDs(routes) {
|
|
7147
7252
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7148
7253
|
for (const route of routes) {
|
|
@@ -7317,8 +7422,9 @@ function processEndpoint(endpoint) {
|
|
|
7317
7422
|
}
|
|
7318
7423
|
|
|
7319
7424
|
// src/api.ts
|
|
7320
|
-
var
|
|
7321
|
-
|
|
7425
|
+
var import_bn7 = __toESM(require_bn());
|
|
7426
|
+
var SDK_VERSION = 1000600;
|
|
7427
|
+
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7322
7428
|
return __async(this, null, function* () {
|
|
7323
7429
|
let response;
|
|
7324
7430
|
if (params.liquidityChanges && params.liquidityChanges.length > 0) {
|
|
@@ -7365,6 +7471,17 @@ function getRouterResult(endpoint, apiKey, params) {
|
|
|
7365
7471
|
}
|
|
7366
7472
|
if (data.data != null) {
|
|
7367
7473
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7474
|
+
if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
|
|
7475
|
+
if (params.byAmountIn) {
|
|
7476
|
+
const overlayFeeAmount = res.amountOut.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
|
|
7477
|
+
res.overlayFee = Number(overlayFeeAmount.toString());
|
|
7478
|
+
res.amountOut = res.amountOut.sub(overlayFeeAmount);
|
|
7479
|
+
} else {
|
|
7480
|
+
const overlayFeeAmount = res.amountIn.mul(new import_bn7.default(overlayFee)).div(new import_bn7.default(1e6));
|
|
7481
|
+
res.overlayFee = Number(overlayFeeAmount.toString());
|
|
7482
|
+
res.amountIn = res.amountIn.add(overlayFeeAmount);
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7368
7485
|
return res;
|
|
7369
7486
|
}
|
|
7370
7487
|
return {
|
|
@@ -7510,4 +7627,4 @@ decimal.js/decimal.mjs:
|
|
|
7510
7627
|
*)
|
|
7511
7628
|
*/
|
|
7512
7629
|
|
|
7513
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI,
|
|
7630
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient23 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, HAWAL, KRIYA, KRIYAV3, METASTABLE, OBRIC, ONE, SCALLOP, SPRINGSUI, STEAMM, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|