@typus/typus-sdk 0.4.4 → 0.4.5
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/lib/utils/getVaultData.d.ts +1 -1
- package/lib/utils/getVaultData.js +17 -23
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { CoveredCallVault, Auction } from "../utils/fetchData";
|
|
2
2
|
export declare function getVaultDataFromRegistry(registry: string): Promise<CoveredCallVault[]>;
|
|
3
|
-
export declare function getVaultBidPrice(auction: Auction
|
|
3
|
+
export declare function getVaultBidPrice(auction: Auction): Promise<number>;
|
|
@@ -159,7 +159,7 @@ function getVaultDataFromRegistry(registry) {
|
|
|
159
159
|
priceConfig: priceConfigRes,
|
|
160
160
|
index: (auction.index),
|
|
161
161
|
};
|
|
162
|
-
return [4 /*yield*/, getVaultBidPrice(auctionRes
|
|
162
|
+
return [4 /*yield*/, getVaultBidPrice(auctionRes)];
|
|
163
163
|
case 1:
|
|
164
164
|
vaultBidPrice = _c.sent();
|
|
165
165
|
console.log("get auction in " + vaultId);
|
|
@@ -227,30 +227,24 @@ function getVaultDataFromRegistry(registry) {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
exports.getVaultDataFromRegistry = getVaultDataFromRegistry;
|
|
230
|
-
function getVaultBidPrice(auction
|
|
230
|
+
function getVaultBidPrice(auction) {
|
|
231
231
|
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
-
var
|
|
232
|
+
var current, initialPrice, finalPrice, decaySpeed, start, end;
|
|
233
233
|
return __generator(this, function (_a) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
priceDiff = priceDiff * numerator / denominator;
|
|
249
|
-
decaySpeed = decaySpeed - 1;
|
|
250
|
-
}
|
|
251
|
-
;
|
|
252
|
-
return [2 /*return*/, initialPrice - priceDiff];
|
|
253
|
-
}
|
|
234
|
+
current = Date.now();
|
|
235
|
+
initialPrice = Number(auction.priceConfig.initialPrice);
|
|
236
|
+
finalPrice = Number(auction.priceConfig.finalPrice);
|
|
237
|
+
decaySpeed = Number(auction.priceConfig.decaySpeed);
|
|
238
|
+
start = Number(auction.startTsMs);
|
|
239
|
+
end = Number(auction.endTsMs);
|
|
240
|
+
/// decayed_price =
|
|
241
|
+
/// initial_price -
|
|
242
|
+
/// (initial_price - final_price) *
|
|
243
|
+
/// (1 - remaining_time / auction_duration) ^ decay_speed
|
|
244
|
+
// 1 - remaining_time / auction_duration => 1 - (end - current) / (end - start) => (current - start) / (end - start)
|
|
245
|
+
return [2 /*return*/, initialPrice -
|
|
246
|
+
(initialPrice - finalPrice) *
|
|
247
|
+
(((current - start) / (end - start)) ^ decaySpeed)];
|
|
254
248
|
});
|
|
255
249
|
});
|
|
256
250
|
}
|