@upcoming/bee-js 0.7.1 → 0.8.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/dist/cjs/utils/tokens.js
CHANGED
|
@@ -49,7 +49,7 @@ class BZZ {
|
|
|
49
49
|
* @returns New BZZ instance
|
|
50
50
|
*/
|
|
51
51
|
divide(other) {
|
|
52
|
-
return new BZZ(this.state.
|
|
52
|
+
return new BZZ(this.state.divmod(other)[0]);
|
|
53
53
|
}
|
|
54
54
|
gt(other) {
|
|
55
55
|
return this.state.compare(other.state) === 1;
|
|
@@ -66,6 +66,9 @@ class BZZ {
|
|
|
66
66
|
eq(other) {
|
|
67
67
|
return this.state.compare(other.state) === 0;
|
|
68
68
|
}
|
|
69
|
+
exchangeToDAI(daiPerBzz) {
|
|
70
|
+
return DAI.fromWei(this.state.exchange('*', new cafe_utility_1.FixedPointNumber(daiPerBzz.toWeiBigInt(), DAI.DIGITS), DAI.DIGITS).value);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
exports.BZZ = BZZ;
|
|
71
74
|
BZZ.DIGITS = 16;
|
|
@@ -116,7 +119,7 @@ class DAI {
|
|
|
116
119
|
* @returns New DAI instance
|
|
117
120
|
*/
|
|
118
121
|
divide(other) {
|
|
119
|
-
return new DAI(this.state.
|
|
122
|
+
return new DAI(this.state.divmod(other)[0]);
|
|
120
123
|
}
|
|
121
124
|
gt(other) {
|
|
122
125
|
return this.state.compare(other.state) === 1;
|
|
@@ -133,6 +136,9 @@ class DAI {
|
|
|
133
136
|
eq(other) {
|
|
134
137
|
return this.state.compare(other.state) === 0;
|
|
135
138
|
}
|
|
139
|
+
exchangeToBZZ(daiPerBzz) {
|
|
140
|
+
return BZZ.fromPLUR(this.state.exchange('/', new cafe_utility_1.FixedPointNumber(daiPerBzz.toWeiBigInt(), DAI.DIGITS), BZZ.DIGITS).value);
|
|
141
|
+
}
|
|
136
142
|
}
|
|
137
143
|
exports.DAI = DAI;
|
|
138
144
|
DAI.DIGITS = 18;
|