@zofai/zo-sdk 0.1.92
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/.claude/settings.local.json +9 -0
- package/.gitattributes +4 -0
- package/.prettierrc.js +9 -0
- package/README.md +28 -0
- package/dist/abstract/BaseAPI.cjs +206 -0
- package/dist/abstract/BaseAPI.cjs.map +1 -0
- package/dist/abstract/BaseAPI.d.cts +172 -0
- package/dist/abstract/BaseAPI.d.cts.map +1 -0
- package/dist/abstract/BaseAPI.d.mts +172 -0
- package/dist/abstract/BaseAPI.d.mts.map +1 -0
- package/dist/abstract/BaseAPI.mjs +202 -0
- package/dist/abstract/BaseAPI.mjs.map +1 -0
- package/dist/abstract/BaseDataAPI.cjs +140 -0
- package/dist/abstract/BaseDataAPI.cjs.map +1 -0
- package/dist/abstract/BaseDataAPI.d.cts +89 -0
- package/dist/abstract/BaseDataAPI.d.cts.map +1 -0
- package/dist/abstract/BaseDataAPI.d.mts +89 -0
- package/dist/abstract/BaseDataAPI.d.mts.map +1 -0
- package/dist/abstract/BaseDataAPI.mjs +136 -0
- package/dist/abstract/BaseDataAPI.mjs.map +1 -0
- package/dist/abstract/index.cjs +12 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +7 -0
- package/dist/abstract/index.d.cts.map +1 -0
- package/dist/abstract/index.d.mts +7 -0
- package/dist/abstract/index.d.mts.map +1 -0
- package/dist/abstract/index.mjs +7 -0
- package/dist/abstract/index.mjs.map +1 -0
- package/dist/api.cjs +779 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +75 -0
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +75 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +775 -0
- package/dist/api.mjs.map +1 -0
- package/dist/bcs.cjs +42 -0
- package/dist/bcs.cjs.map +1 -0
- package/dist/bcs.d.cts +91 -0
- package/dist/bcs.d.cts.map +1 -0
- package/dist/bcs.d.mts +91 -0
- package/dist/bcs.d.mts.map +1 -0
- package/dist/bcs.mjs +39 -0
- package/dist/bcs.mjs.map +1 -0
- package/dist/consts/deployments-shared-mainnet.json +50 -0
- package/dist/consts/deployments-shared-testnet.json +45 -0
- package/dist/consts/deployments-slp-mainnet.json +600 -0
- package/dist/consts/deployments-slp-testnet.json +87 -0
- package/dist/consts/deployments-usdz-mainnet.json +494 -0
- package/dist/consts/deployments-usdz-testnet.json +98 -0
- package/dist/consts/deployments-zbtcvc-mainnet.json +180 -0
- package/dist/consts/deployments-zlp-mainnet.json +791 -0
- package/dist/consts/deployments-zlp-testnet.json +76 -0
- package/dist/consts/index.cjs +200 -0
- package/dist/consts/index.cjs.map +1 -0
- package/dist/consts/index.d.cts +157 -0
- package/dist/consts/index.d.cts.map +1 -0
- package/dist/consts/index.d.mts +157 -0
- package/dist/consts/index.d.mts.map +1 -0
- package/dist/consts/index.mjs +189 -0
- package/dist/consts/index.mjs.map +1 -0
- package/dist/consts/price_id_to_object_id.mainnet.json +56 -0
- package/dist/consts/price_id_to_object_id.testnet.json +17 -0
- package/dist/data.cjs +919 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +235 -0
- package/dist/data.d.cts.map +1 -0
- package/dist/data.d.mts +235 -0
- package/dist/data.d.mts.map +1 -0
- package/dist/data.mjs +915 -0
- package/dist/data.mjs.map +1 -0
- package/dist/factory/SDKFactory.cjs +228 -0
- package/dist/factory/SDKFactory.cjs.map +1 -0
- package/dist/factory/SDKFactory.d.cts +84 -0
- package/dist/factory/SDKFactory.d.cts.map +1 -0
- package/dist/factory/SDKFactory.d.mts +84 -0
- package/dist/factory/SDKFactory.d.mts.map +1 -0
- package/dist/factory/SDKFactory.mjs +222 -0
- package/dist/factory/SDKFactory.mjs.map +1 -0
- package/dist/implementations/SLPAPI.cjs +1794 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -0
- package/dist/implementations/SLPAPI.d.cts +183 -0
- package/dist/implementations/SLPAPI.d.cts.map +1 -0
- package/dist/implementations/SLPAPI.d.mts +183 -0
- package/dist/implementations/SLPAPI.d.mts.map +1 -0
- package/dist/implementations/SLPAPI.mjs +1790 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -0
- package/dist/implementations/SLPDataAPI.cjs +1384 -0
- package/dist/implementations/SLPDataAPI.cjs.map +1 -0
- package/dist/implementations/SLPDataAPI.d.cts +158 -0
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/SLPDataAPI.d.mts +158 -0
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/SLPDataAPI.mjs +1380 -0
- package/dist/implementations/SLPDataAPI.mjs.map +1 -0
- package/dist/implementations/USDZAPI.cjs +1676 -0
- package/dist/implementations/USDZAPI.cjs.map +1 -0
- package/dist/implementations/USDZAPI.d.cts +180 -0
- package/dist/implementations/USDZAPI.d.cts.map +1 -0
- package/dist/implementations/USDZAPI.d.mts +180 -0
- package/dist/implementations/USDZAPI.d.mts.map +1 -0
- package/dist/implementations/USDZAPI.mjs +1672 -0
- package/dist/implementations/USDZAPI.mjs.map +1 -0
- package/dist/implementations/USDZDataAPI.cjs +1209 -0
- package/dist/implementations/USDZDataAPI.cjs.map +1 -0
- package/dist/implementations/USDZDataAPI.d.cts +191 -0
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -0
- package/dist/implementations/USDZDataAPI.d.mts +191 -0
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -0
- package/dist/implementations/USDZDataAPI.mjs +1205 -0
- package/dist/implementations/USDZDataAPI.mjs.map +1 -0
- package/dist/implementations/ZBTCVCAPI.cjs +906 -0
- package/dist/implementations/ZBTCVCAPI.cjs.map +1 -0
- package/dist/implementations/ZBTCVCAPI.d.cts +107 -0
- package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -0
- package/dist/implementations/ZBTCVCAPI.d.mts +107 -0
- package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -0
- package/dist/implementations/ZBTCVCAPI.mjs +902 -0
- package/dist/implementations/ZBTCVCAPI.mjs.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.cjs +829 -0
- package/dist/implementations/ZBTCVCDataAPI.cjs.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.d.cts +94 -0
- package/dist/implementations/ZBTCVCDataAPI.d.cts.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.d.mts +94 -0
- package/dist/implementations/ZBTCVCDataAPI.d.mts.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.mjs +825 -0
- package/dist/implementations/ZBTCVCDataAPI.mjs.map +1 -0
- package/dist/implementations/ZLPAPI.cjs +1948 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -0
- package/dist/implementations/ZLPAPI.d.cts +192 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPAPI.d.mts +192 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPAPI.mjs +1944 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.cjs +1267 -0
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.cts +193 -0
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.mts +193 -0
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPDataAPI.mjs +1263 -0
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -0
- package/dist/implementations/index.cjs +26 -0
- package/dist/implementations/index.cjs.map +1 -0
- package/dist/implementations/index.d.cts +13 -0
- package/dist/implementations/index.d.cts.map +1 -0
- package/dist/implementations/index.d.mts +13 -0
- package/dist/implementations/index.d.mts.map +1 -0
- package/dist/implementations/index.mjs +15 -0
- package/dist/implementations/index.mjs.map +1 -0
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +51 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interfaces/base.cjs +7 -0
- package/dist/interfaces/base.cjs.map +1 -0
- package/dist/interfaces/base.d.cts +346 -0
- package/dist/interfaces/base.d.cts.map +1 -0
- package/dist/interfaces/base.d.mts +346 -0
- package/dist/interfaces/base.d.mts.map +1 -0
- package/dist/interfaces/base.mjs +6 -0
- package/dist/interfaces/base.mjs.map +1 -0
- package/dist/interfaces/index.cjs +31 -0
- package/dist/interfaces/index.cjs.map +1 -0
- package/dist/interfaces/index.d.cts +15 -0
- package/dist/interfaces/index.d.cts.map +1 -0
- package/dist/interfaces/index.d.mts +15 -0
- package/dist/interfaces/index.d.mts.map +1 -0
- package/dist/interfaces/index.mjs +15 -0
- package/dist/interfaces/index.mjs.map +1 -0
- package/dist/interfaces/slp.cjs +7 -0
- package/dist/interfaces/slp.cjs.map +1 -0
- package/dist/interfaces/slp.d.cts +179 -0
- package/dist/interfaces/slp.d.cts.map +1 -0
- package/dist/interfaces/slp.d.mts +179 -0
- package/dist/interfaces/slp.d.mts.map +1 -0
- package/dist/interfaces/slp.mjs +6 -0
- package/dist/interfaces/slp.mjs.map +1 -0
- package/dist/interfaces/usdz.cjs +7 -0
- package/dist/interfaces/usdz.cjs.map +1 -0
- package/dist/interfaces/usdz.d.cts +104 -0
- package/dist/interfaces/usdz.d.cts.map +1 -0
- package/dist/interfaces/usdz.d.mts +104 -0
- package/dist/interfaces/usdz.d.mts.map +1 -0
- package/dist/interfaces/usdz.mjs +6 -0
- package/dist/interfaces/usdz.mjs.map +1 -0
- package/dist/interfaces/zbtcvc.cjs +7 -0
- package/dist/interfaces/zbtcvc.cjs.map +1 -0
- package/dist/interfaces/zbtcvc.d.cts +64 -0
- package/dist/interfaces/zbtcvc.d.cts.map +1 -0
- package/dist/interfaces/zbtcvc.d.mts +64 -0
- package/dist/interfaces/zbtcvc.d.mts.map +1 -0
- package/dist/interfaces/zbtcvc.mjs +6 -0
- package/dist/interfaces/zbtcvc.mjs.map +1 -0
- package/dist/interfaces/zlp.cjs +7 -0
- package/dist/interfaces/zlp.cjs.map +1 -0
- package/dist/interfaces/zlp.d.cts +114 -0
- package/dist/interfaces/zlp.d.cts.map +1 -0
- package/dist/interfaces/zlp.d.mts +114 -0
- package/dist/interfaces/zlp.d.mts.map +1 -0
- package/dist/interfaces/zlp.mjs +6 -0
- package/dist/interfaces/zlp.mjs.map +1 -0
- package/dist/oracle.cjs +118 -0
- package/dist/oracle.cjs.map +1 -0
- package/dist/oracle.d.cts +25 -0
- package/dist/oracle.d.cts.map +1 -0
- package/dist/oracle.d.mts +25 -0
- package/dist/oracle.d.mts.map +1 -0
- package/dist/oracle.mjs +114 -0
- package/dist/oracle.mjs.map +1 -0
- package/dist/utils.cjs +129 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +44 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +44 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +115 -0
- package/dist/utils.mjs.map +1 -0
- package/docs/SUMMARY.md +10 -0
- package/docs/api-reference.md +32 -0
- package/docs/architecture.md +14 -0
- package/docs/common-operations.md +52 -0
- package/docs/error-handling.md +17 -0
- package/docs/getting-started.md +60 -0
- package/docs/introduction.md +15 -0
- package/docs/lp-specific-features.md +96 -0
- package/docs/type-safety.md +29 -0
- package/eslint.config.mjs +18 -0
- package/package.json +42 -0
- package/src/abstract/BaseAPI.ts +575 -0
- package/src/abstract/BaseDataAPI.ts +207 -0
- package/src/abstract/index.ts +7 -0
- package/src/api.ts +1100 -0
- package/src/bcs.ts +45 -0
- package/src/consts/deployments-shared-mainnet.json +50 -0
- package/src/consts/deployments-shared-testnet.json +45 -0
- package/src/consts/deployments-slp-mainnet.json +600 -0
- package/src/consts/deployments-slp-testnet.json +87 -0
- package/src/consts/deployments-usdz-mainnet.json +494 -0
- package/src/consts/deployments-usdz-testnet.json +98 -0
- package/src/consts/deployments-zbtcvc-mainnet.json +180 -0
- package/src/consts/deployments-zlp-mainnet.json +791 -0
- package/src/consts/deployments-zlp-testnet.json +76 -0
- package/src/consts/index.ts +345 -0
- package/src/consts/price_id_to_object_id.mainnet.json +56 -0
- package/src/consts/price_id_to_object_id.testnet.json +17 -0
- package/src/data.ts +1279 -0
- package/src/factory/SDKFactory.ts +340 -0
- package/src/implementations/SLPAPI.ts +2722 -0
- package/src/implementations/SLPDataAPI.ts +1839 -0
- package/src/implementations/USDZAPI.ts +2488 -0
- package/src/implementations/USDZDataAPI.ts +1548 -0
- package/src/implementations/ZBTCVCAPI.ts +1337 -0
- package/src/implementations/ZBTCVCDataAPI.ts +993 -0
- package/src/implementations/ZLPAPI.ts +2888 -0
- package/src/implementations/ZLPDataAPI.ts +1603 -0
- package/src/implementations/index.ts +16 -0
- package/src/index.ts +58 -0
- package/src/interfaces/base.ts +838 -0
- package/src/interfaces/index.ts +50 -0
- package/src/interfaces/slp.ts +268 -0
- package/src/interfaces/usdz.ts +181 -0
- package/src/interfaces/zbtcvc.ts +116 -0
- package/src/interfaces/zlp.ts +244 -0
- package/src/oracle.ts +153 -0
- package/src/utils.ts +168 -0
- package/tests/api.test.ts +219 -0
- package/tests/data.test.ts +156 -0
- package/tests/oracle.test.ts +33 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,1209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
/**
|
|
4
|
+
* USDZ DataAPI implementation
|
|
5
|
+
* Implements USDZ-specific data access methods
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.USDZDataAPI = void 0;
|
|
9
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
const abstract_1 = require("../abstract/index.cjs");
|
|
11
|
+
const consts_1 = require("../consts/index.cjs");
|
|
12
|
+
const utils_2 = require("../utils.cjs");
|
|
13
|
+
class USDZDataAPI extends abstract_1.BaseDataAPI {
|
|
14
|
+
constructor(network, provider, apiEndpoint, connectionURL) {
|
|
15
|
+
super(network, provider, apiEndpoint, connectionURL, consts_1.LPToken.USDZ);
|
|
16
|
+
}
|
|
17
|
+
async getStaked(owner) {
|
|
18
|
+
let rawCredentialsData = [];
|
|
19
|
+
let queryNextPage = true;
|
|
20
|
+
let queryCursor;
|
|
21
|
+
const limit = 50;
|
|
22
|
+
while (queryNextPage) {
|
|
23
|
+
const { data, hasNextPage, nextCursor } = await this.provider.getOwnedObjects({
|
|
24
|
+
owner,
|
|
25
|
+
filter: {
|
|
26
|
+
MoveModule: {
|
|
27
|
+
package: this.sharedConfig.zoStaking.package,
|
|
28
|
+
module: 'pool',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
showType: true,
|
|
33
|
+
showContent: true,
|
|
34
|
+
},
|
|
35
|
+
cursor: queryCursor,
|
|
36
|
+
limit,
|
|
37
|
+
});
|
|
38
|
+
queryNextPage = hasNextPage;
|
|
39
|
+
queryCursor = nextCursor;
|
|
40
|
+
if (!data)
|
|
41
|
+
break;
|
|
42
|
+
rawCredentialsData = [...rawCredentialsData, ...data];
|
|
43
|
+
}
|
|
44
|
+
const pool = await this.getStakePool();
|
|
45
|
+
const credentials = rawCredentialsData
|
|
46
|
+
.filter((item) => item.data.type
|
|
47
|
+
=== `${this.sharedConfig.zoStaking.package}::pool::Credential<${this.consts.zoCore.package}::usdz::USDZ, 0x2::sui::SUI>`)
|
|
48
|
+
.map((item) => USDZDataAPI.parseCredential(item, pool));
|
|
49
|
+
return {
|
|
50
|
+
credentials,
|
|
51
|
+
amount: credentials.reduce((acc, cur) => acc + cur.amount, BigInt(0)),
|
|
52
|
+
claimable: credentials.reduce((acc, cur) => acc + cur.claimable, BigInt(0)),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async getStakePool() {
|
|
56
|
+
const poolId = this.sharedConfig.zoStaking.pools.usdz;
|
|
57
|
+
const raw = await this.provider.getObject({
|
|
58
|
+
id: poolId,
|
|
59
|
+
options: {
|
|
60
|
+
showContent: true,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return USDZDataAPI.parseStakePool(raw);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates vaults valuation for USDZ
|
|
67
|
+
*/
|
|
68
|
+
valuateVaults(tx) {
|
|
69
|
+
const vaultsValuation = tx.moveCall({
|
|
70
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_vaults_valuation`,
|
|
71
|
+
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`],
|
|
72
|
+
arguments: [
|
|
73
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
74
|
+
tx.object(this.consts.zoCore.market),
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
for (const key of Object.keys(this.consts.zoCore.vaults)) {
|
|
78
|
+
const vault = this.consts.zoCore.vaults[key];
|
|
79
|
+
tx.moveCall({
|
|
80
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_vault`,
|
|
81
|
+
typeArguments: [
|
|
82
|
+
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
83
|
+
this.consts.coins[key].module,
|
|
84
|
+
],
|
|
85
|
+
arguments: [
|
|
86
|
+
tx.object(this.consts.zoCore.market),
|
|
87
|
+
tx.object(vault.reservingFeeModel),
|
|
88
|
+
tx.object(this.consts.pythFeeder.feeder[key]),
|
|
89
|
+
vaultsValuation,
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return vaultsValuation;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates symbols valuation for USDZ
|
|
97
|
+
*/
|
|
98
|
+
valuateSymbols(tx) {
|
|
99
|
+
const symbolsValuation = tx.moveCall({
|
|
100
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::create_symbols_valuation`,
|
|
101
|
+
typeArguments: [`${this.consts.zoCore.package}::usdz::USDZ`],
|
|
102
|
+
arguments: [
|
|
103
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
104
|
+
tx.object(this.consts.zoCore.market),
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
for (const key of Object.keys(this.consts.zoCore.symbols)) {
|
|
108
|
+
const [direction, token] = (0, utils_2.parseSymbolKey)(key);
|
|
109
|
+
const symbol = this.consts.zoCore.symbols[key];
|
|
110
|
+
tx.moveCall({
|
|
111
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::valuate_symbol`,
|
|
112
|
+
typeArguments: [
|
|
113
|
+
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
114
|
+
this.consts.coins[token].module,
|
|
115
|
+
`${this.consts.zoCore.package}::market::${direction.toUpperCase()}`,
|
|
116
|
+
],
|
|
117
|
+
arguments: [
|
|
118
|
+
tx.object(this.consts.zoCore.market),
|
|
119
|
+
tx.object(symbol.fundingFeeModel),
|
|
120
|
+
tx.object(this.consts.pythFeeder.feeder[token]),
|
|
121
|
+
symbolsValuation,
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return symbolsValuation;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Creates both vaults and symbols valuation
|
|
129
|
+
*/
|
|
130
|
+
valuate(tx) {
|
|
131
|
+
const vaultsValuation = this.valuateVaults(tx);
|
|
132
|
+
const symbolsValuation = this.valuateSymbols(tx);
|
|
133
|
+
return { vaultsValuation, symbolsValuation };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Valuates the USDZ market
|
|
137
|
+
*/
|
|
138
|
+
async valuateMarket() {
|
|
139
|
+
const marketInfo = await this.getMarketInfo();
|
|
140
|
+
let usdzPrice = 0;
|
|
141
|
+
let value = 0;
|
|
142
|
+
const vaultPromises = Object.keys(this.consts.zoCore.vaults).map(async (vault) => {
|
|
143
|
+
const vaultInfo = await this.getVaultInfo(vault);
|
|
144
|
+
const reservingFeeDelta = USDZDataAPI.calculateVaultReservingFee(vaultInfo, vaultInfo.reservingFeeModel, Date.now() / 1000);
|
|
145
|
+
return (reservingFeeDelta + vaultInfo.liquidity + vaultInfo.reservedAmount) * (await this.getOraclePrice(vault)).getPriceUnchecked().getPriceAsNumberUnchecked() / (10 ** this.consts.coins[vault].decimals);
|
|
146
|
+
});
|
|
147
|
+
const symbolPromises = Object.keys(this.consts.zoCore.symbols).map(async (symbol) => {
|
|
148
|
+
const [direction, tokenId] = (0, utils_2.parseSymbolKey)(symbol);
|
|
149
|
+
const symbolInfo = await this.getSymbolInfo(tokenId, direction === 'long');
|
|
150
|
+
const deltaSize = USDZDataAPI.calcDeltaSize(symbolInfo, (await this.getOraclePrice(tokenId)).getPriceUnchecked().getPriceAsNumberUnchecked());
|
|
151
|
+
// OI context for funding fee delta
|
|
152
|
+
const oiState = await this.getSymbolOiFundingState(tokenId);
|
|
153
|
+
const pairedSymbol = await this.getSymbolInfo(tokenId, !(direction === 'long'));
|
|
154
|
+
const fundingFeeDelta = USDZDataAPI.calculateSymbolFundingFee(symbolInfo, symbolInfo.fundingFeeModel, (await this.getOraclePrice(tokenId)).getPriceUnchecked().getPriceAsNumberUnchecked(), marketInfo.lpSupplyWithDecimals, Date.now() / 1000, oiState && oiState.enabled ? oiState.model : undefined, pairedSymbol.openingSize);
|
|
155
|
+
return fundingFeeDelta + deltaSize;
|
|
156
|
+
});
|
|
157
|
+
const [vaultValues, symbolValues] = await Promise.all([Promise.all(vaultPromises), Promise.all(symbolPromises)]);
|
|
158
|
+
value = vaultValues.reduce((acc, curr) => acc + curr, 0);
|
|
159
|
+
value += symbolValues.reduce((acc, curr) => acc + curr, 0);
|
|
160
|
+
usdzPrice = value / marketInfo.lpSupplyWithDecimals;
|
|
161
|
+
return {
|
|
162
|
+
marketCap: value,
|
|
163
|
+
price: usdzPrice,
|
|
164
|
+
supply: marketInfo.lpSupplyWithDecimals,
|
|
165
|
+
apr: Number(marketInfo.apr),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Gets USDZ market information
|
|
170
|
+
*/
|
|
171
|
+
async getMarketInfo() {
|
|
172
|
+
this.validateCache();
|
|
173
|
+
if (this.marketInfoCache) {
|
|
174
|
+
return this.marketInfoCache;
|
|
175
|
+
}
|
|
176
|
+
const rawData = await this.provider.getObject({
|
|
177
|
+
id: this.consts.zoCore.market,
|
|
178
|
+
options: {
|
|
179
|
+
showContent: true,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
return USDZDataAPI.parseMarketInfo(rawData);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Gets USDZ vault information
|
|
186
|
+
*/
|
|
187
|
+
async getVaultInfo(vaultToken) {
|
|
188
|
+
this.validateCache();
|
|
189
|
+
if (this.vaultInfoCache[vaultToken]) {
|
|
190
|
+
return this.vaultInfoCache[vaultToken];
|
|
191
|
+
}
|
|
192
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
193
|
+
parentId: this.consts.zoCore.vaultsParent,
|
|
194
|
+
name: {
|
|
195
|
+
type: `${this.consts.zoCore.package}::market::VaultName<${this.consts.coins[vaultToken].module}>`,
|
|
196
|
+
value: { dummy_field: false },
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
return await this.parseVaultInfo(rawData);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Gets USDZ symbol information
|
|
203
|
+
*/
|
|
204
|
+
async getSymbolInfo(indexToken, long) {
|
|
205
|
+
this.validateCache();
|
|
206
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
207
|
+
if (this.symbolInfoCache[symbol]) {
|
|
208
|
+
return this.symbolInfoCache[symbol];
|
|
209
|
+
}
|
|
210
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
211
|
+
parentId: this.consts.zoCore.symbolsParent,
|
|
212
|
+
name: {
|
|
213
|
+
type: `${this.consts.zoCore.package}::market::SymbolName<${this.consts.coins[indexToken].module}, ${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}>`,
|
|
214
|
+
value: { dummy_field: false },
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
return await this.parseSymbolInfo(rawData, long);
|
|
218
|
+
}
|
|
219
|
+
async getPositionConfig(indexToken, long) {
|
|
220
|
+
this.validateCache();
|
|
221
|
+
const symbol = (0, utils_2.joinSymbol)(long ? 'long' : 'short', indexToken);
|
|
222
|
+
if (this.positionConfigCache[symbol]) {
|
|
223
|
+
return this.positionConfigCache[symbol];
|
|
224
|
+
}
|
|
225
|
+
const rawData = await this.provider.getObject({
|
|
226
|
+
id: this.consts.zoCore.symbols[symbol].positionConfig,
|
|
227
|
+
options: {
|
|
228
|
+
showContent: true,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
return USDZDataAPI.parsePositionConfig(rawData);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Gets USDZ symbol configuration
|
|
235
|
+
*/
|
|
236
|
+
async getSymbolConfig(indexToken, long) {
|
|
237
|
+
this.validateCache();
|
|
238
|
+
try {
|
|
239
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
240
|
+
parentId: this.consts.zoCore.market,
|
|
241
|
+
name: {
|
|
242
|
+
type: `${this.consts.zoCore.package}::market::SymbolName<${this.consts.coins[indexToken].module}, ${this.consts.zoCore.package}::market::${long ? 'LONG' : 'SHORT'}>`,
|
|
243
|
+
value: { dummy_field: false },
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
return USDZDataAPI.parseSymbolConfig(rawData);
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// If the dynamic field doesn't exist, return null
|
|
250
|
+
console.error('Symbol Config Not Found');
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets USDZ symbol OI funding state (global per symbol)
|
|
256
|
+
*/
|
|
257
|
+
async getSymbolOiFundingState(indexToken) {
|
|
258
|
+
this.validateCache();
|
|
259
|
+
try {
|
|
260
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
261
|
+
parentId: this.consts.zoCore.market,
|
|
262
|
+
name: {
|
|
263
|
+
type: `0x562c9969f4c4046b33437c80c1fcdb389e8113d43de5b97c29a10b52db8f3287::funding::FundingStateKey<${this.consts.coins[indexToken].module}>`,
|
|
264
|
+
value: { dummy_field: false },
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
return USDZDataAPI.parseOiFundingState(rawData);
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
console.error('Error Fetching USDZ Symbol OI Funding State:', e);
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Gets price impact configuration for a symbol.
|
|
276
|
+
* Price impact config applies to both long and short directions for the same index token.
|
|
277
|
+
*/
|
|
278
|
+
async getPriceImpactConfig(indexToken) {
|
|
279
|
+
this.validateCache();
|
|
280
|
+
try {
|
|
281
|
+
const rawData = await this.provider.getDynamicFieldObject({
|
|
282
|
+
parentId: this.consts.zoCore.market,
|
|
283
|
+
name: {
|
|
284
|
+
type: `0x28405237f444c214c03ba32778a2e1716c3311bbe517b9f216b0d83778c36729::price_impact::PriceImpactConfigKey<${this.consts.coins[indexToken].module}>`,
|
|
285
|
+
value: { dummy_field: false },
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
return USDZDataAPI.parsePriceImpactConfig(rawData);
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
// If the dynamic field doesn't exist, return null (price impact not configured for this symbol)
|
|
292
|
+
console.error('Error Fetching Price Impact Config:', e);
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async getPositionCapInfoList(owner) {
|
|
297
|
+
const positionCapInfoList = [];
|
|
298
|
+
let cursor;
|
|
299
|
+
let hasNextPage = true;
|
|
300
|
+
while (hasNextPage) {
|
|
301
|
+
const positionCaps = await this.provider.getOwnedObjects({
|
|
302
|
+
owner,
|
|
303
|
+
filter: {
|
|
304
|
+
MoveModule: {
|
|
305
|
+
package: this.consts.zoCore.package,
|
|
306
|
+
module: 'market',
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
options: {
|
|
310
|
+
showType: true,
|
|
311
|
+
},
|
|
312
|
+
cursor,
|
|
313
|
+
});
|
|
314
|
+
for (const positionCap of positionCaps.data) {
|
|
315
|
+
if (positionCap.data?.type?.includes('PositionCap')) {
|
|
316
|
+
positionCapInfoList.push({
|
|
317
|
+
positionCapId: positionCap.data.objectId,
|
|
318
|
+
symbol0: positionCap.data.type.split('<')[1].split(',')[0].trim(),
|
|
319
|
+
symbol1: positionCap.data.type.split('<')[1].split(',')[1].split(',')[0].trim(),
|
|
320
|
+
long: positionCap.data.type.includes('LONG'),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// If we don't want to fetch all pages or there are no more pages, break the loop
|
|
325
|
+
hasNextPage = positionCaps.hasNextPage;
|
|
326
|
+
cursor = positionCaps.nextCursor;
|
|
327
|
+
}
|
|
328
|
+
return positionCapInfoList;
|
|
329
|
+
}
|
|
330
|
+
async getPositionInfoList(positionCapInfoList, owner, batchSize = 10) {
|
|
331
|
+
const positionInfoList = [];
|
|
332
|
+
// Process in batches of 10
|
|
333
|
+
for (let i = 0; i < positionCapInfoList.length; i += batchSize) {
|
|
334
|
+
const batch = positionCapInfoList.slice(i, i + batchSize);
|
|
335
|
+
await Promise.all(batch.map(async (positionCapInfo) => {
|
|
336
|
+
try {
|
|
337
|
+
const positionRaw = await this.provider.getDynamicFieldObject({
|
|
338
|
+
parentId: this.consts.zoCore.positionsParent,
|
|
339
|
+
name: {
|
|
340
|
+
type: `${this.consts.zoCore.package}::market::PositionName<${positionCapInfo.symbol0}, ${positionCapInfo.symbol1}, ${this.consts.zoCore.package}::market::${positionCapInfo.long ? 'LONG' : 'SHORT'}>`,
|
|
341
|
+
value: {
|
|
342
|
+
owner,
|
|
343
|
+
id: positionCapInfo.positionCapId,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
positionInfoList.push(await this.parsePositionInfo(positionRaw, positionCapInfo.positionCapId));
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
// Position might have been deleted after force settlement
|
|
351
|
+
console.warn(`Failed to parse position info for position cap ID ${positionCapInfo.positionCapId}: ${error}`);
|
|
352
|
+
// Continue with next position without adding this one to the list
|
|
353
|
+
}
|
|
354
|
+
}));
|
|
355
|
+
}
|
|
356
|
+
return positionInfoList.sort((a, b) => a.openTimestamp > b.openTimestamp ? 1 : -1);
|
|
357
|
+
}
|
|
358
|
+
async getOpenPositions() {
|
|
359
|
+
let positionDynamicFields = [];
|
|
360
|
+
let _continue = true;
|
|
361
|
+
let cursor;
|
|
362
|
+
while (_continue) {
|
|
363
|
+
// data here will be a list of dynamic fields containing name and value
|
|
364
|
+
const { data, nextCursor, hasNextPage } = await this.provider.getDynamicFields({
|
|
365
|
+
parentId: this.consts.zoCore.positionsParent,
|
|
366
|
+
cursor,
|
|
367
|
+
});
|
|
368
|
+
positionDynamicFields = positionDynamicFields.concat(data);
|
|
369
|
+
_continue = hasNextPage;
|
|
370
|
+
cursor = nextCursor;
|
|
371
|
+
}
|
|
372
|
+
// then we query by dynamic field names and order by time
|
|
373
|
+
const positionInfoList = [];
|
|
374
|
+
await Promise.all(positionDynamicFields.map(async (positionDynamicField) => {
|
|
375
|
+
const positionRaw = await this.provider.getDynamicFieldObject({
|
|
376
|
+
parentId: this.consts.zoCore.positionsParent,
|
|
377
|
+
name: positionDynamicField.name,
|
|
378
|
+
});
|
|
379
|
+
if (positionRaw?.data?.content) {
|
|
380
|
+
const positionInfo = await this.parsePositionInfo(positionRaw, positionDynamicField.objectId);
|
|
381
|
+
if (positionInfo) {
|
|
382
|
+
positionInfoList.push(positionInfo);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}));
|
|
386
|
+
return positionInfoList
|
|
387
|
+
.filter(positionInfo => !positionInfo.closed)
|
|
388
|
+
.sort((a, b) => (a.openTimestamp > b.openTimestamp ? 1 : -1));
|
|
389
|
+
}
|
|
390
|
+
async getOrderCapInfoList(owner) {
|
|
391
|
+
const orderCapInfoList = [];
|
|
392
|
+
let cursor;
|
|
393
|
+
let hasNextPage = true;
|
|
394
|
+
while (hasNextPage) {
|
|
395
|
+
const orderCaps = await this.provider.getOwnedObjects({
|
|
396
|
+
owner,
|
|
397
|
+
filter: {
|
|
398
|
+
MoveModule: {
|
|
399
|
+
package: this.consts.zoCore.package,
|
|
400
|
+
module: 'market',
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
options: {
|
|
404
|
+
showType: true,
|
|
405
|
+
showContent: true,
|
|
406
|
+
},
|
|
407
|
+
cursor,
|
|
408
|
+
});
|
|
409
|
+
for (const orderCap of orderCaps.data) {
|
|
410
|
+
if (orderCap.data?.type?.includes('OrderCap')) {
|
|
411
|
+
orderCapInfoList.push({
|
|
412
|
+
orderCapId: orderCap.data.objectId,
|
|
413
|
+
symbol0: orderCap.data.type.split('<')[1].split(',')[0].trim(),
|
|
414
|
+
symbol1: orderCap.data.type.split('<')[1].split(',')[1].split(',')[0].trim(),
|
|
415
|
+
long: orderCap.data.type.includes('LONG'),
|
|
416
|
+
positionId: orderCap.data.content?.fields?.position_id,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
hasNextPage = orderCaps.hasNextPage;
|
|
421
|
+
cursor = orderCaps.nextCursor;
|
|
422
|
+
}
|
|
423
|
+
return orderCapInfoList;
|
|
424
|
+
}
|
|
425
|
+
async getOrderInfoList(orderCapInfoList, owner, batchSize = 10) {
|
|
426
|
+
const orderInfoList = [];
|
|
427
|
+
// Process in batches of 10
|
|
428
|
+
for (let i = 0; i < orderCapInfoList.length; i += batchSize) {
|
|
429
|
+
const batch = orderCapInfoList.slice(i, i + batchSize);
|
|
430
|
+
await Promise.all(batch.map(async (orderCapInfo) => {
|
|
431
|
+
try {
|
|
432
|
+
const orderRaw = await this.provider.getDynamicFieldObject({
|
|
433
|
+
parentId: this.consts.zoCore.ordersParent,
|
|
434
|
+
name: {
|
|
435
|
+
// We have enforced collateral coin type to match with fee coin type so we can use symbol0 in the first slot and the last slot of the OrderName
|
|
436
|
+
type: `${this.consts.zoCore.package}::market::OrderName<${orderCapInfo.symbol0}, ${orderCapInfo.symbol1}, ${this.consts.zoCore.package}::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${orderCapInfo.symbol0}>`,
|
|
437
|
+
value: {
|
|
438
|
+
owner,
|
|
439
|
+
id: orderCapInfo.orderCapId,
|
|
440
|
+
position_id: {
|
|
441
|
+
vec: orderCapInfo.positionId ? [orderCapInfo.positionId] : [],
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
orderInfoList.push(this.parseOrderInfo(orderRaw, orderCapInfo.orderCapId));
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
// Order might have been deleted
|
|
450
|
+
console.warn(`Failed to parse order info for order cap ID ${orderCapInfo.orderCapId}: ${error}`);
|
|
451
|
+
// Continue with next order without adding this one to the list
|
|
452
|
+
}
|
|
453
|
+
}));
|
|
454
|
+
}
|
|
455
|
+
return orderInfoList.sort((a, b) => a.createdAt > b.createdAt ? 1 : -1);
|
|
456
|
+
}
|
|
457
|
+
async hasReferral(referree) {
|
|
458
|
+
const raw = await this.getReferralData(referree);
|
|
459
|
+
return !raw.error;
|
|
460
|
+
}
|
|
461
|
+
async getReferralData(referree) {
|
|
462
|
+
const raw = await this.provider.getDynamicFieldObject({
|
|
463
|
+
parentId: this.consts.zoCore.referralsParent,
|
|
464
|
+
name: {
|
|
465
|
+
type: 'address',
|
|
466
|
+
value: referree,
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
return raw;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Gets rebase fee model for USDZ
|
|
473
|
+
*/
|
|
474
|
+
async getRebaseFeeModel() {
|
|
475
|
+
this.validateCache();
|
|
476
|
+
if (this.rebaseFeeModelCache) {
|
|
477
|
+
return this.rebaseFeeModelCache;
|
|
478
|
+
}
|
|
479
|
+
const rawData = await this.provider.getObject({
|
|
480
|
+
id: this.consts.zoCore.rebaseFeeModel,
|
|
481
|
+
options: {
|
|
482
|
+
showContent: true,
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
return USDZDataAPI.parseRebaseFeeModel(rawData);
|
|
486
|
+
}
|
|
487
|
+
async fundingFeeRate(indexToken, long) {
|
|
488
|
+
const oiState = await this.getSymbolOiFundingState(indexToken);
|
|
489
|
+
if (!oiState || !oiState.enabled) {
|
|
490
|
+
const symbol = await this.getSymbolInfo(indexToken, long);
|
|
491
|
+
if (symbol.lastUpdate <= 0) {
|
|
492
|
+
return 0;
|
|
493
|
+
}
|
|
494
|
+
const price = (await this.getOraclePrice(indexToken)).getPriceUnchecked().getPriceAsNumberUnchecked();
|
|
495
|
+
const lpSupplyAmount = (await this.getMarketInfo()).lpSupplyWithDecimals;
|
|
496
|
+
const model = symbol.fundingFeeModel;
|
|
497
|
+
const elapsed = consts_1.SECONDS_PER_EIGHT_HOUR;
|
|
498
|
+
const deltaSize = USDZDataAPI.calcDeltaSize(symbol, price);
|
|
499
|
+
const pnlPerLp = (symbol.realisedPnl + symbol.unrealisedFundingFeeValue + deltaSize) / lpSupplyAmount;
|
|
500
|
+
return USDZDataAPI.calcFundingFeeRate(model, pnlPerLp, elapsed);
|
|
501
|
+
}
|
|
502
|
+
// OI model enabled: rate based on long/short imbalance
|
|
503
|
+
const longSymbol = await this.getSymbolInfo(indexToken, true);
|
|
504
|
+
const shortSymbol = await this.getSymbolInfo(indexToken, false);
|
|
505
|
+
if (longSymbol.lastUpdate <= 0 && shortSymbol.lastUpdate <= 0) {
|
|
506
|
+
return 0;
|
|
507
|
+
}
|
|
508
|
+
const elapsed = consts_1.SECONDS_PER_EIGHT_HOUR;
|
|
509
|
+
const longSize = longSymbol.openingSize;
|
|
510
|
+
const shortSize = shortSymbol.openingSize;
|
|
511
|
+
const deltaRate = USDZDataAPI.calcOiFundingFeeRate(oiState.model, longSize, shortSize, elapsed);
|
|
512
|
+
return long ? deltaRate : -deltaRate;
|
|
513
|
+
}
|
|
514
|
+
async rebaseFeeRate(collateralToken, increase, amount) {
|
|
515
|
+
let vaultValue = 0;
|
|
516
|
+
if (!increase && amount > 0) {
|
|
517
|
+
amount = -amount;
|
|
518
|
+
}
|
|
519
|
+
const value = amount * (await this.getOraclePrice(collateralToken)).getPriceUnchecked().getPriceAsNumberUnchecked() / (10 ** this.consts.coins[collateralToken].decimals);
|
|
520
|
+
const vaultPromises = Object.keys(this.consts.zoCore.vaults).map(async (vault) => {
|
|
521
|
+
const vaultInfo = await this.getVaultInfo(vault);
|
|
522
|
+
const reservingFeeDelta = USDZDataAPI.calculateVaultReservingFee(vaultInfo, vaultInfo.reservingFeeModel, Date.now() / 1000);
|
|
523
|
+
const res = (reservingFeeDelta + vaultInfo.liquidity + vaultInfo.reservedAmount) * (await this.getOraclePrice(vault)).getPriceUnchecked().getPriceAsNumberUnchecked() / (10 ** this.consts.coins[vault].decimals);
|
|
524
|
+
if (collateralToken === vault) {
|
|
525
|
+
vaultValue = res;
|
|
526
|
+
}
|
|
527
|
+
return res;
|
|
528
|
+
});
|
|
529
|
+
const vaultValues = await Promise.all(vaultPromises);
|
|
530
|
+
const totalVaultValue = vaultValues.reduce((acc, curr) => acc + curr, 0);
|
|
531
|
+
const targetRatio = Number.parseInt(this.consts.zoCore.vaults[collateralToken].weight, 10) / Object.values(this.consts.zoCore.vaults)
|
|
532
|
+
.map(e => Number.parseInt(e.weight, 10))
|
|
533
|
+
.reduce((acc, curr) => acc + curr, 0);
|
|
534
|
+
return USDZDataAPI.calcRebaseFeeRate(await this.getRebaseFeeModel(), increase, (vaultValue + value) / (totalVaultValue + value), targetRatio);
|
|
535
|
+
}
|
|
536
|
+
async reservingFeeRate(collateralToken, amount = 0) {
|
|
537
|
+
const vaultInfo = await this.getVaultInfo(collateralToken);
|
|
538
|
+
const vaultSupply = vaultInfo.liquidity + vaultInfo.reservedAmount + vaultInfo.unrealisedReservingFeeAmount + amount;
|
|
539
|
+
const utilization = vaultSupply ? ((vaultInfo.reservedAmount + amount) / vaultSupply) : 0;
|
|
540
|
+
return USDZDataAPI.calcReservingFeeRate(vaultInfo.reservingFeeModel, utilization, consts_1.SECONDS_PER_EIGHT_HOUR);
|
|
541
|
+
}
|
|
542
|
+
async getHistory(trader, page, limit, orderType, symbol) {
|
|
543
|
+
const params = new URLSearchParams({
|
|
544
|
+
trader,
|
|
545
|
+
page: page.toString(),
|
|
546
|
+
limit: limit.toString(),
|
|
547
|
+
});
|
|
548
|
+
// Add filter parameters if provided
|
|
549
|
+
if (orderType && orderType !== 'all') {
|
|
550
|
+
params.append('orderType', orderType);
|
|
551
|
+
}
|
|
552
|
+
if (symbol && symbol !== 'all') {
|
|
553
|
+
params.append('symbol', symbol);
|
|
554
|
+
}
|
|
555
|
+
params.append('lpType', 'USDZ');
|
|
556
|
+
const url = `${this.apiEndpoint}/traderEvents?${params}`;
|
|
557
|
+
const res = await fetch(url, {
|
|
558
|
+
method: 'GET',
|
|
559
|
+
headers: {
|
|
560
|
+
'Content-Type': 'application/json',
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
const response = await res.json();
|
|
564
|
+
return {
|
|
565
|
+
histories: response.data?.histories || [],
|
|
566
|
+
pagination: response.data?.pagination || {
|
|
567
|
+
total: 0,
|
|
568
|
+
page: 1,
|
|
569
|
+
limit: 20,
|
|
570
|
+
pages: 0,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
// Private helper methods
|
|
575
|
+
static calcFundingFeeRate(model, pnlPerRate, elapsed) {
|
|
576
|
+
const dailyRate = Math.min(model.multiplier * Math.abs(pnlPerRate), model.max);
|
|
577
|
+
const secondsRate = dailyRate * elapsed / consts_1.SECONDS_PER_EIGHT_HOUR;
|
|
578
|
+
return pnlPerRate >= 0 ? -secondsRate : secondsRate;
|
|
579
|
+
}
|
|
580
|
+
static calcOiFundingFeeRate(model, longSize, shortSize, elapsed) {
|
|
581
|
+
const imbalance = Math.abs(longSize - shortSize);
|
|
582
|
+
const total = longSize + shortSize > 0 ? longSize + shortSize : 1;
|
|
583
|
+
const dailyRate = Math.min((model.multiplier * (imbalance ** model.exponent)) / total, model.max);
|
|
584
|
+
const secondsRate = dailyRate * elapsed / consts_1.SECONDS_PER_EIGHT_HOUR;
|
|
585
|
+
return longSize >= shortSize ? secondsRate : -secondsRate;
|
|
586
|
+
}
|
|
587
|
+
static calcAccFundingFeeRate(symbol, model, price, lpSupplyAmount, timestamp, oiModel, pairedOpeningSize) {
|
|
588
|
+
if (symbol.lastUpdate > 0) {
|
|
589
|
+
const elapsed = timestamp - symbol.lastUpdate;
|
|
590
|
+
if (elapsed > 0) {
|
|
591
|
+
if (oiModel && typeof pairedOpeningSize === 'number') {
|
|
592
|
+
const longSize = symbol.long ? symbol.openingSize : pairedOpeningSize;
|
|
593
|
+
const shortSize = symbol.long ? pairedOpeningSize : symbol.openingSize;
|
|
594
|
+
const deltaRate = USDZDataAPI.calcOiFundingFeeRate(oiModel, longSize, shortSize, elapsed);
|
|
595
|
+
return symbol.accFundingRate + deltaRate;
|
|
596
|
+
}
|
|
597
|
+
const deltaSize = USDZDataAPI.calcDeltaSize(symbol, price);
|
|
598
|
+
const pnlPerLp = (symbol.realisedPnl + symbol.unrealisedFundingFeeValue + deltaSize) / lpSupplyAmount;
|
|
599
|
+
return symbol.accFundingRate + USDZDataAPI.calcFundingFeeRate(model, pnlPerLp, elapsed);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return symbol.accFundingRate;
|
|
603
|
+
}
|
|
604
|
+
static calculateSymbolFundingFee(symbol, model, price, lpSupplyAmount, timestamp, oiModel, pairedOpeningSize) {
|
|
605
|
+
const accFundingRate = USDZDataAPI.calcAccFundingFeeRate(symbol, model, price, lpSupplyAmount, timestamp, oiModel, pairedOpeningSize);
|
|
606
|
+
return symbol.unrealisedFundingFeeValue + (accFundingRate - symbol.accFundingRate) * symbol.openingSize;
|
|
607
|
+
}
|
|
608
|
+
static calculatePositionReserveFee(position, vault, model, timestamp) {
|
|
609
|
+
const accReservingRate = USDZDataAPI.calcAccReservingFeeRate(vault, model, timestamp);
|
|
610
|
+
return position.reservingFeeAmount + (accReservingRate - position.lastReservingRate) * position.reservedAmount;
|
|
611
|
+
}
|
|
612
|
+
static calcAccReservingFeeRate(vault, model, timestamp) {
|
|
613
|
+
if (vault.lastUpdate > 0) {
|
|
614
|
+
const elapsed = timestamp - vault.lastUpdate;
|
|
615
|
+
if (elapsed > 0) {
|
|
616
|
+
const utilization = USDZDataAPI.vaultUtilization(vault);
|
|
617
|
+
return vault.accReservingRate + USDZDataAPI.calcReservingFeeRate(model, utilization, elapsed);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return vault.accReservingRate;
|
|
621
|
+
}
|
|
622
|
+
static calcRebaseFeeRate(model, increase, ratio, targetRatio) {
|
|
623
|
+
if ((increase && ratio <= targetRatio) || (!increase && ratio >= targetRatio)) {
|
|
624
|
+
return model.base;
|
|
625
|
+
}
|
|
626
|
+
return model.base + model.multiplier * Math.abs(ratio - targetRatio);
|
|
627
|
+
}
|
|
628
|
+
static vaultUtilization(vault) {
|
|
629
|
+
const supplyAmount = vault.liquidity + vault.reservedAmount + vault.unrealisedReservingFeeAmount;
|
|
630
|
+
if (supplyAmount === 0) {
|
|
631
|
+
return 0;
|
|
632
|
+
}
|
|
633
|
+
return vault.reservedAmount / supplyAmount;
|
|
634
|
+
}
|
|
635
|
+
static calcReservingFeeRate(model, utilization, elapsed) {
|
|
636
|
+
return model.multiplier * utilization * elapsed / consts_1.SECONDS_PER_EIGHT_HOUR;
|
|
637
|
+
}
|
|
638
|
+
static calcDeltaSize(symbol, price) {
|
|
639
|
+
const latestSize = symbol.openingAmount / symbol.priceConfig.precision * price;
|
|
640
|
+
return symbol.long ? symbol.openingSize - latestSize : latestSize - symbol.openingSize;
|
|
641
|
+
}
|
|
642
|
+
static parseMarketInfo(raw) {
|
|
643
|
+
const content = raw.data.content.fields;
|
|
644
|
+
return {
|
|
645
|
+
lpSupply: content.lp_supply.fields.value,
|
|
646
|
+
positionId: content.positions.fields.id.id,
|
|
647
|
+
vaultId: content.vaults.fields.id.id,
|
|
648
|
+
symbolId: content.symbols.fields.id.id,
|
|
649
|
+
referralId: content.referrals.fields.id.id,
|
|
650
|
+
orderId: content.orders.fields.id.id,
|
|
651
|
+
rebaseFeeModel: content.rebase_fee_model,
|
|
652
|
+
lpSupplyWithDecimals: content.lp_supply.fields.value / (10 ** consts_1.USDZ_TOKEN_DECIMALS),
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
async parseVaultInfo(raw) {
|
|
656
|
+
const vaultFields = raw.data.content.fields.value.fields;
|
|
657
|
+
const reservingFeeModelAddr = vaultFields.reserving_fee_model;
|
|
658
|
+
const reservingFeeModelRaw = await this.provider.getObject({
|
|
659
|
+
id: reservingFeeModelAddr,
|
|
660
|
+
options: {
|
|
661
|
+
showContent: true,
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
const reservingFeeModel = USDZDataAPI.parseReservingFeeModel(reservingFeeModelRaw);
|
|
665
|
+
return {
|
|
666
|
+
liquidity: (0, utils_2.parseValue)(vaultFields.liquidity),
|
|
667
|
+
reservedAmount: (0, utils_2.parseValue)(vaultFields.reserved_amount),
|
|
668
|
+
unrealisedReservingFeeAmount: (0, utils_2.parseValue)(vaultFields.unrealised_reserving_fee_amount),
|
|
669
|
+
accReservingRate: (0, utils_2.parseValue)(vaultFields.acc_reserving_rate),
|
|
670
|
+
enabled: vaultFields.enabled,
|
|
671
|
+
weight: (0, utils_2.parseValue)(vaultFields.weight),
|
|
672
|
+
lastUpdate: (0, utils_2.parseValue)(vaultFields.last_update),
|
|
673
|
+
reservingFeeModel,
|
|
674
|
+
priceConfig: {
|
|
675
|
+
maxInterval: (0, utils_2.parseValue)(vaultFields.price_config.fields.max_interval),
|
|
676
|
+
maxConfidence: (0, utils_2.parseValue)(vaultFields.price_config.fields.max_confidence),
|
|
677
|
+
precision: (0, utils_2.parseValue)(vaultFields.price_config.fields.precision),
|
|
678
|
+
feeder: vaultFields.price_config.fields.feeder,
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
async parseSymbolInfo(raw, long) {
|
|
683
|
+
const { objectId } = raw.data;
|
|
684
|
+
const { fields } = raw.data.content.fields.value;
|
|
685
|
+
const fundingFeeModelAddr = fields.funding_fee_model;
|
|
686
|
+
const fundingFeeModelRaw = await this.provider.getObject({
|
|
687
|
+
id: fundingFeeModelAddr,
|
|
688
|
+
options: {
|
|
689
|
+
showContent: true,
|
|
690
|
+
},
|
|
691
|
+
});
|
|
692
|
+
const fundingFeeModel = USDZDataAPI.parseFundingFeeModel(fundingFeeModelRaw);
|
|
693
|
+
return {
|
|
694
|
+
objectId,
|
|
695
|
+
openingSize: (0, utils_2.parseValue)(fields.opening_size),
|
|
696
|
+
openingAmount: (0, utils_2.parseValue)(fields.opening_amount),
|
|
697
|
+
accFundingRate: (0, utils_2.parseValue)(fields.acc_funding_rate),
|
|
698
|
+
realisedPnl: (0, utils_2.parseValue)(fields.realised_pnl),
|
|
699
|
+
unrealisedFundingFeeValue: (0, utils_2.parseValue)(fields.unrealised_funding_fee_value),
|
|
700
|
+
openEnabled: fields.open_enabled,
|
|
701
|
+
liquidateEnabled: fields.liquidate_enabled,
|
|
702
|
+
decreaseEnabled: fields.decrease_enabled,
|
|
703
|
+
lastUpdate: (0, utils_2.parseValue)(fields.last_update),
|
|
704
|
+
fundingFeeModel,
|
|
705
|
+
long,
|
|
706
|
+
priceConfig: {
|
|
707
|
+
maxInterval: (0, utils_2.parseValue)(fields.price_config.fields.max_interval),
|
|
708
|
+
maxConfidence: (0, utils_2.parseValue)(fields.price_config.fields.max_confidence),
|
|
709
|
+
precision: (0, utils_2.parseValue)(fields.price_config.fields.precision),
|
|
710
|
+
feeder: fields.price_config.fields.feeder,
|
|
711
|
+
},
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
static parsePositionConfig(raw) {
|
|
715
|
+
const positionConfigFields = raw.data.content.fields.inner.fields;
|
|
716
|
+
return {
|
|
717
|
+
decreaseFeeBps: (0, utils_2.parseValue)(positionConfigFields.decrease_fee_bps),
|
|
718
|
+
liquidationBonus: (0, utils_2.parseValue)(positionConfigFields.liquidation_bonus),
|
|
719
|
+
liquidationThreshold: (0, utils_2.parseValue)(positionConfigFields.liquidation_threshold),
|
|
720
|
+
maxLeverage: (0, utils_2.parseValue)(positionConfigFields.max_leverage),
|
|
721
|
+
minHoldingDuration: (0, utils_2.parseValue)(positionConfigFields.min_holding_duration),
|
|
722
|
+
openFeeBps: (0, utils_2.parseValue)(positionConfigFields.open_fee_bps),
|
|
723
|
+
maxReservedMultiplier: (0, utils_2.parseValue)(positionConfigFields.max_reserved_multiplier),
|
|
724
|
+
minCollateralValue: (0, utils_2.parseValue)(positionConfigFields.min_collateral_value),
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
static parseSymbolConfig(raw) {
|
|
728
|
+
const { fields } = raw.data.content;
|
|
729
|
+
return {
|
|
730
|
+
id: fields.id.id,
|
|
731
|
+
max_opening_size: (0, utils_2.parseValue)(fields.max_opening_size),
|
|
732
|
+
max_opening_size_enabled: fields.max_opening_size_enabled,
|
|
733
|
+
max_opening_size_per_position: (0, utils_2.parseValue)(fields.max_opening_size_per_position),
|
|
734
|
+
max_opening_size_per_position_enabled: fields.max_opening_size_per_position_enabled,
|
|
735
|
+
instant_exit_fee_config: {
|
|
736
|
+
instant_exit_tier_1_duration_threshold: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_1_duration_threshold),
|
|
737
|
+
instant_exit_tier_1_fee_bps: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_bps.fields.value),
|
|
738
|
+
instant_exit_tier_1_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_1_fee_enabled,
|
|
739
|
+
instant_exit_tier_2_duration_threshold: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_2_duration_threshold),
|
|
740
|
+
instant_exit_tier_2_fee_bps: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_bps.fields.value),
|
|
741
|
+
instant_exit_tier_2_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_2_fee_enabled,
|
|
742
|
+
instant_exit_tier_3_duration_threshold: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_3_duration_threshold),
|
|
743
|
+
instant_exit_tier_3_fee_bps: (0, utils_2.parseValue)(fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_bps.fields.value),
|
|
744
|
+
instant_exit_tier_3_fee_enabled: fields.instant_exit_fee_config.fields.instant_exit_tier_3_fee_enabled,
|
|
745
|
+
},
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
async parsePositionInfo(raw, id_) {
|
|
749
|
+
const { content } = raw.data;
|
|
750
|
+
const { fields } = content;
|
|
751
|
+
const positionFields = fields.value.fields;
|
|
752
|
+
const dataType = fields.name.type;
|
|
753
|
+
const positionInfo = {
|
|
754
|
+
id: id_,
|
|
755
|
+
long: dataType.includes('::market::LONG'),
|
|
756
|
+
owner: fields.name.fields.owner,
|
|
757
|
+
version: Number.parseInt(raw.data.version, 10),
|
|
758
|
+
collateralToken: (0, utils_2.suiSymbolToSymbol)(dataType.split('<')[1].split(',')[0].trim(), this.consts),
|
|
759
|
+
indexToken: (0, utils_2.suiSymbolToSymbol)(dataType.split(',')[1].trim(), this.consts),
|
|
760
|
+
collateralAmount: (0, utils_2.parseValue)(positionFields.collateral),
|
|
761
|
+
positionAmount: (0, utils_2.parseValue)(positionFields.position_amount),
|
|
762
|
+
reservedAmount: (0, utils_2.parseValue)(positionFields.reserved),
|
|
763
|
+
positionSize: (0, utils_2.parseValue)(positionFields.position_size),
|
|
764
|
+
lastFundingRate: (0, utils_2.parseValue)(positionFields.last_funding_rate),
|
|
765
|
+
lastReservingRate: (0, utils_2.parseValue)(positionFields.last_reserving_rate),
|
|
766
|
+
reservingFeeAmount: (0, utils_2.parseValue)(positionFields.reserving_fee_amount),
|
|
767
|
+
fundingFeeValue: (0, utils_2.parseValue)(positionFields.funding_fee_value),
|
|
768
|
+
closed: positionFields.closed,
|
|
769
|
+
openTimestamp: (0, utils_2.parseValue)(positionFields.open_timestamp),
|
|
770
|
+
};
|
|
771
|
+
positionInfo.reservingFeeAmount = USDZDataAPI.calculatePositionReserveFee(positionInfo, await this.getVaultInfo(positionInfo.collateralToken), (await this.getVaultInfo(positionInfo.collateralToken)).reservingFeeModel, Date.now() / 1000);
|
|
772
|
+
// OI context for funding: fetch state and paired side size when enabled
|
|
773
|
+
const oiState = await this.getSymbolOiFundingState(positionInfo.indexToken);
|
|
774
|
+
const pairedSymbol = await this.getSymbolInfo(positionInfo.indexToken, !positionInfo.long);
|
|
775
|
+
positionInfo.fundingFeeValue = USDZDataAPI.calculatePositionFundingFee(positionInfo, await this.getSymbolInfo(positionInfo.indexToken, positionInfo.long), (await this.getSymbolInfo(positionInfo.indexToken, positionInfo.long)).fundingFeeModel, (await this.getOraclePrice(positionInfo.indexToken)).getPriceUnchecked().getPriceAsNumberUnchecked(), (await this.getMarketInfo()).lpSupplyWithDecimals, Date.now() / 1000, oiState && oiState.enabled ? oiState.model : undefined, pairedSymbol.openingSize);
|
|
776
|
+
return positionInfo;
|
|
777
|
+
}
|
|
778
|
+
static calculatePositionFundingFee(position, symbol, model, price, lpSupplyAmount, timestamp, oiModel, pairedOpeningSize) {
|
|
779
|
+
const accFundingRate = USDZDataAPI.calcAccFundingFeeRate(symbol, model, price, lpSupplyAmount, timestamp, oiModel, pairedOpeningSize);
|
|
780
|
+
return position.fundingFeeValue + (accFundingRate - position.lastFundingRate) * position.positionSize;
|
|
781
|
+
}
|
|
782
|
+
static parseRebaseFeeModel(raw) {
|
|
783
|
+
const { fields } = raw.data.content;
|
|
784
|
+
return {
|
|
785
|
+
base: (0, utils_2.parseValue)(fields.base),
|
|
786
|
+
multiplier: (0, utils_2.parseValue)(fields.multiplier),
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
static parseReservingFeeModel(raw) {
|
|
790
|
+
const content = raw.data.content.fields;
|
|
791
|
+
return {
|
|
792
|
+
multiplier: (0, utils_2.parseValue)(content.multiplier),
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
static parseFundingFeeModel(raw) {
|
|
796
|
+
const content = raw.data.content.fields;
|
|
797
|
+
return {
|
|
798
|
+
multiplier: (0, utils_2.parseValue)(content.multiplier),
|
|
799
|
+
max: (0, utils_2.parseValue)(content.max),
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
static parseOiFundingState(raw) {
|
|
803
|
+
const content = raw.data.content.fields;
|
|
804
|
+
return {
|
|
805
|
+
id: content.id.id,
|
|
806
|
+
enabled: content.enabled,
|
|
807
|
+
last_update: (0, utils_2.parseValue)(content.last_update),
|
|
808
|
+
model: {
|
|
809
|
+
id: content.model.fields.id.id,
|
|
810
|
+
multiplier: (0, utils_2.parseValue)(content.model.fields.multiplier),
|
|
811
|
+
exponent: (0, utils_2.parseValue)(content.model.fields.exponent),
|
|
812
|
+
max: (0, utils_2.parseValue)(content.model.fields.max),
|
|
813
|
+
},
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
static parsePriceImpactConfig(raw) {
|
|
817
|
+
const content = raw.data.content.fields;
|
|
818
|
+
return {
|
|
819
|
+
id: content.id.id,
|
|
820
|
+
enabled: content.enabled,
|
|
821
|
+
baseSpreadRate: (0, utils_2.parseValue)(content.base_spread_rate),
|
|
822
|
+
maxDynamicSpreadRate: (0, utils_2.parseValue)(content.max_dynamic_spread_rate),
|
|
823
|
+
maxTotalSpreadRate: (0, utils_2.parseValue)(content.max_total_spread_rate),
|
|
824
|
+
impactExponent: (0, utils_2.parseValue)(content.impact_exponent),
|
|
825
|
+
maxOiLong: (0, utils_2.parseValue)(content.max_oi_long),
|
|
826
|
+
maxOiShort: (0, utils_2.parseValue)(content.max_oi_short),
|
|
827
|
+
referenceSize: (0, utils_2.parseValue)(content.reference_size),
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Computes the spread rate based on OI skew between long and short sides using point evaluation.
|
|
832
|
+
* This is the offchain equivalent of price_impact::compute_spread_rate in the Move contract.
|
|
833
|
+
*
|
|
834
|
+
* NOTE: This method uses point evaluation at the final state. For large trades,
|
|
835
|
+
* use computeAverageSpreadRate() instead, which integrates over the trade path
|
|
836
|
+
* for more accurate pricing.
|
|
837
|
+
*
|
|
838
|
+
* @param config - Price impact configuration for the symbol
|
|
839
|
+
* @param currentOiThisSide - Current OI on the side being traded (in value terms)
|
|
840
|
+
* @param newPositionSize - Size of the new position in value terms
|
|
841
|
+
* @param currentOiOpposite - Current OI on the opposite side (in value terms)
|
|
842
|
+
* @param maxOiThisSide - Maximum OI for this side (from config or SymbolConfig)
|
|
843
|
+
* @param maxOiOpposite - Maximum OI for opposite side (from config or SymbolConfig)
|
|
844
|
+
* @returns Total spread rate to apply (as a decimal, e.g., 0.001 = 0.1%)
|
|
845
|
+
*/
|
|
846
|
+
static computeSpreadRate(config, currentOiThisSide, newPositionSize, currentOiOpposite, maxOiThisSide, maxOiOpposite) {
|
|
847
|
+
// If not enabled, return zero spread
|
|
848
|
+
if (!config.enabled) {
|
|
849
|
+
return 0;
|
|
850
|
+
}
|
|
851
|
+
// If maxOiThisSide is zero, return base spread only (cannot compute utilization)
|
|
852
|
+
if (maxOiThisSide === 0) {
|
|
853
|
+
return config.baseSpreadRate;
|
|
854
|
+
}
|
|
855
|
+
// Calculate this side utilization: (current_oi + new_position) / max_oi
|
|
856
|
+
const totalOiThis = currentOiThisSide + newPositionSize;
|
|
857
|
+
const thisUtil = Math.min(totalOiThis / maxOiThisSide, 1);
|
|
858
|
+
// Calculate opposite side utilization: current_oi / max_oi
|
|
859
|
+
let oppositeUtil = 0;
|
|
860
|
+
if (maxOiOpposite > 0) {
|
|
861
|
+
oppositeUtil = Math.min(currentOiOpposite / maxOiOpposite, 1);
|
|
862
|
+
}
|
|
863
|
+
// Calculate skew_ratio = this_util - opposite_util, clamped to [0, 1]
|
|
864
|
+
// Positive when this side is more utilized (crowded), which increases spread
|
|
865
|
+
let skewRatio = thisUtil - oppositeUtil;
|
|
866
|
+
if (skewRatio < 0) {
|
|
867
|
+
skewRatio = 0; // No penalty when opposite side is more crowded
|
|
868
|
+
}
|
|
869
|
+
else if (skewRatio > 1) {
|
|
870
|
+
skewRatio = 1; // Cap at 1.0
|
|
871
|
+
}
|
|
872
|
+
// Calculate dynamic_spread = max_dynamic * (skew_ratio ^ exponent)
|
|
873
|
+
// For fractional exponents, use linear interpolation
|
|
874
|
+
const exponent = config.impactExponent;
|
|
875
|
+
const exponentInt = Math.floor(exponent);
|
|
876
|
+
const exponentFrac = exponent - exponentInt;
|
|
877
|
+
// Compute base^exponent_int
|
|
878
|
+
let ratioPowered = skewRatio ** exponentInt;
|
|
879
|
+
// For fractional exponent, interpolate: result = base^n + frac * (base^(n+1) - base^n)
|
|
880
|
+
if (exponentFrac > 0) {
|
|
881
|
+
const ratioPoweredNext = skewRatio ** (exponentInt + 1);
|
|
882
|
+
const diff = ratioPoweredNext - ratioPowered;
|
|
883
|
+
if (diff >= 0) {
|
|
884
|
+
ratioPowered += exponentFrac * diff;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
// dynamic_spread = max_dynamic_spread * final_ratio
|
|
888
|
+
const dynamicSpread = config.maxDynamicSpreadRate * ratioPowered;
|
|
889
|
+
// total_spread = base_spread + dynamic_spread
|
|
890
|
+
let totalSpread = config.baseSpreadRate + dynamicSpread;
|
|
891
|
+
// Cap at max_total_spread
|
|
892
|
+
if (totalSpread > config.maxTotalSpreadRate) {
|
|
893
|
+
totalSpread = config.maxTotalSpreadRate;
|
|
894
|
+
}
|
|
895
|
+
return totalSpread;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Computes the size factor multiplier based on position size.
|
|
899
|
+
* Formula: size_factor = 1 + min(1, position_size / reference_size)
|
|
900
|
+
*
|
|
901
|
+
* @param positionSize - Size of the new position
|
|
902
|
+
* @param referenceSize - Reference size for scaling (0 = disabled)
|
|
903
|
+
* @returns Size factor multiplier (1.0 to 2.0)
|
|
904
|
+
*/
|
|
905
|
+
static computeSizeFactor(positionSize, referenceSize) {
|
|
906
|
+
// If reference_size is zero, size scaling is disabled
|
|
907
|
+
if (referenceSize === 0) {
|
|
908
|
+
return 1;
|
|
909
|
+
}
|
|
910
|
+
// Compute position_size / reference_size, capped at 1
|
|
911
|
+
const ratio = Math.min(positionSize / referenceSize, 1);
|
|
912
|
+
// Return 1 + capped_ratio
|
|
913
|
+
return 1 + ratio;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Computes the average value of max_dynamic * s^n over the interval [s1, s2].
|
|
917
|
+
* Uses the integral formula: average = max_dynamic * (s2^(n+1) - s1^(n+1)) / ((n+1) * (s2 - s1))
|
|
918
|
+
*
|
|
919
|
+
* @param maxDynamic - Maximum dynamic spread rate
|
|
920
|
+
* @param s1 - Start skew ratio
|
|
921
|
+
* @param s2 - End skew ratio
|
|
922
|
+
* @param exponent - Impact exponent
|
|
923
|
+
* @returns Average dynamic spread rate
|
|
924
|
+
*/
|
|
925
|
+
static computeIntegralAverage(maxDynamic, s1, s2, exponent) {
|
|
926
|
+
// If s1 == s2, return point evaluation
|
|
927
|
+
if (s1 === s2) {
|
|
928
|
+
return maxDynamic * (s1 ** exponent);
|
|
929
|
+
}
|
|
930
|
+
// Compute n + 1
|
|
931
|
+
const nPlus1 = exponent + 1;
|
|
932
|
+
// Compute s2^(n+1) and s1^(n+1)
|
|
933
|
+
const s2Pow = s2 ** nPlus1;
|
|
934
|
+
const s1Pow = s1 ** nPlus1;
|
|
935
|
+
// Compute numerator: s2^(n+1) - s1^(n+1)
|
|
936
|
+
const numerator = Math.abs(s2Pow - s1Pow);
|
|
937
|
+
// Compute denominator: (n+1) * (s2 - s1)
|
|
938
|
+
const sDiff = Math.abs(s2 - s1);
|
|
939
|
+
const denominator = nPlus1 * sDiff;
|
|
940
|
+
// Avoid division by zero
|
|
941
|
+
if (denominator === 0) {
|
|
942
|
+
return 0;
|
|
943
|
+
}
|
|
944
|
+
// Compute average ratio and multiply by max_dynamic
|
|
945
|
+
return maxDynamic * (numerator / denominator);
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Computes the average spread rate over the trade path with size scaling.
|
|
949
|
+
* This is the offchain equivalent of price_impact::compute_average_spread_rate in the Move contract.
|
|
950
|
+
*
|
|
951
|
+
* This function integrates the spread over the utilization change rather than
|
|
952
|
+
* using the final-state spread, and applies a size-based multiplier to the
|
|
953
|
+
* dynamic spread component.
|
|
954
|
+
*
|
|
955
|
+
* @param config - Price impact configuration for the symbol
|
|
956
|
+
* @param currentOiThisSide - Current OI on the side being traded (in value terms)
|
|
957
|
+
* @param newPositionSize - Size of the new position in value terms
|
|
958
|
+
* @param currentOiOpposite - Current OI on the opposite side (in value terms)
|
|
959
|
+
* @param maxOiThisSide - Maximum OI for this side (from config or SymbolConfig)
|
|
960
|
+
* @param maxOiOpposite - Maximum OI for opposite side (from config or SymbolConfig)
|
|
961
|
+
* @returns Total spread rate to apply (as a decimal, e.g., 0.001 = 0.1%)
|
|
962
|
+
*/
|
|
963
|
+
static computeAverageSpreadRate(config, currentOiThisSide, newPositionSize, currentOiOpposite, maxOiThisSide, maxOiOpposite) {
|
|
964
|
+
// If not enabled, return zero spread
|
|
965
|
+
if (!config.enabled) {
|
|
966
|
+
return 0;
|
|
967
|
+
}
|
|
968
|
+
// If maxOiThisSide is zero, return base spread only (cannot compute utilization)
|
|
969
|
+
if (maxOiThisSide === 0) {
|
|
970
|
+
return config.baseSpreadRate;
|
|
971
|
+
}
|
|
972
|
+
// Calculate opposite side utilization (constant throughout the trade)
|
|
973
|
+
let oppositeUtil = 0;
|
|
974
|
+
if (maxOiOpposite > 0) {
|
|
975
|
+
oppositeUtil = Math.min(currentOiOpposite / maxOiOpposite, 1);
|
|
976
|
+
}
|
|
977
|
+
// Calculate start utilization: current_oi / max_oi
|
|
978
|
+
const startUtil = Math.min(currentOiThisSide / maxOiThisSide, 1);
|
|
979
|
+
// Calculate end utilization: (current_oi + new_position) / max_oi
|
|
980
|
+
const totalOiThis = currentOiThisSide + newPositionSize;
|
|
981
|
+
const endUtil = Math.min(totalOiThis / maxOiThisSide, 1);
|
|
982
|
+
// Calculate start skew: max(0, min(1, start_util - opposite_util))
|
|
983
|
+
let startSkew = startUtil - oppositeUtil;
|
|
984
|
+
if (startSkew < 0) {
|
|
985
|
+
startSkew = 0;
|
|
986
|
+
}
|
|
987
|
+
else if (startSkew > 1) {
|
|
988
|
+
startSkew = 1;
|
|
989
|
+
}
|
|
990
|
+
// Calculate end skew: max(0, min(1, end_util - opposite_util))
|
|
991
|
+
let endSkew = endUtil - oppositeUtil;
|
|
992
|
+
if (endSkew < 0) {
|
|
993
|
+
endSkew = 0;
|
|
994
|
+
}
|
|
995
|
+
else if (endSkew > 1) {
|
|
996
|
+
endSkew = 1;
|
|
997
|
+
}
|
|
998
|
+
// Compute average dynamic spread via integral
|
|
999
|
+
const avgDynamicRate = USDZDataAPI.computeIntegralAverage(config.maxDynamicSpreadRate, startSkew, endSkew, config.impactExponent);
|
|
1000
|
+
// Apply size scaling factor to dynamic spread
|
|
1001
|
+
const sizeFactor = USDZDataAPI.computeSizeFactor(newPositionSize, config.referenceSize);
|
|
1002
|
+
const scaledDynamicRate = avgDynamicRate * sizeFactor;
|
|
1003
|
+
// total_spread = base_spread + scaled_dynamic
|
|
1004
|
+
let totalSpread = config.baseSpreadRate + scaledDynamicRate;
|
|
1005
|
+
// Cap at max_total_spread
|
|
1006
|
+
if (totalSpread > config.maxTotalSpreadRate) {
|
|
1007
|
+
totalSpread = config.maxTotalSpreadRate;
|
|
1008
|
+
}
|
|
1009
|
+
return totalSpread;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Applies price impact to a price.
|
|
1013
|
+
* This is the offchain equivalent of price_impact::apply_price_impact in the Move contract.
|
|
1014
|
+
*
|
|
1015
|
+
* Direction logic:
|
|
1016
|
+
* - Open Long: price INCREASES (pay more)
|
|
1017
|
+
* - Open Short: price DECREASES (receive less)
|
|
1018
|
+
* - Close Long: price DECREASES (receive less)
|
|
1019
|
+
* - Close Short: price INCREASES (pay more)
|
|
1020
|
+
*
|
|
1021
|
+
* @param originalPrice - The original price
|
|
1022
|
+
* @param spreadRate - The spread rate to apply (as a decimal, e.g., 0.001 = 0.1%)
|
|
1023
|
+
* @param isLong - Whether this is a long position
|
|
1024
|
+
* @param isOpening - Whether this is opening (true) or closing (false)
|
|
1025
|
+
* @returns Adjusted price with spread applied
|
|
1026
|
+
*/
|
|
1027
|
+
static applyPriceImpact(originalPrice, spreadRate, isLong, isOpening) {
|
|
1028
|
+
// If spread is zero, return original price
|
|
1029
|
+
if (spreadRate === 0) {
|
|
1030
|
+
return originalPrice;
|
|
1031
|
+
}
|
|
1032
|
+
// Determine if we should increase or decrease price
|
|
1033
|
+
// Open Long or Close Short -> increase price
|
|
1034
|
+
// Open Short or Close Long -> decrease price
|
|
1035
|
+
const increasePrice = (isLong && isOpening) || (!isLong && !isOpening);
|
|
1036
|
+
// Calculate spread amount: price * spread_rate
|
|
1037
|
+
const spreadAmount = originalPrice * spreadRate;
|
|
1038
|
+
// Apply spread
|
|
1039
|
+
if (increasePrice) {
|
|
1040
|
+
return originalPrice + spreadAmount;
|
|
1041
|
+
}
|
|
1042
|
+
// Ensure we don't go negative
|
|
1043
|
+
const adjusted = originalPrice - spreadAmount;
|
|
1044
|
+
return Math.max(adjusted, 0);
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Convenience method to compute the estimated execution price with price impact.
|
|
1048
|
+
* Fetches the required data and computes the adjusted price.
|
|
1049
|
+
*
|
|
1050
|
+
* @param indexToken - The index token symbol (e.g., 'sui', 'btc')
|
|
1051
|
+
* @param isLong - Whether this is a long position
|
|
1052
|
+
* @param isOpening - Whether this is opening or closing
|
|
1053
|
+
* @param positionSizeValue - Size of the position in value terms (USD)
|
|
1054
|
+
* @returns Object containing spread rate and adjusted price, or null if price impact not configured
|
|
1055
|
+
*/
|
|
1056
|
+
async estimatePriceImpact(indexToken, isLong, isOpening, positionSizeValue) {
|
|
1057
|
+
const config = await this.getPriceImpactConfig(indexToken);
|
|
1058
|
+
if (!config) {
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
// Get current OI for both sides
|
|
1062
|
+
const longSymbol = await this.getSymbolInfo(indexToken, true);
|
|
1063
|
+
const shortSymbol = await this.getSymbolInfo(indexToken, false);
|
|
1064
|
+
// Get oracle price
|
|
1065
|
+
const oraclePrice = (await this.getOraclePrice(indexToken)).getPriceUnchecked().getPriceAsNumberUnchecked();
|
|
1066
|
+
// Determine which side is "this" side and which is "opposite"
|
|
1067
|
+
const currentOiThisSide = isLong ? longSymbol.openingSize : shortSymbol.openingSize;
|
|
1068
|
+
const currentOiOpposite = isLong ? shortSymbol.openingSize : longSymbol.openingSize;
|
|
1069
|
+
const maxOiThisSide = isLong ? config.maxOiLong : config.maxOiShort;
|
|
1070
|
+
const maxOiOpposite = isLong ? config.maxOiShort : config.maxOiLong;
|
|
1071
|
+
// Compute average spread rate (uses integration for better accuracy on large trades)
|
|
1072
|
+
const spreadRate = USDZDataAPI.computeAverageSpreadRate(config, currentOiThisSide, positionSizeValue, currentOiOpposite, maxOiThisSide, maxOiOpposite);
|
|
1073
|
+
// Apply price impact
|
|
1074
|
+
const adjustedPrice = USDZDataAPI.applyPriceImpact(oraclePrice, spreadRate, isLong, isOpening);
|
|
1075
|
+
return {
|
|
1076
|
+
spreadRate,
|
|
1077
|
+
originalPrice: oraclePrice,
|
|
1078
|
+
adjustedPrice,
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
parseOrderInfo(raw, capId) {
|
|
1082
|
+
const { content } = raw.data;
|
|
1083
|
+
const { fields } = content.fields.value;
|
|
1084
|
+
// Extract tokens from dataType
|
|
1085
|
+
const dataType = content?.type;
|
|
1086
|
+
let orderType;
|
|
1087
|
+
if (content.fields.value?.type.includes('OpenPositionOrder')) {
|
|
1088
|
+
orderType = 'OPEN_POSITION';
|
|
1089
|
+
}
|
|
1090
|
+
else if (content.fields.value?.type.includes('OpenMarketOrder')) {
|
|
1091
|
+
orderType = 'OPEN_MARKET';
|
|
1092
|
+
}
|
|
1093
|
+
else if (content.fields.value?.type.includes('DecreasePositionOrder')) {
|
|
1094
|
+
orderType = 'DECREASE_POSITION';
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
orderType = 'DECREASE_MARKET';
|
|
1098
|
+
}
|
|
1099
|
+
const ret = {
|
|
1100
|
+
id: content.fields.id.id,
|
|
1101
|
+
capId,
|
|
1102
|
+
executed: fields.executed,
|
|
1103
|
+
owner: content.fields.name.fields.owner,
|
|
1104
|
+
collateralToken: (0, utils_2.suiSymbolToSymbol)(dataType.split('<')[2].split(',')[0].trim(), this.consts),
|
|
1105
|
+
indexToken: (0, utils_2.suiSymbolToSymbol)(dataType.split(',')[1].trim(), this.consts),
|
|
1106
|
+
feeToken: (0, utils_2.suiSymbolToSymbol)(dataType.split(',')[3].split('>')[0].trim(), this.consts),
|
|
1107
|
+
// Use index_price for open orders, limited_index_price for decrease orders
|
|
1108
|
+
indexPrice: orderType === 'OPEN_MARKET'
|
|
1109
|
+
? (0, utils_2.parseValue)(fields.index_price)
|
|
1110
|
+
: (0, utils_2.parseValue)(fields.limited_index_price?.fields?.price || fields.limited_index_price),
|
|
1111
|
+
collateralPriceThreshold: fields.collateral_price_threshold ? (0, utils_2.parseValue)(fields.collateral_price_threshold) : 0,
|
|
1112
|
+
// New index price threshold
|
|
1113
|
+
indexPriceThreshold: fields.index_price_threshold ? (0, utils_2.parseValue)(fields.index_price_threshold) : undefined,
|
|
1114
|
+
feeAmount: BigInt(fields.fee),
|
|
1115
|
+
long: dataType.includes('::market::LONG'),
|
|
1116
|
+
orderType,
|
|
1117
|
+
createdAt: (0, utils_2.parseValue)(fields.created_at),
|
|
1118
|
+
v11Order: !fields.limited_index_price?.fields?.price,
|
|
1119
|
+
// New: referrer and scard fields
|
|
1120
|
+
referrer: fields.referrer,
|
|
1121
|
+
scardId: (fields.scard_id?.fields?.some?.fields?.id
|
|
1122
|
+
|| fields.scard_id?.fields?.value?.fields?.id
|
|
1123
|
+
|| fields.scard_id?.fields?.id
|
|
1124
|
+
|| fields.scard_id?.id),
|
|
1125
|
+
scardRebateRate: (() => {
|
|
1126
|
+
const inner = fields.scard_rebate_rate?.fields?.some ?? fields.scard_rebate_rate?.fields?.value;
|
|
1127
|
+
return inner ? (0, utils_2.parseValue)(inner) : undefined;
|
|
1128
|
+
})(),
|
|
1129
|
+
};
|
|
1130
|
+
if (orderType === 'OPEN_POSITION' || orderType === 'OPEN_MARKET') {
|
|
1131
|
+
ret.openOrder = {
|
|
1132
|
+
reserveAmount: BigInt(fields.reserve_amount),
|
|
1133
|
+
collateralAmount: BigInt(fields.collateral),
|
|
1134
|
+
openAmount: BigInt(fields.open_amount),
|
|
1135
|
+
// New: position_config from OpenMarketOrder
|
|
1136
|
+
positionConfig: fields.position_config?.fields
|
|
1137
|
+
? {
|
|
1138
|
+
decreaseFeeBps: (0, utils_2.parseValue)(fields.position_config.fields.decrease_fee_bps),
|
|
1139
|
+
liquidationBonus: (0, utils_2.parseValue)(fields.position_config.fields.liquidation_bonus),
|
|
1140
|
+
liquidationThreshold: (0, utils_2.parseValue)(fields.position_config.fields.liquidation_threshold),
|
|
1141
|
+
maxLeverage: (0, utils_2.parseValue)(fields.position_config.fields.max_leverage),
|
|
1142
|
+
minHoldingDuration: (0, utils_2.parseValue)(fields.position_config.fields.min_holding_duration),
|
|
1143
|
+
openFeeBps: (0, utils_2.parseValue)(fields.position_config.fields.open_fee_bps),
|
|
1144
|
+
maxReservedMultiplier: (0, utils_2.parseValue)(fields.position_config.fields.max_reserved_multiplier),
|
|
1145
|
+
minCollateralValue: (0, utils_2.parseValue)(fields.position_config.fields.min_collateral_value),
|
|
1146
|
+
}
|
|
1147
|
+
: undefined,
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
else if (orderType === 'DECREASE_POSITION' || orderType === 'DECREASE_MARKET') {
|
|
1151
|
+
ret.decreaseOrder = {
|
|
1152
|
+
decreaseAmount: BigInt(fields.decrease_amount),
|
|
1153
|
+
takeProfit: fields.take_profit,
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
return ret;
|
|
1157
|
+
}
|
|
1158
|
+
static calculateVaultReservingFee(vaultInfo, reservingFeeModel, currentTime) {
|
|
1159
|
+
const timeDelta = currentTime - vaultInfo.lastUpdate;
|
|
1160
|
+
const periods = Math.floor(timeDelta / consts_1.SECONDS_PER_EIGHT_HOUR);
|
|
1161
|
+
return vaultInfo.unrealisedReservingFeeAmount
|
|
1162
|
+
+ (vaultInfo.reservedAmount * reservingFeeModel.multiplier * periods) / 1e18;
|
|
1163
|
+
}
|
|
1164
|
+
static parseCredential(raw, pool) {
|
|
1165
|
+
const stakedAmount = BigInt(raw.data.content.fields.stake);
|
|
1166
|
+
const accRewardPerShare = BigInt(raw.data.content.fields.acc_reward_per_share);
|
|
1167
|
+
return {
|
|
1168
|
+
id: raw.data.objectId,
|
|
1169
|
+
lockUntil: (0, utils_2.parseValue)(raw.data.content.fields.lock_until),
|
|
1170
|
+
amount: stakedAmount,
|
|
1171
|
+
accRewardPerShare,
|
|
1172
|
+
claimable: ((pool.accRewardPerShare - accRewardPerShare) * stakedAmount)
|
|
1173
|
+
/ BigInt(1e18),
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
static parseStakePool(raw) {
|
|
1177
|
+
const content = raw.data.content.fields;
|
|
1178
|
+
const pool = {
|
|
1179
|
+
id: content.id.id,
|
|
1180
|
+
enabled: content.enabled,
|
|
1181
|
+
lastUpdatedTime: (0, utils_2.parseValue)(content.last_updated_time),
|
|
1182
|
+
stakedAmount: BigInt(content.staked_amount),
|
|
1183
|
+
reward: BigInt(content.reward_vault),
|
|
1184
|
+
startTime: (0, utils_2.parseValue)(content.start_time),
|
|
1185
|
+
endTime: (0, utils_2.parseValue)(content.end_time),
|
|
1186
|
+
rewardRate: BigInt(content.reward_rate),
|
|
1187
|
+
accRewardPerShare: BigInt(content.acc_reward_per_share),
|
|
1188
|
+
lockDuration: (0, utils_2.parseValue)(content.lock_duration),
|
|
1189
|
+
};
|
|
1190
|
+
USDZDataAPI.refreshPool(pool, Math.floor(Date.now() / 1000));
|
|
1191
|
+
return pool;
|
|
1192
|
+
}
|
|
1193
|
+
static refreshPool(pool, timestamp) {
|
|
1194
|
+
if (timestamp <= pool.lastUpdatedTime || timestamp < pool.startTime) {
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
const applicableEndTime = Math.max(pool.endTime, pool.lastUpdatedTime);
|
|
1198
|
+
const calculationEndTime = Math.min(timestamp, applicableEndTime);
|
|
1199
|
+
if (calculationEndTime > pool.lastUpdatedTime && pool.stakedAmount > BigInt(0) && pool.rewardRate > BigInt(0)) {
|
|
1200
|
+
const timeDiff = BigInt(calculationEndTime - pool.lastUpdatedTime);
|
|
1201
|
+
const rewardAmount = timeDiff * pool.rewardRate;
|
|
1202
|
+
const rewardPerShare = (rewardAmount * BigInt(1e18)) / pool.stakedAmount;
|
|
1203
|
+
pool.accRewardPerShare += rewardPerShare;
|
|
1204
|
+
}
|
|
1205
|
+
pool.lastUpdatedTime = calculationEndTime;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
exports.USDZDataAPI = USDZDataAPI;
|
|
1209
|
+
//# sourceMappingURL=USDZDataAPI.cjs.map
|