@ape.swap/bonds-sdk 4.1.3-test.41 → 4.2.0-test.1

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.
Files changed (56) hide show
  1. package/dist/main.js +586 -16
  2. package/dist/utils/convertToTokenValue.d.ts +1 -2
  3. package/package.json +1 -1
  4. package/dist/config/abi/types/Banana.d.ts +0 -394
  5. package/dist/config/abi/types/Bond.d.ts +0 -758
  6. package/dist/config/abi/types/BondNft.d.ts +0 -556
  7. package/dist/config/abi/types/EnsPublicResolver.d.ts +0 -437
  8. package/dist/config/abi/types/EnsRegistrar.d.ts +0 -254
  9. package/dist/config/abi/types/Erc20.d.ts +0 -156
  10. package/dist/config/abi/types/Erc20_bytes32.d.ts +0 -50
  11. package/dist/config/abi/types/JungleChef.d.ts +0 -245
  12. package/dist/config/abi/types/LaunchBonds.d.ts +0 -1306
  13. package/dist/config/abi/types/LensContract.d.ts +0 -276
  14. package/dist/config/abi/types/LockVeAbond.d.ts +0 -1173
  15. package/dist/config/abi/types/MigrationBond.d.ts +0 -1074
  16. package/dist/config/abi/types/MigrationFveAbond.d.ts +0 -284
  17. package/dist/config/abi/types/MiniComplexRewarder.d.ts +0 -423
  18. package/dist/config/abi/types/Multicallv2.d.ts +0 -139
  19. package/dist/config/abi/types/Multicallv3.d.ts +0 -98
  20. package/dist/config/abi/types/NonFungibleApes.d.ts +0 -492
  21. package/dist/config/abi/types/NonFungibleBananas.d.ts +0 -468
  22. package/dist/config/abi/types/PriceGetter.d.ts +0 -676
  23. package/dist/config/abi/types/PriceGetterLinea.d.ts +0 -756
  24. package/dist/config/abi/types/PriceGetterV2.d.ts +0 -692
  25. package/dist/config/abi/types/SousChef.d.ts +0 -542
  26. package/dist/config/abi/types/Treasury.d.ts +0 -274
  27. package/dist/config/abi/types/Weth.d.ts +0 -206
  28. package/dist/config/abi/types/Zap.d.ts +0 -484
  29. package/dist/config/abi/types/common.d.ts +0 -22
  30. package/dist/config/abi/types/factories/Banana__factory.d.ts +0 -475
  31. package/dist/config/abi/types/factories/BondNft__factory.d.ts +0 -723
  32. package/dist/config/abi/types/factories/Bond__factory.d.ts +0 -799
  33. package/dist/config/abi/types/factories/EnsPublicResolver__factory.d.ts +0 -649
  34. package/dist/config/abi/types/factories/EnsRegistrar__factory.d.ts +0 -338
  35. package/dist/config/abi/types/factories/Erc20__factory.d.ts +0 -175
  36. package/dist/config/abi/types/factories/Erc20_bytes32__factory.d.ts +0 -30
  37. package/dist/config/abi/types/factories/JungleChef__factory.d.ts +0 -247
  38. package/dist/config/abi/types/factories/LaunchBonds__factory.d.ts +0 -1560
  39. package/dist/config/abi/types/factories/LensContract__factory.d.ts +0 -254
  40. package/dist/config/abi/types/factories/LockVeAbond__factory.d.ts +0 -1698
  41. package/dist/config/abi/types/factories/MigrationBond__factory.d.ts +0 -1268
  42. package/dist/config/abi/types/factories/MigrationFveAbond__factory.d.ts +0 -262
  43. package/dist/config/abi/types/factories/MiniComplexRewarder__factory.d.ts +0 -448
  44. package/dist/config/abi/types/factories/Multicallv2__factory.d.ts +0 -115
  45. package/dist/config/abi/types/factories/Multicallv3__factory.d.ts +0 -76
  46. package/dist/config/abi/types/factories/NonFungibleApes__factory.d.ts +0 -617
  47. package/dist/config/abi/types/factories/NonFungibleBananas__factory.d.ts +0 -576
  48. package/dist/config/abi/types/factories/PriceGetterLinea__factory.d.ts +0 -1105
  49. package/dist/config/abi/types/factories/PriceGetterV2__factory.d.ts +0 -1027
  50. package/dist/config/abi/types/factories/PriceGetter__factory.d.ts +0 -999
  51. package/dist/config/abi/types/factories/SousChef__factory.d.ts +0 -511
  52. package/dist/config/abi/types/factories/Treasury__factory.d.ts +0 -235
  53. package/dist/config/abi/types/factories/Weth__factory.d.ts +0 -220
  54. package/dist/config/abi/types/factories/Zap__factory.d.ts +0 -695
  55. package/dist/config/abi/types/factories/index.d.ts +0 -25
  56. package/dist/config/abi/types/index.d.ts +0 -51
package/dist/main.js CHANGED
@@ -22463,8 +22463,8 @@ function zeroPadBytes(data, length) {
22463
22463
  *
22464
22464
  * @_subsection: api/utils:Math Helpers [about-maths]
22465
22465
  */
22466
- const BN_0$8 = BigInt(0);
22467
- const BN_1$3 = BigInt(1);
22466
+ const BN_0$9 = BigInt(0);
22467
+ const BN_1$4 = BigInt(1);
22468
22468
  //const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
22469
22469
  // IEEE 754 support 53-bits of mantissa
22470
22470
  const maxValue = 0x1fffffffffffff;
@@ -22477,13 +22477,13 @@ const maxValue = 0x1fffffffffffff;
22477
22477
  function fromTwos(_value, _width) {
22478
22478
  const value = getUint(_value, "value");
22479
22479
  const width = BigInt(getNumber(_width, "width"));
22480
- assert((value >> width) === BN_0$8, "overflow", "NUMERIC_FAULT", {
22480
+ assert((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
22481
22481
  operation: "fromTwos", fault: "overflow", value: _value
22482
22482
  });
22483
22483
  // Top bit set; treat as a negative value
22484
- if (value >> (width - BN_1$3)) {
22485
- const mask = (BN_1$3 << width) - BN_1$3;
22486
- return -(((~value) & mask) + BN_1$3);
22484
+ if (value >> (width - BN_1$4)) {
22485
+ const mask = (BN_1$4 << width) - BN_1$4;
22486
+ return -(((~value) & mask) + BN_1$4);
22487
22487
  }
22488
22488
  return value;
22489
22489
  }
@@ -22496,14 +22496,14 @@ function fromTwos(_value, _width) {
22496
22496
  function toTwos(_value, _width) {
22497
22497
  let value = getBigInt(_value, "value");
22498
22498
  const width = BigInt(getNumber(_width, "width"));
22499
- const limit = (BN_1$3 << (width - BN_1$3));
22500
- if (value < BN_0$8) {
22499
+ const limit = (BN_1$4 << (width - BN_1$4));
22500
+ if (value < BN_0$9) {
22501
22501
  value = -value;
22502
22502
  assert(value <= limit, "too low", "NUMERIC_FAULT", {
22503
22503
  operation: "toTwos", fault: "overflow", value: _value
22504
22504
  });
22505
- const mask = (BN_1$3 << width) - BN_1$3;
22506
- return ((~value) & mask) + BN_1$3;
22505
+ const mask = (BN_1$4 << width) - BN_1$4;
22506
+ return ((~value) & mask) + BN_1$4;
22507
22507
  }
22508
22508
  else {
22509
22509
  assert(value < limit, "too high", "NUMERIC_FAULT", {
@@ -22518,7 +22518,7 @@ function toTwos(_value, _width) {
22518
22518
  function mask(_value, _bits) {
22519
22519
  const value = getUint(_value, "value");
22520
22520
  const bits = BigInt(getNumber(_bits, "bits"));
22521
- return value & ((BN_1$3 << bits) - BN_1$3);
22521
+ return value & ((BN_1$4 << bits) - BN_1$4);
22522
22522
  }
22523
22523
  /**
22524
22524
  * Gets a BigInt from %%value%%. If it is an invalid value for
@@ -22553,7 +22553,7 @@ function getBigInt(value, name) {
22553
22553
  */
22554
22554
  function getUint(value, name) {
22555
22555
  const result = getBigInt(value, name);
22556
- assert(result >= BN_0$8, "unsigned value cannot be negative", "NUMERIC_FAULT", {
22556
+ assert(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
22557
22557
  fault: "overflow", operation: "getUint", value
22558
22558
  });
22559
22559
  return result;
@@ -22639,7 +22639,7 @@ function toBeHex(_value, _width) {
22639
22639
  */
22640
22640
  function toBeArray(_value) {
22641
22641
  const value = getUint(_value, "value");
22642
- if (value === BN_0$8) {
22642
+ if (value === BN_0$9) {
22643
22643
  return new Uint8Array([]);
22644
22644
  }
22645
22645
  let hex = value.toString(16);
@@ -23956,6 +23956,526 @@ function wait(delay) {
23956
23956
  return new Promise((resolve) => setTimeout(resolve, delay));
23957
23957
  }
23958
23958
 
23959
+ /**
23960
+ * The **FixedNumber** class permits using values with decimal places,
23961
+ * using fixed-pont math.
23962
+ *
23963
+ * Fixed-point math is still based on integers under-the-hood, but uses an
23964
+ * internal offset to store fractional components below, and each operation
23965
+ * corrects for this after each operation.
23966
+ *
23967
+ * @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
23968
+ */
23969
+ const BN_N1 = BigInt(-1);
23970
+ const BN_0$8 = BigInt(0);
23971
+ const BN_1$3 = BigInt(1);
23972
+ const BN_5 = BigInt(5);
23973
+ const _guard$3 = {};
23974
+ // Constant to pull zeros from for multipliers
23975
+ let Zeros$1 = "0000";
23976
+ while (Zeros$1.length < 80) {
23977
+ Zeros$1 += Zeros$1;
23978
+ }
23979
+ // Returns a string "1" followed by decimal "0"s
23980
+ function getTens(decimals) {
23981
+ let result = Zeros$1;
23982
+ while (result.length < decimals) {
23983
+ result += result;
23984
+ }
23985
+ return BigInt("1" + result.substring(0, decimals));
23986
+ }
23987
+ function checkValue(val, format, safeOp) {
23988
+ const width = BigInt(format.width);
23989
+ if (format.signed) {
23990
+ const limit = (BN_1$3 << (width - BN_1$3));
23991
+ assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
23992
+ operation: safeOp, fault: "overflow", value: val
23993
+ });
23994
+ if (val > BN_0$8) {
23995
+ val = fromTwos(mask(val, width), width);
23996
+ }
23997
+ else {
23998
+ val = -fromTwos(mask(-val, width), width);
23999
+ }
24000
+ }
24001
+ else {
24002
+ const limit = (BN_1$3 << width);
24003
+ assert(safeOp == null || (val >= 0 && val < limit), "overflow", "NUMERIC_FAULT", {
24004
+ operation: safeOp, fault: "overflow", value: val
24005
+ });
24006
+ val = (((val % limit) + limit) % limit) & (limit - BN_1$3);
24007
+ }
24008
+ return val;
24009
+ }
24010
+ function getFormat(value) {
24011
+ if (typeof (value) === "number") {
24012
+ value = `fixed128x${value}`;
24013
+ }
24014
+ let signed = true;
24015
+ let width = 128;
24016
+ let decimals = 18;
24017
+ if (typeof (value) === "string") {
24018
+ // Parse the format string
24019
+ if (value === "fixed") ;
24020
+ else if (value === "ufixed") {
24021
+ signed = false;
24022
+ }
24023
+ else {
24024
+ const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
24025
+ assertArgument(match, "invalid fixed format", "format", value);
24026
+ signed = (match[1] !== "u");
24027
+ width = parseInt(match[2]);
24028
+ decimals = parseInt(match[3]);
24029
+ }
24030
+ }
24031
+ else if (value) {
24032
+ // Extract the values from the object
24033
+ const v = value;
24034
+ const check = (key, type, defaultValue) => {
24035
+ if (v[key] == null) {
24036
+ return defaultValue;
24037
+ }
24038
+ assertArgument(typeof (v[key]) === type, "invalid fixed format (" + key + " not " + type + ")", "format." + key, v[key]);
24039
+ return v[key];
24040
+ };
24041
+ signed = check("signed", "boolean", signed);
24042
+ width = check("width", "number", width);
24043
+ decimals = check("decimals", "number", decimals);
24044
+ }
24045
+ assertArgument((width % 8) === 0, "invalid FixedNumber width (not byte aligned)", "format.width", width);
24046
+ assertArgument(decimals <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", decimals);
24047
+ const name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals);
24048
+ return { signed, width, decimals, name };
24049
+ }
24050
+ function toString$2(val, decimals) {
24051
+ let negative = "";
24052
+ if (val < BN_0$8) {
24053
+ negative = "-";
24054
+ val *= BN_N1;
24055
+ }
24056
+ let str = val.toString();
24057
+ // No decimal point for whole values
24058
+ if (decimals === 0) {
24059
+ return (negative + str);
24060
+ }
24061
+ // Pad out to the whole component (including a whole digit)
24062
+ while (str.length <= decimals) {
24063
+ str = Zeros$1 + str;
24064
+ }
24065
+ // Insert the decimal point
24066
+ const index = str.length - decimals;
24067
+ str = str.substring(0, index) + "." + str.substring(index);
24068
+ // Trim the whole component (leaving at least one 0)
24069
+ while (str[0] === "0" && str[1] !== ".") {
24070
+ str = str.substring(1);
24071
+ }
24072
+ // Trim the decimal component (leaving at least one 0)
24073
+ while (str[str.length - 1] === "0" && str[str.length - 2] !== ".") {
24074
+ str = str.substring(0, str.length - 1);
24075
+ }
24076
+ return (negative + str);
24077
+ }
24078
+ /**
24079
+ * A FixedNumber represents a value over its [[FixedFormat]]
24080
+ * arithmetic field.
24081
+ *
24082
+ * A FixedNumber can be used to perform math, losslessly, on
24083
+ * values which have decmial places.
24084
+ *
24085
+ * A FixedNumber has a fixed bit-width to store values in, and stores all
24086
+ * values internally by multiplying the value by 10 raised to the power of
24087
+ * %%decimals%%.
24088
+ *
24089
+ * If operations are performed that cause a value to grow too high (close to
24090
+ * positive infinity) or too low (close to negative infinity), the value
24091
+ * is said to //overflow//.
24092
+ *
24093
+ * For example, an 8-bit signed value, with 0 decimals may only be within
24094
+ * the range ``-128`` to ``127``; so ``-128 - 1`` will overflow and become
24095
+ * ``127``. Likewise, ``127 + 1`` will overflow and become ``-127``.
24096
+ *
24097
+ * Many operation have a normal and //unsafe// variant. The normal variant
24098
+ * will throw a [[NumericFaultError]] on any overflow, while the //unsafe//
24099
+ * variant will silently allow overflow, corrupting its value value.
24100
+ *
24101
+ * If operations are performed that cause a value to become too small
24102
+ * (close to zero), the value loses precison and is said to //underflow//.
24103
+ *
24104
+ * For example, a value with 1 decimal place may store a number as small
24105
+ * as ``0.1``, but the value of ``0.1 / 2`` is ``0.05``, which cannot fit
24106
+ * into 1 decimal place, so underflow occurs which means precision is lost
24107
+ * and the value becomes ``0``.
24108
+ *
24109
+ * Some operations have a normal and //signalling// variant. The normal
24110
+ * variant will silently ignore underflow, while the //signalling// variant
24111
+ * will thow a [[NumericFaultError]] on underflow.
24112
+ */
24113
+ class FixedNumber {
24114
+ /**
24115
+ * The specific fixed-point arithmetic field for this value.
24116
+ */
24117
+ format;
24118
+ #format;
24119
+ // The actual value (accounting for decimals)
24120
+ #val;
24121
+ // A base-10 value to multiple values by to maintain the magnitude
24122
+ #tens;
24123
+ /**
24124
+ * This is a property so console.log shows a human-meaningful value.
24125
+ *
24126
+ * @private
24127
+ */
24128
+ _value;
24129
+ // Use this when changing this file to get some typing info,
24130
+ // but then switch to any to mask the internal type
24131
+ //constructor(guard: any, value: bigint, format: _FixedFormat) {
24132
+ /**
24133
+ * @private
24134
+ */
24135
+ constructor(guard, value, format) {
24136
+ assertPrivate(guard, _guard$3, "FixedNumber");
24137
+ this.#val = value;
24138
+ this.#format = format;
24139
+ const _value = toString$2(value, format.decimals);
24140
+ defineProperties(this, { format: format.name, _value });
24141
+ this.#tens = getTens(format.decimals);
24142
+ }
24143
+ /**
24144
+ * If true, negative values are permitted, otherwise only
24145
+ * positive values and zero are allowed.
24146
+ */
24147
+ get signed() { return this.#format.signed; }
24148
+ /**
24149
+ * The number of bits available to store the value.
24150
+ */
24151
+ get width() { return this.#format.width; }
24152
+ /**
24153
+ * The number of decimal places in the fixed-point arithment field.
24154
+ */
24155
+ get decimals() { return this.#format.decimals; }
24156
+ /**
24157
+ * The value as an integer, based on the smallest unit the
24158
+ * [[decimals]] allow.
24159
+ */
24160
+ get value() { return this.#val; }
24161
+ #checkFormat(other) {
24162
+ assertArgument(this.format === other.format, "incompatible format; use fixedNumber.toFormat", "other", other);
24163
+ }
24164
+ #checkValue(val, safeOp) {
24165
+ /*
24166
+ const width = BigInt(this.width);
24167
+ if (this.signed) {
24168
+ const limit = (BN_1 << (width - BN_1));
24169
+ assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
24170
+ operation: <string>safeOp, fault: "overflow", value: val
24171
+ });
24172
+
24173
+ if (val > BN_0) {
24174
+ val = fromTwos(mask(val, width), width);
24175
+ } else {
24176
+ val = -fromTwos(mask(-val, width), width);
24177
+ }
24178
+
24179
+ } else {
24180
+ const masked = mask(val, width);
24181
+ assert(safeOp == null || (val >= 0 && val === masked), "overflow", "NUMERIC_FAULT", {
24182
+ operation: <string>safeOp, fault: "overflow", value: val
24183
+ });
24184
+ val = masked;
24185
+ }
24186
+ */
24187
+ val = checkValue(val, this.#format, safeOp);
24188
+ return new FixedNumber(_guard$3, val, this.#format);
24189
+ }
24190
+ #add(o, safeOp) {
24191
+ this.#checkFormat(o);
24192
+ return this.#checkValue(this.#val + o.#val, safeOp);
24193
+ }
24194
+ /**
24195
+ * Returns a new [[FixedNumber]] with the result of %%this%% added
24196
+ * to %%other%%, ignoring overflow.
24197
+ */
24198
+ addUnsafe(other) { return this.#add(other); }
24199
+ /**
24200
+ * Returns a new [[FixedNumber]] with the result of %%this%% added
24201
+ * to %%other%%. A [[NumericFaultError]] is thrown if overflow
24202
+ * occurs.
24203
+ */
24204
+ add(other) { return this.#add(other, "add"); }
24205
+ #sub(o, safeOp) {
24206
+ this.#checkFormat(o);
24207
+ return this.#checkValue(this.#val - o.#val, safeOp);
24208
+ }
24209
+ /**
24210
+ * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
24211
+ * from %%this%%, ignoring overflow.
24212
+ */
24213
+ subUnsafe(other) { return this.#sub(other); }
24214
+ /**
24215
+ * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
24216
+ * from %%this%%. A [[NumericFaultError]] is thrown if overflow
24217
+ * occurs.
24218
+ */
24219
+ sub(other) { return this.#sub(other, "sub"); }
24220
+ #mul(o, safeOp) {
24221
+ this.#checkFormat(o);
24222
+ return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp);
24223
+ }
24224
+ /**
24225
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
24226
+ * by %%other%%, ignoring overflow and underflow (precision loss).
24227
+ */
24228
+ mulUnsafe(other) { return this.#mul(other); }
24229
+ /**
24230
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
24231
+ * by %%other%%. A [[NumericFaultError]] is thrown if overflow
24232
+ * occurs.
24233
+ */
24234
+ mul(other) { return this.#mul(other, "mul"); }
24235
+ /**
24236
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
24237
+ * by %%other%%. A [[NumericFaultError]] is thrown if overflow
24238
+ * occurs or if underflow (precision loss) occurs.
24239
+ */
24240
+ mulSignal(other) {
24241
+ this.#checkFormat(other);
24242
+ const value = this.#val * other.#val;
24243
+ assert((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", {
24244
+ operation: "mulSignal", fault: "underflow", value: this
24245
+ });
24246
+ return this.#checkValue(value / this.#tens, "mulSignal");
24247
+ }
24248
+ #div(o, safeOp) {
24249
+ assert(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
24250
+ operation: "div", fault: "divide-by-zero", value: this
24251
+ });
24252
+ this.#checkFormat(o);
24253
+ return this.#checkValue((this.#val * this.#tens) / o.#val, safeOp);
24254
+ }
24255
+ /**
24256
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
24257
+ * by %%other%%, ignoring underflow (precision loss). A
24258
+ * [[NumericFaultError]] is thrown if overflow occurs.
24259
+ */
24260
+ divUnsafe(other) { return this.#div(other); }
24261
+ /**
24262
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
24263
+ * by %%other%%, ignoring underflow (precision loss). A
24264
+ * [[NumericFaultError]] is thrown if overflow occurs.
24265
+ */
24266
+ div(other) { return this.#div(other, "div"); }
24267
+ /**
24268
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
24269
+ * by %%other%%. A [[NumericFaultError]] is thrown if underflow
24270
+ * (precision loss) occurs.
24271
+ */
24272
+ divSignal(other) {
24273
+ assert(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
24274
+ operation: "div", fault: "divide-by-zero", value: this
24275
+ });
24276
+ this.#checkFormat(other);
24277
+ const value = (this.#val * this.#tens);
24278
+ assert((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", {
24279
+ operation: "divSignal", fault: "underflow", value: this
24280
+ });
24281
+ return this.#checkValue(value / other.#val, "divSignal");
24282
+ }
24283
+ /**
24284
+ * Returns a comparison result between %%this%% and %%other%%.
24285
+ *
24286
+ * This is suitable for use in sorting, where ``-1`` implies %%this%%
24287
+ * is smaller, ``1`` implies %%this%% is larger and ``0`` implies
24288
+ * both are equal.
24289
+ */
24290
+ cmp(other) {
24291
+ let a = this.value, b = other.value;
24292
+ // Coerce a and b to the same magnitude
24293
+ const delta = this.decimals - other.decimals;
24294
+ if (delta > 0) {
24295
+ b *= getTens(delta);
24296
+ }
24297
+ else if (delta < 0) {
24298
+ a *= getTens(-delta);
24299
+ }
24300
+ // Comnpare
24301
+ if (a < b) {
24302
+ return -1;
24303
+ }
24304
+ if (a > b) {
24305
+ return 1;
24306
+ }
24307
+ return 0;
24308
+ }
24309
+ /**
24310
+ * Returns true if %%other%% is equal to %%this%%.
24311
+ */
24312
+ eq(other) { return this.cmp(other) === 0; }
24313
+ /**
24314
+ * Returns true if %%other%% is less than to %%this%%.
24315
+ */
24316
+ lt(other) { return this.cmp(other) < 0; }
24317
+ /**
24318
+ * Returns true if %%other%% is less than or equal to %%this%%.
24319
+ */
24320
+ lte(other) { return this.cmp(other) <= 0; }
24321
+ /**
24322
+ * Returns true if %%other%% is greater than to %%this%%.
24323
+ */
24324
+ gt(other) { return this.cmp(other) > 0; }
24325
+ /**
24326
+ * Returns true if %%other%% is greater than or equal to %%this%%.
24327
+ */
24328
+ gte(other) { return this.cmp(other) >= 0; }
24329
+ /**
24330
+ * Returns a new [[FixedNumber]] which is the largest **integer**
24331
+ * that is less than or equal to %%this%%.
24332
+ *
24333
+ * The decimal component of the result will always be ``0``.
24334
+ */
24335
+ floor() {
24336
+ let val = this.#val;
24337
+ if (this.#val < BN_0$8) {
24338
+ val -= this.#tens - BN_1$3;
24339
+ }
24340
+ val = (this.#val / this.#tens) * this.#tens;
24341
+ return this.#checkValue(val, "floor");
24342
+ }
24343
+ /**
24344
+ * Returns a new [[FixedNumber]] which is the smallest **integer**
24345
+ * that is greater than or equal to %%this%%.
24346
+ *
24347
+ * The decimal component of the result will always be ``0``.
24348
+ */
24349
+ ceiling() {
24350
+ let val = this.#val;
24351
+ if (this.#val > BN_0$8) {
24352
+ val += this.#tens - BN_1$3;
24353
+ }
24354
+ val = (this.#val / this.#tens) * this.#tens;
24355
+ return this.#checkValue(val, "ceiling");
24356
+ }
24357
+ /**
24358
+ * Returns a new [[FixedNumber]] with the decimal component
24359
+ * rounded up on ties at %%decimals%% places.
24360
+ */
24361
+ round(decimals) {
24362
+ if (decimals == null) {
24363
+ decimals = 0;
24364
+ }
24365
+ // Not enough precision to not already be rounded
24366
+ if (decimals >= this.decimals) {
24367
+ return this;
24368
+ }
24369
+ const delta = this.decimals - decimals;
24370
+ const bump = BN_5 * getTens(delta - 1);
24371
+ let value = this.value + bump;
24372
+ const tens = getTens(delta);
24373
+ value = (value / tens) * tens;
24374
+ checkValue(value, this.#format, "round");
24375
+ return new FixedNumber(_guard$3, value, this.#format);
24376
+ }
24377
+ /**
24378
+ * Returns true if %%this%% is equal to ``0``.
24379
+ */
24380
+ isZero() { return (this.#val === BN_0$8); }
24381
+ /**
24382
+ * Returns true if %%this%% is less than ``0``.
24383
+ */
24384
+ isNegative() { return (this.#val < BN_0$8); }
24385
+ /**
24386
+ * Returns the string representation of %%this%%.
24387
+ */
24388
+ toString() { return this._value; }
24389
+ /**
24390
+ * Returns a float approximation.
24391
+ *
24392
+ * Due to IEEE 754 precission (or lack thereof), this function
24393
+ * can only return an approximation and most values will contain
24394
+ * rounding errors.
24395
+ */
24396
+ toUnsafeFloat() { return parseFloat(this.toString()); }
24397
+ /**
24398
+ * Return a new [[FixedNumber]] with the same value but has had
24399
+ * its field set to %%format%%.
24400
+ *
24401
+ * This will throw if the value cannot fit into %%format%%.
24402
+ */
24403
+ toFormat(format) {
24404
+ return FixedNumber.fromString(this.toString(), format);
24405
+ }
24406
+ /**
24407
+ * Creates a new [[FixedNumber]] for %%value%% divided by
24408
+ * %%decimal%% places with %%format%%.
24409
+ *
24410
+ * This will throw a [[NumericFaultError]] if %%value%% (once adjusted
24411
+ * for %%decimals%%) cannot fit in %%format%%, either due to overflow
24412
+ * or underflow (precision loss).
24413
+ */
24414
+ static fromValue(_value, _decimals, _format) {
24415
+ const decimals = (_decimals == null) ? 0 : getNumber(_decimals);
24416
+ const format = getFormat(_format);
24417
+ let value = getBigInt(_value, "value");
24418
+ const delta = decimals - format.decimals;
24419
+ if (delta > 0) {
24420
+ const tens = getTens(delta);
24421
+ assert((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", {
24422
+ operation: "fromValue", fault: "underflow", value: _value
24423
+ });
24424
+ value /= tens;
24425
+ }
24426
+ else if (delta < 0) {
24427
+ value *= getTens(-delta);
24428
+ }
24429
+ checkValue(value, format, "fromValue");
24430
+ return new FixedNumber(_guard$3, value, format);
24431
+ }
24432
+ /**
24433
+ * Creates a new [[FixedNumber]] for %%value%% with %%format%%.
24434
+ *
24435
+ * This will throw a [[NumericFaultError]] if %%value%% cannot fit
24436
+ * in %%format%%, either due to overflow or underflow (precision loss).
24437
+ */
24438
+ static fromString(_value, _format) {
24439
+ const match = _value.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
24440
+ assertArgument(match && (match[2].length + match[3].length) > 0, "invalid FixedNumber string value", "value", _value);
24441
+ const format = getFormat(_format);
24442
+ let whole = (match[2] || "0"), decimal = (match[3] || "");
24443
+ // Pad out the decimals
24444
+ while (decimal.length < format.decimals) {
24445
+ decimal += Zeros$1;
24446
+ }
24447
+ // Check precision is safe
24448
+ assert(decimal.substring(format.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
24449
+ operation: "fromString", fault: "underflow", value: _value
24450
+ });
24451
+ // Remove extra padding
24452
+ decimal = decimal.substring(0, format.decimals);
24453
+ const value = BigInt(match[1] + whole + decimal);
24454
+ checkValue(value, format, "fromString");
24455
+ return new FixedNumber(_guard$3, value, format);
24456
+ }
24457
+ /**
24458
+ * Creates a new [[FixedNumber]] with the big-endian representation
24459
+ * %%value%% with %%format%%.
24460
+ *
24461
+ * This will throw a [[NumericFaultError]] if %%value%% cannot fit
24462
+ * in %%format%% due to overflow.
24463
+ */
24464
+ static fromBytes(_value, _format) {
24465
+ let value = toBigInt(getBytes(_value, "value"));
24466
+ const format = getFormat(_format);
24467
+ if (format.signed) {
24468
+ value = fromTwos(value, format.width);
24469
+ }
24470
+ checkValue(value, format, "fromBytes");
24471
+ return new FixedNumber(_guard$3, value, format);
24472
+ }
24473
+ }
24474
+ //const f1 = FixedNumber.fromString("12.56", "fixed16x2");
24475
+ //const f2 = FixedNumber.fromString("0.3", "fixed16x2");
24476
+ //console.log(f1.divSignal(f2));
24477
+ //const BUMP = FixedNumber.from("0.5");
24478
+
23959
24479
  //See: https://github.com/ethereum/wiki/wiki/RLP
23960
24480
  function hexlifyByte(value) {
23961
24481
  let result = value.toString(16);
@@ -24080,6 +24600,55 @@ function encodeRlp(object) {
24080
24600
  return result;
24081
24601
  }
24082
24602
 
24603
+ /**
24604
+ * Most interactions with Ethereum requires integer values, which use
24605
+ * the smallest magnitude unit.
24606
+ *
24607
+ * For example, imagine dealing with dollars and cents. Since dollars
24608
+ * are divisible, non-integer values are possible, such as ``$10.77``.
24609
+ * By using the smallest indivisible unit (i.e. cents), the value can
24610
+ * be kept as the integer ``1077``.
24611
+ *
24612
+ * When receiving decimal input from the user (as a decimal string),
24613
+ * the value should be converted to an integer and when showing a user
24614
+ * a value, the integer value should be converted to a decimal string.
24615
+ *
24616
+ * This creates a clear distinction, between values to be used by code
24617
+ * (integers) and values used for display logic to users (decimals).
24618
+ *
24619
+ * The native unit in Ethereum, //ether// is divisible to 18 decimal places,
24620
+ * where each individual unit is called a //wei//.
24621
+ *
24622
+ * @_subsection api/utils:Unit Conversion [about-units]
24623
+ */
24624
+ const names$2 = [
24625
+ "wei",
24626
+ "kwei",
24627
+ "mwei",
24628
+ "gwei",
24629
+ "szabo",
24630
+ "finney",
24631
+ "ether",
24632
+ ];
24633
+ /**
24634
+ * Converts the //decimal string// %%value%% to a BigInt, assuming
24635
+ * %%unit%% decimal places. The %%unit%% may the number of decimal places
24636
+ * or the name of a unit (e.g. ``"gwei"`` for 9 decimal places).
24637
+ */
24638
+ function parseUnits$2(value, unit) {
24639
+ assertArgument(typeof (value) === "string", "value must be a string", "value", value);
24640
+ let decimals = 18;
24641
+ if (typeof (unit) === "string") {
24642
+ const index = names$2.indexOf(unit);
24643
+ assertArgument(index >= 0, "invalid unit", "unit", unit);
24644
+ decimals = 3 * index;
24645
+ }
24646
+ else if (unit != null) {
24647
+ decimals = getNumber(unit, "unit");
24648
+ }
24649
+ return FixedNumber.fromString(value, { decimals, width: 512 }).value;
24650
+ }
24651
+
24083
24652
  /**
24084
24653
  * @_ignore:
24085
24654
  */
@@ -74250,10 +74819,9 @@ function adjustDecimals(numStr) {
74250
74819
  const convertToTokenValue = (numberString, decimals) => {
74251
74820
  if (isNaN(parseFloat(numberString))) {
74252
74821
  console.error('Error: numberString to parse is not a number');
74253
- return undefined.parseUnits('0', decimals);
74822
+ return parseUnits$2('0', decimals);
74254
74823
  }
74255
- const tokenValue = undefined.parseUnits(adjustDecimals(numberString), decimals);
74256
- return tokenValue;
74824
+ return parseUnits$2(adjustDecimals(numberString), decimals);
74257
74825
  };
74258
74826
 
74259
74827
  var ABI_DEPOSIT = [
@@ -77597,7 +78165,9 @@ const BuyComponent = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
77597
78165
  });
77598
78166
  try {
77599
78167
  const maxPrice = new BigNumber(trueBondPrice !== null && trueBondPrice !== void 0 ? trueBondPrice : '0').times(102).div(100).toFixed(0); // multiply it by 1.02
78168
+ console.log(inputValue);
77600
78169
  const rawAmount = adjustDecimals(inputValue);
78170
+ console.log(rawAmount);
77601
78171
  const amount = new BigNumber(rawAmount).times(new BigNumber(10).pow(decimals !== null && decimals !== void 0 ? decimals : 18)).toString();
77602
78172
  const shouldUseSig = (bondData === null || bondData === void 0 ? void 0 : bondData.billVersion) === main.BillVersion.V4 && SDKConfig.useTiers;
77603
78173
  const args = shouldUseSig ? [amount, maxPrice, account, tierProofSig] : [amount, maxPrice, account];
@@ -1,4 +1,3 @@
1
- import { ethers } from 'ethers';
2
1
  export declare function adjustDecimals(numStr: string): string;
3
- declare const convertToTokenValue: (numberString: string, decimals: number) => ethers.BigNumber;
2
+ declare const convertToTokenValue: (numberString: string, decimals: number) => bigint;
4
3
  export default convertToTokenValue;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "4.1.3-test.41",
6
+ "version": "4.2.0-test.1",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",