@typus/typus-perp-sdk 1.0.20 → 1.0.21-tk1
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/src/api/sentio.js +1 -1
- package/dist/src/fetch.js +20 -27
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +16 -12
- package/dist/src/typus_perp/admin/structs.d.ts +5 -5
- package/dist/src/typus_perp/error/functions.d.ts +2 -2
- package/dist/src/typus_perp/error/functions.js +8 -8
- package/dist/src/typus_perp/escrow/structs.d.ts +1 -1
- package/dist/src/typus_perp/index.js +3 -3
- package/dist/src/typus_perp/init.js +0 -3
- package/dist/src/typus_perp/lp-pool/functions.d.ts +2 -10
- package/dist/src/typus_perp/lp-pool/functions.js +7 -27
- package/dist/src/typus_perp/lp-pool/structs.d.ts +26 -26
- package/dist/src/typus_perp/position/functions.d.ts +21 -6
- package/dist/src/typus_perp/position/functions.js +42 -6
- package/dist/src/typus_perp/position/structs.d.ts +6 -6
- package/dist/src/typus_perp/symbol/structs.d.ts +1 -1
- package/dist/src/typus_perp/tlp/structs.d.ts +2 -2
- package/dist/src/typus_perp/trading/functions.d.ts +50 -70
- package/dist/src/typus_perp/trading/functions.js +50 -70
- package/dist/src/typus_perp/trading/structs.d.ts +52 -30
- package/dist/src/typus_perp/trading/structs.js +6 -0
- package/dist/src/typus_perp/treasury-caps/structs.d.ts +1 -1
- package/dist/src/typus_stake_pool/admin/structs.d.ts +4 -4
- package/dist/src/typus_stake_pool/index.js +3 -3
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +0 -1
- package/dist/src/typus_stake_pool/stake-pool/functions.js +0 -1
- package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +22 -22
- package/dist/src/user/history.js +10 -10
- package/dist/src/user/order.js +87 -42
- package/dist/src/user/orderWithBidReceipt.js +58 -26
- package/dist/src/user/tlp.d.ts +4 -3
- package/dist/src/user/tlp.js +93 -60
- package/package.json +2 -2
- package/dist/src/typus_perp/oracle/functions.d.ts +0 -13
- package/dist/src/typus_perp/oracle/functions.js +0 -22
- package/dist/src/typus_perp/oracle/structs.d.ts +0 -111
- package/dist/src/typus_perp/oracle/structs.js +0 -389
|
@@ -40,7 +40,7 @@ export declare class UnsubscribeEvent implements StructClass {
|
|
|
40
40
|
static reified(): UnsubscribeEventReified;
|
|
41
41
|
static get r(): reified.StructClassReified<UnsubscribeEvent, UnsubscribeEventFields>;
|
|
42
42
|
static phantom(): PhantomReified<ToTypeStr<UnsubscribeEvent>>;
|
|
43
|
-
static get p(): reified.PhantomReified<"::stake_pool::UnsubscribeEvent" | "
|
|
43
|
+
static get p(): reified.PhantomReified<"::stake_pool::UnsubscribeEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::UnsubscribeEvent">;
|
|
44
44
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
45
45
|
sender: string;
|
|
46
46
|
index: string;
|
|
@@ -134,7 +134,7 @@ export declare class WithdrawIncentiveEvent implements StructClass {
|
|
|
134
134
|
static reified(): WithdrawIncentiveEventReified;
|
|
135
135
|
static get r(): reified.StructClassReified<WithdrawIncentiveEvent, WithdrawIncentiveEventFields>;
|
|
136
136
|
static phantom(): PhantomReified<ToTypeStr<WithdrawIncentiveEvent>>;
|
|
137
|
-
static get p(): reified.PhantomReified<"::stake_pool::WithdrawIncentiveEvent" | "
|
|
137
|
+
static get p(): reified.PhantomReified<"::stake_pool::WithdrawIncentiveEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::WithdrawIncentiveEvent">;
|
|
138
138
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
139
139
|
sender: string;
|
|
140
140
|
index: string;
|
|
@@ -214,7 +214,7 @@ export declare class ActivateIncentiveTokenEvent implements StructClass {
|
|
|
214
214
|
static reified(): ActivateIncentiveTokenEventReified;
|
|
215
215
|
static get r(): reified.StructClassReified<ActivateIncentiveTokenEvent, ActivateIncentiveTokenEventFields>;
|
|
216
216
|
static phantom(): PhantomReified<ToTypeStr<ActivateIncentiveTokenEvent>>;
|
|
217
|
-
static get p(): reified.PhantomReified<"::stake_pool::ActivateIncentiveTokenEvent" | "
|
|
217
|
+
static get p(): reified.PhantomReified<"::stake_pool::ActivateIncentiveTokenEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::ActivateIncentiveTokenEvent">;
|
|
218
218
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
219
219
|
sender: string;
|
|
220
220
|
index: string;
|
|
@@ -294,7 +294,7 @@ export declare class AddIncentiveTokenEvent implements StructClass {
|
|
|
294
294
|
static reified(): AddIncentiveTokenEventReified;
|
|
295
295
|
static get r(): reified.StructClassReified<AddIncentiveTokenEvent, AddIncentiveTokenEventFields>;
|
|
296
296
|
static phantom(): PhantomReified<ToTypeStr<AddIncentiveTokenEvent>>;
|
|
297
|
-
static get p(): reified.PhantomReified<"::stake_pool::AddIncentiveTokenEvent" | "
|
|
297
|
+
static get p(): reified.PhantomReified<"::stake_pool::AddIncentiveTokenEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::AddIncentiveTokenEvent">;
|
|
298
298
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
299
299
|
sender: string;
|
|
300
300
|
index: string;
|
|
@@ -422,7 +422,7 @@ export declare class DeactivateIncentiveTokenEvent implements StructClass {
|
|
|
422
422
|
static reified(): DeactivateIncentiveTokenEventReified;
|
|
423
423
|
static get r(): reified.StructClassReified<DeactivateIncentiveTokenEvent, DeactivateIncentiveTokenEventFields>;
|
|
424
424
|
static phantom(): PhantomReified<ToTypeStr<DeactivateIncentiveTokenEvent>>;
|
|
425
|
-
static get p(): reified.PhantomReified<"::stake_pool::DeactivateIncentiveTokenEvent" | "
|
|
425
|
+
static get p(): reified.PhantomReified<"::stake_pool::DeactivateIncentiveTokenEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::DeactivateIncentiveTokenEvent">;
|
|
426
426
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
427
427
|
sender: string;
|
|
428
428
|
index: string;
|
|
@@ -500,7 +500,7 @@ export declare class DeactivatingShares implements StructClass {
|
|
|
500
500
|
static reified(): DeactivatingSharesReified;
|
|
501
501
|
static get r(): reified.StructClassReified<DeactivatingShares, DeactivatingSharesFields>;
|
|
502
502
|
static phantom(): PhantomReified<ToTypeStr<DeactivatingShares>>;
|
|
503
|
-
static get p(): reified.PhantomReified<"::stake_pool::DeactivatingShares" | "
|
|
503
|
+
static get p(): reified.PhantomReified<"::stake_pool::DeactivatingShares" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::DeactivatingShares">;
|
|
504
504
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
505
505
|
shares: string;
|
|
506
506
|
unsubscribed_ts_ms: string;
|
|
@@ -604,7 +604,7 @@ export declare class DepositIncentiveEvent implements StructClass {
|
|
|
604
604
|
static reified(): DepositIncentiveEventReified;
|
|
605
605
|
static get r(): reified.StructClassReified<DepositIncentiveEvent, DepositIncentiveEventFields>;
|
|
606
606
|
static phantom(): PhantomReified<ToTypeStr<DepositIncentiveEvent>>;
|
|
607
|
-
static get p(): reified.PhantomReified<"::stake_pool::DepositIncentiveEvent" | "
|
|
607
|
+
static get p(): reified.PhantomReified<"::stake_pool::DepositIncentiveEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::DepositIncentiveEvent">;
|
|
608
608
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
609
609
|
sender: string;
|
|
610
610
|
index: string;
|
|
@@ -688,7 +688,7 @@ export declare class HarvestPerUserShareEvent implements StructClass {
|
|
|
688
688
|
static reified(): HarvestPerUserShareEventReified;
|
|
689
689
|
static get r(): reified.StructClassReified<HarvestPerUserShareEvent, HarvestPerUserShareEventFields>;
|
|
690
690
|
static phantom(): PhantomReified<ToTypeStr<HarvestPerUserShareEvent>>;
|
|
691
|
-
static get p(): reified.PhantomReified<"::stake_pool::HarvestPerUserShareEvent" | "
|
|
691
|
+
static get p(): reified.PhantomReified<"::stake_pool::HarvestPerUserShareEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::HarvestPerUserShareEvent">;
|
|
692
692
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
693
693
|
sender: string;
|
|
694
694
|
index: string;
|
|
@@ -770,7 +770,7 @@ export declare class Incentive implements StructClass {
|
|
|
770
770
|
static reified(): IncentiveReified;
|
|
771
771
|
static get r(): reified.StructClassReified<Incentive, IncentiveFields>;
|
|
772
772
|
static phantom(): PhantomReified<ToTypeStr<Incentive>>;
|
|
773
|
-
static get p(): reified.PhantomReified<"::stake_pool::Incentive" | "
|
|
773
|
+
static get p(): reified.PhantomReified<"::stake_pool::Incentive" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::Incentive">;
|
|
774
774
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
775
775
|
token_type: {
|
|
776
776
|
name: {
|
|
@@ -882,7 +882,7 @@ export declare class IncentiveConfig implements StructClass {
|
|
|
882
882
|
static reified(): IncentiveConfigReified;
|
|
883
883
|
static get r(): reified.StructClassReified<IncentiveConfig, IncentiveConfigFields>;
|
|
884
884
|
static phantom(): PhantomReified<ToTypeStr<IncentiveConfig>>;
|
|
885
|
-
static get p(): reified.PhantomReified<"::stake_pool::IncentiveConfig" | "
|
|
885
|
+
static get p(): reified.PhantomReified<"::stake_pool::IncentiveConfig" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::IncentiveConfig">;
|
|
886
886
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
887
887
|
period_incentive_amount: string;
|
|
888
888
|
incentive_interval_ts_ms: string;
|
|
@@ -942,7 +942,7 @@ export declare class IncentiveInfo implements StructClass {
|
|
|
942
942
|
static reified(): IncentiveInfoReified;
|
|
943
943
|
static get r(): reified.StructClassReified<IncentiveInfo, IncentiveInfoFields>;
|
|
944
944
|
static phantom(): PhantomReified<ToTypeStr<IncentiveInfo>>;
|
|
945
|
-
static get p(): reified.PhantomReified<"::stake_pool::IncentiveInfo" | "
|
|
945
|
+
static get p(): reified.PhantomReified<"::stake_pool::IncentiveInfo" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::IncentiveInfo">;
|
|
946
946
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
947
947
|
active: boolean;
|
|
948
948
|
last_allocate_ts_ms: string;
|
|
@@ -1016,7 +1016,7 @@ export declare class LpUserShare implements StructClass {
|
|
|
1016
1016
|
static reified(): LpUserShareReified;
|
|
1017
1017
|
static get r(): reified.StructClassReified<LpUserShare, LpUserShareFields>;
|
|
1018
1018
|
static phantom(): PhantomReified<ToTypeStr<LpUserShare>>;
|
|
1019
|
-
static get p(): reified.PhantomReified<"::stake_pool::LpUserShare" | "
|
|
1019
|
+
static get p(): reified.PhantomReified<"::stake_pool::LpUserShare" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::LpUserShare">;
|
|
1020
1020
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1021
1021
|
user: string;
|
|
1022
1022
|
user_share_id: string;
|
|
@@ -1194,7 +1194,7 @@ export declare class NewStakePoolEvent implements StructClass {
|
|
|
1194
1194
|
static reified(): NewStakePoolEventReified;
|
|
1195
1195
|
static get r(): reified.StructClassReified<NewStakePoolEvent, NewStakePoolEventFields>;
|
|
1196
1196
|
static phantom(): PhantomReified<ToTypeStr<NewStakePoolEvent>>;
|
|
1197
|
-
static get p(): reified.PhantomReified<"::stake_pool::NewStakePoolEvent" | "
|
|
1197
|
+
static get p(): reified.PhantomReified<"::stake_pool::NewStakePoolEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::NewStakePoolEvent">;
|
|
1198
1198
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1199
1199
|
sender: string;
|
|
1200
1200
|
stake_pool_info: {
|
|
@@ -1316,7 +1316,7 @@ export declare class RemoveIncentiveTokenEvent implements StructClass {
|
|
|
1316
1316
|
static reified(): RemoveIncentiveTokenEventReified;
|
|
1317
1317
|
static get r(): reified.StructClassReified<RemoveIncentiveTokenEvent, RemoveIncentiveTokenEventFields>;
|
|
1318
1318
|
static phantom(): PhantomReified<ToTypeStr<RemoveIncentiveTokenEvent>>;
|
|
1319
|
-
static get p(): reified.PhantomReified<"::stake_pool::RemoveIncentiveTokenEvent" | "
|
|
1319
|
+
static get p(): reified.PhantomReified<"::stake_pool::RemoveIncentiveTokenEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::RemoveIncentiveTokenEvent">;
|
|
1320
1320
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1321
1321
|
sender: string;
|
|
1322
1322
|
index: string;
|
|
@@ -1404,7 +1404,7 @@ export declare class StakeEvent implements StructClass {
|
|
|
1404
1404
|
static reified(): StakeEventReified;
|
|
1405
1405
|
static get r(): reified.StructClassReified<StakeEvent, StakeEventFields>;
|
|
1406
1406
|
static phantom(): PhantomReified<ToTypeStr<StakeEvent>>;
|
|
1407
|
-
static get p(): reified.PhantomReified<"::stake_pool::StakeEvent" | "
|
|
1407
|
+
static get p(): reified.PhantomReified<"::stake_pool::StakeEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::StakeEvent">;
|
|
1408
1408
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1409
1409
|
sender: string;
|
|
1410
1410
|
index: string;
|
|
@@ -1534,7 +1534,7 @@ export declare class StakePool implements StructClass {
|
|
|
1534
1534
|
static reified(): StakePoolReified;
|
|
1535
1535
|
static get r(): reified.StructClassReified<StakePool, StakePoolFields>;
|
|
1536
1536
|
static phantom(): PhantomReified<ToTypeStr<StakePool>>;
|
|
1537
|
-
static get p(): reified.PhantomReified<"::stake_pool::StakePool" | "
|
|
1537
|
+
static get p(): reified.PhantomReified<"::stake_pool::StakePool" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::StakePool">;
|
|
1538
1538
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1539
1539
|
id: {
|
|
1540
1540
|
id: {
|
|
@@ -1738,7 +1738,7 @@ export declare class StakePoolConfig implements StructClass {
|
|
|
1738
1738
|
static reified(): StakePoolConfigReified;
|
|
1739
1739
|
static get r(): reified.StructClassReified<StakePoolConfig, StakePoolConfigFields>;
|
|
1740
1740
|
static phantom(): PhantomReified<ToTypeStr<StakePoolConfig>>;
|
|
1741
|
-
static get p(): reified.PhantomReified<"::stake_pool::StakePoolConfig" | "
|
|
1741
|
+
static get p(): reified.PhantomReified<"::stake_pool::StakePoolConfig" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::StakePoolConfig">;
|
|
1742
1742
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1743
1743
|
unlock_countdown_ts_ms: string;
|
|
1744
1744
|
u64_padding: string[];
|
|
@@ -1796,7 +1796,7 @@ export declare class StakePoolInfo implements StructClass {
|
|
|
1796
1796
|
static reified(): StakePoolInfoReified;
|
|
1797
1797
|
static get r(): reified.StructClassReified<StakePoolInfo, StakePoolInfoFields>;
|
|
1798
1798
|
static phantom(): PhantomReified<ToTypeStr<StakePoolInfo>>;
|
|
1799
|
-
static get p(): reified.PhantomReified<"::stake_pool::StakePoolInfo" | "
|
|
1799
|
+
static get p(): reified.PhantomReified<"::stake_pool::StakePoolInfo" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::StakePoolInfo">;
|
|
1800
1800
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1801
1801
|
stake_token: {
|
|
1802
1802
|
name: {
|
|
@@ -1876,7 +1876,7 @@ export declare class StakePoolRegistry implements StructClass {
|
|
|
1876
1876
|
static reified(): StakePoolRegistryReified;
|
|
1877
1877
|
static get r(): reified.StructClassReified<StakePoolRegistry, StakePoolRegistryFields>;
|
|
1878
1878
|
static phantom(): PhantomReified<ToTypeStr<StakePoolRegistry>>;
|
|
1879
|
-
static get p(): reified.PhantomReified<"::stake_pool::StakePoolRegistry" | "
|
|
1879
|
+
static get p(): reified.PhantomReified<"::stake_pool::StakePoolRegistry" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::StakePoolRegistry">;
|
|
1880
1880
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1881
1881
|
id: {
|
|
1882
1882
|
id: {
|
|
@@ -1942,7 +1942,7 @@ export declare class UnstakeEvent implements StructClass {
|
|
|
1942
1942
|
static reified(): UnstakeEventReified;
|
|
1943
1943
|
static get r(): reified.StructClassReified<UnstakeEvent, UnstakeEventFields>;
|
|
1944
1944
|
static phantom(): PhantomReified<ToTypeStr<UnstakeEvent>>;
|
|
1945
|
-
static get p(): reified.PhantomReified<"::stake_pool::UnstakeEvent" | "
|
|
1945
|
+
static get p(): reified.PhantomReified<"::stake_pool::UnstakeEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::UnstakeEvent">;
|
|
1946
1946
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
1947
1947
|
sender: string;
|
|
1948
1948
|
index: string;
|
|
@@ -2032,7 +2032,7 @@ export declare class UpdateIncentiveConfigEvent implements StructClass {
|
|
|
2032
2032
|
static reified(): UpdateIncentiveConfigEventReified;
|
|
2033
2033
|
static get r(): reified.StructClassReified<UpdateIncentiveConfigEvent, UpdateIncentiveConfigEventFields>;
|
|
2034
2034
|
static phantom(): PhantomReified<ToTypeStr<UpdateIncentiveConfigEvent>>;
|
|
2035
|
-
static get p(): reified.PhantomReified<"::stake_pool::UpdateIncentiveConfigEvent" | "
|
|
2035
|
+
static get p(): reified.PhantomReified<"::stake_pool::UpdateIncentiveConfigEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::UpdateIncentiveConfigEvent">;
|
|
2036
2036
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
2037
2037
|
sender: string;
|
|
2038
2038
|
index: string;
|
|
@@ -2136,7 +2136,7 @@ export declare class UpdateUnlockCountdownTsMsEvent implements StructClass {
|
|
|
2136
2136
|
static reified(): UpdateUnlockCountdownTsMsEventReified;
|
|
2137
2137
|
static get r(): reified.StructClassReified<UpdateUnlockCountdownTsMsEvent, UpdateUnlockCountdownTsMsEventFields>;
|
|
2138
2138
|
static phantom(): PhantomReified<ToTypeStr<UpdateUnlockCountdownTsMsEvent>>;
|
|
2139
|
-
static get p(): reified.PhantomReified<"::stake_pool::UpdateUnlockCountdownTsMsEvent" | "
|
|
2139
|
+
static get p(): reified.PhantomReified<"::stake_pool::UpdateUnlockCountdownTsMsEvent" | "0xafe221d6a3abc88d6f6f79b2452840c9f8d4cf8f7e58938b853acee5f06f24a2::stake_pool::UpdateUnlockCountdownTsMsEvent">;
|
|
2140
2140
|
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
2141
2141
|
sender: string;
|
|
2142
2142
|
index: string;
|
package/dist/src/user/history.js
CHANGED
|
@@ -77,8 +77,8 @@ function parseUserHistory(raw_events) {
|
|
|
77
77
|
switch (type) {
|
|
78
78
|
case structs_2.CreateTradingOrderEvent.$typeName:
|
|
79
79
|
case structs_2.CreateTradingOrderWithBidReceiptsEvent.$typeName:
|
|
80
|
-
var base_token = (0, constants_1.
|
|
81
|
-
var collateral_token = (0, constants_1.
|
|
80
|
+
var base_token = (0, constants_1.typeArgToAsset)(json.base_token.name);
|
|
81
|
+
var collateral_token = (0, constants_1.typeArgToAsset)(json.collateral_token.name);
|
|
82
82
|
var market = "".concat(base_token, "/USD");
|
|
83
83
|
var size = Number(json.size) / Math.pow(10, (0, constants_1.assetToDecimal)(base_token));
|
|
84
84
|
var collateral;
|
|
@@ -120,8 +120,8 @@ function parseUserHistory(raw_events) {
|
|
|
120
120
|
events.push(e);
|
|
121
121
|
break;
|
|
122
122
|
case structs_1.OrderFilledEvent.$typeName:
|
|
123
|
-
var base_token = (0, constants_1.
|
|
124
|
-
var collateral_token = (0, constants_1.
|
|
123
|
+
var base_token = (0, constants_1.typeArgToAsset)(json.symbol.base_token.name);
|
|
124
|
+
var collateral_token = (0, constants_1.typeArgToAsset)(json.collateral_token.name);
|
|
125
125
|
var market = "".concat(base_token, "/USD");
|
|
126
126
|
var size = Number(json.filled_size) / Math.pow(10, (0, constants_1.assetToDecimal)(base_token));
|
|
127
127
|
var price = json.filled_price;
|
|
@@ -170,8 +170,8 @@ function parseUserHistory(raw_events) {
|
|
|
170
170
|
}
|
|
171
171
|
break;
|
|
172
172
|
case structs_2.CancelTradingOrderEvent.$typeName:
|
|
173
|
-
var base_token = (0, constants_1.
|
|
174
|
-
var collateral_token = (0, constants_1.
|
|
173
|
+
var base_token = (0, constants_1.typeArgToAsset)(json.base_token.name);
|
|
174
|
+
var collateral_token = (0, constants_1.typeArgToAsset)(json.collateral_token.name);
|
|
175
175
|
var market = "".concat(base_token, "/USD");
|
|
176
176
|
var related = events.findLast(function (e) { return e.order_id === json.order_id && e.market === market; });
|
|
177
177
|
var e = {
|
|
@@ -195,8 +195,8 @@ function parseUserHistory(raw_events) {
|
|
|
195
195
|
break;
|
|
196
196
|
case structs_2.IncreaseCollateralEvent.$typeName:
|
|
197
197
|
case structs_2.ReleaseCollateralEvent.$typeName:
|
|
198
|
-
var base_token = (0, constants_1.
|
|
199
|
-
var collateral_token = (0, constants_1.
|
|
198
|
+
var base_token = (0, constants_1.typeArgToAsset)(json.base_token.name);
|
|
199
|
+
var collateral_token = (0, constants_1.typeArgToAsset)(json.collateral_token.name);
|
|
200
200
|
var market = "".concat(base_token, "/USD");
|
|
201
201
|
var related = events.findLast(function (e) { return e.position_id === json.position_id && e.market === market; });
|
|
202
202
|
var collateral;
|
|
@@ -226,8 +226,8 @@ function parseUserHistory(raw_events) {
|
|
|
226
226
|
events.push(e);
|
|
227
227
|
break;
|
|
228
228
|
case structs_3.SwapEvent.$typeName:
|
|
229
|
-
var from_token = (0, constants_1.
|
|
230
|
-
var to_token = (0, constants_1.
|
|
229
|
+
var from_token = (0, constants_1.typeArgToAsset)(json.from_token_type.name);
|
|
230
|
+
var to_token = (0, constants_1.typeArgToAsset)(json.to_token_type.name);
|
|
231
231
|
var from_price = Number(json.oracle_price_from_token);
|
|
232
232
|
var to_price = Number(json.oracle_price_to_token);
|
|
233
233
|
var e = {
|
package/dist/src/user/order.js
CHANGED
|
@@ -35,6 +35,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
38
49
|
var __read = (this && this.__read) || function (o, n) {
|
|
39
50
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
51
|
if (!m) return o;
|
|
@@ -63,38 +74,52 @@ var utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
|
63
74
|
var constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
64
75
|
function createTradingOrder(config, tx, pythClient, input) {
|
|
65
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination;
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
|
-
return __generator(this, function (
|
|
69
|
-
switch (
|
|
77
|
+
var TOKEN, BASE_TOKEN, tokens, tokens_1, tokens_1_1, token, cToken, baseToken, coin, destination;
|
|
78
|
+
var e_1, _a, _b, _c, _d, _e;
|
|
79
|
+
return __generator(this, function (_f) {
|
|
80
|
+
switch (_f.label) {
|
|
70
81
|
case 0:
|
|
71
82
|
TOKEN = input.cToken;
|
|
72
83
|
BASE_TOKEN = input.tradingToken;
|
|
73
|
-
|
|
84
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
85
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
74
86
|
case 1:
|
|
75
|
-
|
|
87
|
+
_f.sent();
|
|
88
|
+
try {
|
|
89
|
+
for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
90
|
+
token = tokens_1_1.value;
|
|
91
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
98
|
+
}
|
|
99
|
+
finally { if (e_1) throw e_1.error; }
|
|
100
|
+
}
|
|
76
101
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
77
102
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
78
103
|
if (TOKEN == "SUI") {
|
|
79
104
|
if (input.coins.length == 0) {
|
|
80
105
|
// support zero coin input for closing position
|
|
81
|
-
|
|
106
|
+
_b = __read(zeroCoin(tx, [cToken]), 1), coin = _b[0];
|
|
82
107
|
}
|
|
83
108
|
else {
|
|
84
|
-
|
|
109
|
+
_c = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _c[0];
|
|
85
110
|
}
|
|
86
111
|
}
|
|
87
112
|
else {
|
|
88
113
|
if (input.coins.length == 0) {
|
|
89
114
|
// support zero coin input for closing position
|
|
90
|
-
|
|
115
|
+
_d = __read(zeroCoin(tx, [cToken]), 1), coin = _d[0];
|
|
91
116
|
}
|
|
92
117
|
else {
|
|
93
118
|
destination = input.coins.pop();
|
|
94
119
|
if (input.coins.length > 0) {
|
|
95
120
|
tx.mergeCoins(destination, input.coins);
|
|
96
121
|
}
|
|
97
|
-
|
|
122
|
+
_e = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _e[0];
|
|
98
123
|
}
|
|
99
124
|
}
|
|
100
125
|
(0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
|
|
@@ -103,9 +128,8 @@ function createTradingOrder(config, tx, pythClient, input) {
|
|
|
103
128
|
poolRegistry: __1.LP_POOL,
|
|
104
129
|
marketIndex: BigInt(0),
|
|
105
130
|
poolIndex: BigInt(0),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
|
|
131
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
132
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
109
133
|
clock: constants_1.CLOCK,
|
|
110
134
|
typusEcosystemVersion: config.version.typus,
|
|
111
135
|
typusUserRegistry: config.registry.typus.user,
|
|
@@ -151,30 +175,41 @@ function cancelTradingOrder(config, tx, input) {
|
|
|
151
175
|
}
|
|
152
176
|
function increaseCollateral(config, tx, pythClient, input) {
|
|
153
177
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
-
var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination;
|
|
155
|
-
var _a, _b;
|
|
156
|
-
return __generator(this, function (
|
|
157
|
-
switch (
|
|
178
|
+
var TOKEN, BASE_TOKEN, tokens, tokens_2, tokens_2_1, token, cToken, baseToken, coin, destination;
|
|
179
|
+
var e_2, _a, _b, _c;
|
|
180
|
+
return __generator(this, function (_d) {
|
|
181
|
+
switch (_d.label) {
|
|
158
182
|
case 0:
|
|
159
|
-
TOKEN = (0, constants_1.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
BASE_TOKEN = (0, constants_1.typeArgToToken)(input.position.symbol.baseToken.name);
|
|
164
|
-
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
|
|
183
|
+
TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateralToken.name);
|
|
184
|
+
BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.baseToken.name);
|
|
185
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
186
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
165
187
|
case 1:
|
|
166
|
-
|
|
188
|
+
_d.sent();
|
|
189
|
+
try {
|
|
190
|
+
for (tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) {
|
|
191
|
+
token = tokens_2_1.value;
|
|
192
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
196
|
+
finally {
|
|
197
|
+
try {
|
|
198
|
+
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
199
|
+
}
|
|
200
|
+
finally { if (e_2) throw e_2.error; }
|
|
201
|
+
}
|
|
167
202
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
168
203
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
169
204
|
if (TOKEN == "SUI") {
|
|
170
|
-
|
|
205
|
+
_b = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _b[0];
|
|
171
206
|
}
|
|
172
207
|
else {
|
|
173
208
|
destination = input.coins.pop();
|
|
174
209
|
if (input.coins.length > 0) {
|
|
175
210
|
tx.mergeCoins(destination, input.coins);
|
|
176
211
|
}
|
|
177
|
-
|
|
212
|
+
_c = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _c[0];
|
|
178
213
|
}
|
|
179
214
|
(0, functions_1.increaseCollateral)(tx, [cToken, baseToken], {
|
|
180
215
|
version: __1.PERP_VERSION,
|
|
@@ -182,9 +217,8 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
182
217
|
poolRegistry: __1.LP_POOL,
|
|
183
218
|
marketIndex: BigInt(0),
|
|
184
219
|
poolIndex: BigInt(0),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
|
|
220
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
221
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
188
222
|
clock: constants_1.CLOCK,
|
|
189
223
|
positionId: BigInt(input.position.positionId),
|
|
190
224
|
collateral: coin,
|
|
@@ -196,18 +230,30 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
196
230
|
}
|
|
197
231
|
function releaseCollateral(config, tx, pythClient, input) {
|
|
198
232
|
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
var TOKEN, BASE_TOKEN, cToken, baseToken, coin;
|
|
200
|
-
|
|
201
|
-
|
|
233
|
+
var TOKEN, BASE_TOKEN, tokens, tokens_3, tokens_3_1, token, cToken, baseToken, coin;
|
|
234
|
+
var e_3, _a;
|
|
235
|
+
return __generator(this, function (_b) {
|
|
236
|
+
switch (_b.label) {
|
|
202
237
|
case 0:
|
|
203
|
-
TOKEN = (0, constants_1.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
BASE_TOKEN = (0, constants_1.typeArgToToken)(input.position.symbol.baseToken.name);
|
|
208
|
-
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
|
|
238
|
+
TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateralToken.name);
|
|
239
|
+
BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.baseToken.name);
|
|
240
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
241
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
209
242
|
case 1:
|
|
210
|
-
|
|
243
|
+
_b.sent();
|
|
244
|
+
try {
|
|
245
|
+
for (tokens_3 = __values(tokens), tokens_3_1 = tokens_3.next(); !tokens_3_1.done; tokens_3_1 = tokens_3.next()) {
|
|
246
|
+
token = tokens_3_1.value;
|
|
247
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
251
|
+
finally {
|
|
252
|
+
try {
|
|
253
|
+
if (tokens_3_1 && !tokens_3_1.done && (_a = tokens_3.return)) _a.call(tokens_3);
|
|
254
|
+
}
|
|
255
|
+
finally { if (e_3) throw e_3.error; }
|
|
256
|
+
}
|
|
211
257
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
212
258
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
213
259
|
coin = (0, functions_1.releaseCollateral)(tx, [cToken, baseToken], {
|
|
@@ -216,9 +262,8 @@ function releaseCollateral(config, tx, pythClient, input) {
|
|
|
216
262
|
poolRegistry: __1.LP_POOL,
|
|
217
263
|
marketIndex: BigInt(0),
|
|
218
264
|
poolIndex: BigInt(0),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
|
|
265
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
266
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
222
267
|
clock: constants_1.CLOCK,
|
|
223
268
|
positionId: BigInt(input.position.positionId),
|
|
224
269
|
releaseAmount: BigInt(input.amount),
|
|
@@ -35,6 +35,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
38
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
50
|
exports.createTradingOrderWithBidReceipt = createTradingOrderWithBidReceipt;
|
|
40
51
|
exports.reduceOptionCollateralPositionSize = reduceOptionCollateralPositionSize;
|
|
@@ -45,22 +56,30 @@ var typus_dov_single_v2_1 = require("@typus/typus-sdk/dist/src/typus-dov-single-
|
|
|
45
56
|
var __1 = require("..");
|
|
46
57
|
function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
47
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var TOKEN, BASE_TOKEN, cToken, bToken, baseToken
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
var TOKEN, BASE_TOKEN, tokens, tokens_1, tokens_1_1, token, collateralBidReceipt, cToken, bToken, baseToken;
|
|
60
|
+
var e_1, _a;
|
|
61
|
+
return __generator(this, function (_b) {
|
|
62
|
+
switch (_b.label) {
|
|
51
63
|
case 0:
|
|
52
64
|
TOKEN = input.cToken;
|
|
53
65
|
BASE_TOKEN = input.tradingToken;
|
|
54
|
-
|
|
55
|
-
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx,
|
|
66
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
67
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
56
68
|
case 1:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
_b.sent();
|
|
70
|
+
try {
|
|
71
|
+
for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
72
|
+
token = tokens_1_1.value;
|
|
73
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
77
|
+
finally {
|
|
78
|
+
try {
|
|
79
|
+
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
80
|
+
}
|
|
81
|
+
finally { if (e_1) throw e_1.error; }
|
|
82
|
+
}
|
|
64
83
|
if (input.share) {
|
|
65
84
|
collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, tx, {
|
|
66
85
|
index: input.index,
|
|
@@ -72,22 +91,23 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
72
91
|
else {
|
|
73
92
|
collateralBidReceipt = input.bidReceipt;
|
|
74
93
|
}
|
|
94
|
+
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
95
|
+
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
96
|
+
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
75
97
|
(0, functions_1.createTradingOrderWithBidReceipt)(tx, [cToken, bToken, baseToken], {
|
|
76
98
|
version: __1.PERP_VERSION,
|
|
77
99
|
registry: __1.MARKET,
|
|
78
100
|
poolRegistry: __1.LP_POOL,
|
|
79
101
|
marketIndex: BigInt(0),
|
|
80
102
|
poolIndex: BigInt(0),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
|
|
103
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
104
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
84
105
|
clock: constants_1.CLOCK,
|
|
85
106
|
typusEcosystemVersion: config.version.typus,
|
|
86
107
|
typusUserRegistry: config.registry.typus.user,
|
|
87
108
|
typusLeaderboardRegistry: config.registry.typus.leaderboard,
|
|
88
109
|
isLong: input.isLong,
|
|
89
110
|
dovRegistry: config.registry.dov.dovSingle,
|
|
90
|
-
typusOracle: config.oracle[BASE_TOKEN.toLocaleLowerCase()],
|
|
91
111
|
collateralBidReceipt: collateralBidReceipt,
|
|
92
112
|
user: input.user,
|
|
93
113
|
});
|
|
@@ -98,34 +118,46 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
98
118
|
}
|
|
99
119
|
function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
100
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var TOKEN, BASE_TOKEN, cToken, bToken, baseToken;
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
var TOKEN, BASE_TOKEN, tokens, tokens_2, tokens_2_1, token, cToken, bToken, baseToken;
|
|
122
|
+
var e_2, _a;
|
|
123
|
+
return __generator(this, function (_b) {
|
|
124
|
+
switch (_b.label) {
|
|
104
125
|
case 0:
|
|
105
126
|
TOKEN = input.cToken;
|
|
106
127
|
BASE_TOKEN = input.tradingToken;
|
|
107
|
-
|
|
128
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
129
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
108
130
|
case 1:
|
|
109
|
-
|
|
131
|
+
_b.sent();
|
|
132
|
+
try {
|
|
133
|
+
for (tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) {
|
|
134
|
+
token = tokens_2_1.value;
|
|
135
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
139
|
+
finally {
|
|
140
|
+
try {
|
|
141
|
+
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
142
|
+
}
|
|
143
|
+
finally { if (e_2) throw e_2.error; }
|
|
144
|
+
}
|
|
110
145
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
111
146
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
112
147
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
113
|
-
(0, utils_1.updateOracleWithPyth)(pythClient, tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "wUSDC");
|
|
114
148
|
(0, functions_1.reduceOptionCollateralPositionSize)(tx, [cToken, bToken, baseToken], {
|
|
115
149
|
version: __1.PERP_VERSION,
|
|
116
150
|
registry: __1.MARKET,
|
|
117
151
|
poolRegistry: __1.LP_POOL,
|
|
118
152
|
marketIndex: BigInt(0),
|
|
119
153
|
poolIndex: BigInt(0),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
|
|
154
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
155
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
123
156
|
clock: constants_1.CLOCK,
|
|
124
157
|
typusEcosystemVersion: config.version.typus,
|
|
125
158
|
typusUserRegistry: config.registry.typus.user,
|
|
126
159
|
typusLeaderboardRegistry: config.registry.typus.leaderboard,
|
|
127
160
|
dovRegistry: config.registry.dov.dovSingle,
|
|
128
|
-
typusOracle: config.oracle[BASE_TOKEN.toLocaleLowerCase()],
|
|
129
161
|
positionId: BigInt(input.positionId),
|
|
130
162
|
orderSize: input.orderSize ? BigInt(input.orderSize) : null,
|
|
131
163
|
});
|