@gearbox-protocol/sdk 12.3.7 → 12.3.8
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.
|
@@ -142,6 +142,9 @@ class PriceOracleBaseContract extends import_base.BaseContract {
|
|
|
142
142
|
* @param reserve use reserve price feed instead of main
|
|
143
143
|
*/
|
|
144
144
|
convertToUSD(from, amount, reserve = false) {
|
|
145
|
+
if (amount === 0n) {
|
|
146
|
+
return 0n;
|
|
147
|
+
}
|
|
145
148
|
const price = reserve ? this.reservePrice(from) : this.mainPrice(from);
|
|
146
149
|
const scale = 10n ** BigInt(this.tokensMeta.decimals(from));
|
|
147
150
|
return amount * price / scale;
|
|
@@ -153,6 +156,9 @@ class PriceOracleBaseContract extends import_base.BaseContract {
|
|
|
153
156
|
* @param reserve use reserve price feed instead of main
|
|
154
157
|
*/
|
|
155
158
|
convertFromUSD(to, amount, reserve = false) {
|
|
159
|
+
if (amount === 0n) {
|
|
160
|
+
return 0n;
|
|
161
|
+
}
|
|
156
162
|
const price = reserve ? this.reservePrice(to) : this.mainPrice(to);
|
|
157
163
|
const scale = 10n ** BigInt(this.tokensMeta.decimals(to));
|
|
158
164
|
return amount * scale / price;
|
|
@@ -113,6 +113,9 @@ class PriceOracleBaseContract extends BaseContract {
|
|
|
113
113
|
* @param reserve use reserve price feed instead of main
|
|
114
114
|
*/
|
|
115
115
|
convertToUSD(from, amount, reserve = false) {
|
|
116
|
+
if (amount === 0n) {
|
|
117
|
+
return 0n;
|
|
118
|
+
}
|
|
116
119
|
const price = reserve ? this.reservePrice(from) : this.mainPrice(from);
|
|
117
120
|
const scale = 10n ** BigInt(this.tokensMeta.decimals(from));
|
|
118
121
|
return amount * price / scale;
|
|
@@ -124,6 +127,9 @@ class PriceOracleBaseContract extends BaseContract {
|
|
|
124
127
|
* @param reserve use reserve price feed instead of main
|
|
125
128
|
*/
|
|
126
129
|
convertFromUSD(to, amount, reserve = false) {
|
|
130
|
+
if (amount === 0n) {
|
|
131
|
+
return 0n;
|
|
132
|
+
}
|
|
127
133
|
const price = reserve ? this.reservePrice(to) : this.mainPrice(to);
|
|
128
134
|
const scale = 10n ** BigInt(this.tokensMeta.decimals(to));
|
|
129
135
|
return amount * scale / price;
|