zo-sdk 0.1.2 → 0.1.3
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/abstract/BaseAPI.cjs +3 -4
- package/dist/abstract/BaseAPI.cjs.map +1 -1
- package/dist/abstract/BaseAPI.d.cts +13 -13
- package/dist/abstract/BaseAPI.d.cts.map +1 -1
- package/dist/abstract/BaseAPI.d.mts +13 -13
- package/dist/abstract/BaseAPI.d.mts.map +1 -1
- package/dist/abstract/BaseAPI.mjs +3 -4
- package/dist/abstract/BaseAPI.mjs.map +1 -1
- package/dist/abstract/BaseDataAPI.cjs +2 -2
- package/dist/abstract/BaseDataAPI.cjs.map +1 -1
- package/dist/abstract/BaseDataAPI.d.cts +2 -2
- package/dist/abstract/BaseDataAPI.d.cts.map +1 -1
- package/dist/abstract/BaseDataAPI.d.mts +2 -2
- package/dist/abstract/BaseDataAPI.d.mts.map +1 -1
- package/dist/abstract/BaseDataAPI.mjs +2 -2
- package/dist/abstract/BaseDataAPI.mjs.map +1 -1
- package/dist/abstract/index.cjs +3 -3
- package/dist/abstract/index.cjs.map +1 -1
- package/dist/abstract/index.d.cts +1 -1
- package/dist/abstract/index.d.cts.map +1 -1
- package/dist/abstract/index.d.mts +1 -1
- package/dist/abstract/index.d.mts.map +1 -1
- package/dist/abstract/index.mjs +1 -1
- package/dist/abstract/index.mjs.map +1 -1
- package/dist/api.cjs +2 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +2 -1
- package/dist/api.mjs.map +1 -1
- package/dist/bcs.cjs.map +1 -1
- package/dist/bcs.d.cts.map +1 -1
- package/dist/bcs.d.mts.map +1 -1
- package/dist/bcs.mjs.map +1 -1
- package/dist/consts/deployments-slp-mainnet.json +0 -70
- package/dist/consts/deployments-usdz-mainnet.json +1 -133
- package/dist/consts/index.cjs +21 -14
- package/dist/consts/index.cjs.map +1 -1
- package/dist/consts/index.d.cts.map +1 -1
- package/dist/consts/index.d.mts.map +1 -1
- package/dist/consts/index.mjs +21 -14
- package/dist/consts/index.mjs.map +1 -1
- package/dist/factory/SDKFactory.cjs +21 -14
- package/dist/factory/SDKFactory.cjs.map +1 -1
- package/dist/factory/SDKFactory.d.cts +4 -4
- package/dist/factory/SDKFactory.d.cts.map +1 -1
- package/dist/factory/SDKFactory.d.mts +4 -4
- package/dist/factory/SDKFactory.d.mts.map +1 -1
- package/dist/factory/SDKFactory.mjs +22 -15
- package/dist/factory/SDKFactory.mjs.map +1 -1
- package/dist/implementations/SLPAPI.cjs +143 -110
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +49 -47
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +49 -47
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +143 -110
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/SLPDataAPI.cjs +98 -89
- package/dist/implementations/SLPDataAPI.cjs.map +1 -1
- package/dist/implementations/SLPDataAPI.d.cts +21 -21
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/SLPDataAPI.d.mts +21 -21
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/SLPDataAPI.mjs +98 -89
- package/dist/implementations/SLPDataAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +128 -84
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +46 -45
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +46 -45
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +128 -84
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/USDZDataAPI.cjs +48 -47
- package/dist/implementations/USDZDataAPI.cjs.map +1 -1
- package/dist/implementations/USDZDataAPI.d.cts +19 -19
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -1
- package/dist/implementations/USDZDataAPI.d.mts +19 -19
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -1
- package/dist/implementations/USDZDataAPI.mjs +49 -48
- package/dist/implementations/USDZDataAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +137 -89
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +50 -48
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +50 -48
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +137 -89
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.cjs +62 -63
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.cts +19 -19
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPDataAPI.d.mts +19 -19
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPDataAPI.mjs +63 -64
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -1
- package/dist/implementations/index.cjs +5 -5
- package/dist/implementations/index.cjs.map +1 -1
- package/dist/implementations/index.d.cts +2 -2
- package/dist/implementations/index.d.cts.map +1 -1
- package/dist/implementations/index.d.mts +2 -2
- package/dist/implementations/index.d.mts.map +1 -1
- package/dist/implementations/index.mjs +2 -2
- package/dist/implementations/index.mjs.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces/base.cjs +0 -1
- package/dist/interfaces/base.cjs.map +1 -1
- package/dist/interfaces/base.d.cts +57 -57
- package/dist/interfaces/base.d.cts.map +1 -1
- package/dist/interfaces/base.d.mts +57 -57
- package/dist/interfaces/base.d.mts.map +1 -1
- package/dist/interfaces/base.mjs +1 -1
- package/dist/interfaces/base.mjs.map +1 -1
- package/dist/interfaces/index.d.cts +4 -4
- package/dist/interfaces/index.d.cts.map +1 -1
- package/dist/interfaces/index.d.mts +4 -4
- package/dist/interfaces/index.d.mts.map +1 -1
- package/dist/interfaces/slp.cjs +0 -2
- package/dist/interfaces/slp.cjs.map +1 -1
- package/dist/interfaces/slp.d.cts +5 -5
- package/dist/interfaces/slp.d.cts.map +1 -1
- package/dist/interfaces/slp.d.mts +5 -5
- package/dist/interfaces/slp.d.mts.map +1 -1
- package/dist/interfaces/slp.mjs +1 -2
- package/dist/interfaces/slp.mjs.map +1 -1
- package/dist/interfaces/usdz.d.cts +1 -1
- package/dist/interfaces/usdz.d.cts.map +1 -1
- package/dist/interfaces/usdz.d.mts +1 -1
- package/dist/interfaces/usdz.d.mts.map +1 -1
- package/dist/interfaces/zlp.d.cts +5 -5
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +5 -5
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/dist/oracle.cjs +12 -2
- package/dist/oracle.cjs.map +1 -1
- package/dist/oracle.d.cts +4 -3
- package/dist/oracle.d.cts.map +1 -1
- package/dist/oracle.d.mts +4 -3
- package/dist/oracle.d.mts.map +1 -1
- package/dist/oracle.mjs +13 -3
- package/dist/oracle.mjs.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +1 -1
- package/dist/utils.mjs.map +1 -1
- package/eslint.config.mjs +18 -0
- package/package.json +16 -15
- package/src/abstract/BaseAPI.ts +55 -49
- package/src/abstract/BaseDataAPI.ts +19 -17
- package/src/abstract/index.ts +1 -1
- package/src/api.ts +3 -1
- package/src/bcs.ts +9 -9
- package/src/consts/deployments-slp-mainnet.json +0 -70
- package/src/consts/deployments-usdz-mainnet.json +1 -133
- package/src/consts/index.ts +22 -15
- package/src/factory/SDKFactory.ts +49 -41
- package/src/implementations/SLPAPI.ts +299 -210
- package/src/implementations/SLPDataAPI.ts +163 -146
- package/src/implementations/USDZAPI.ts +238 -133
- package/src/implementations/USDZDataAPI.ts +79 -74
- package/src/implementations/ZLPAPI.ts +296 -174
- package/src/implementations/ZLPDataAPI.ts +93 -88
- package/src/implementations/index.ts +3 -3
- package/src/index.ts +17 -17
- package/src/interfaces/base.ts +123 -116
- package/src/interfaces/index.ts +14 -17
- package/src/interfaces/slp.ts +20 -19
- package/src/interfaces/usdz.ts +13 -13
- package/src/interfaces/zlp.ts +22 -21
- package/src/oracle.ts +25 -5
- package/src/utils.ts +9 -9
- package/tsconfig.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SLPAPI.d.mts","sourceRoot":"","sources":["../../src/implementations/SLPAPI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AACnD,OAAO,EAAE,WAAW,EAAE,iCAAgC;
|
|
1
|
+
{"version":3,"file":"SLPAPI.d.mts","sourceRoot":"","sources":["../../src/implementations/SLPAPI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,sBAAqB;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA0B;AACnD,OAAO,EAAE,WAAW,EAAE,iCAAgC;AAGtD,OAAO,EAAE,OAAO,EAAE,8BAAmB;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,4BAAiB;AAExC,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAA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W,CAAC;IA2FhB,WAAW,CAChB,QAAQ,EAAE,MAAM,EAChB,EAAE,CAAC,EAAE,WAAW,GACf,WAAW;IAaD,oBAAoB,CAC/B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC;IAKhB,mBAAmB,CACxB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,GACb,WAAW;IAKP,qBAAqB,CAC1B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,eAAe,CAAC,EAAE,MAAM,EACxB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW;IAuDP,wBAAwB,CAC7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,WAAW,GACd,IAAI;IAmBA,mBAAmB,CACxB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,MAAM,GACZ,WAAW;CA+Bf"}
|
|
@@ -2,101 +2,130 @@
|
|
|
2
2
|
* SLP API implementation
|
|
3
3
|
* Implements SLP-specific trading and transaction methods for Sudo SDK
|
|
4
4
|
*/
|
|
5
|
+
import { KioskTransaction } from "@mysten/kiosk";
|
|
5
6
|
import { Transaction } from "@mysten/sui/transactions";
|
|
6
7
|
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
7
|
-
import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE, LPToken } from "../consts/index.mjs";
|
|
8
8
|
import { BaseAPI } from "../abstract/index.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { ALLOW_TRADE_CAN_TRADE, ALLOW_TRADE_MUST_TRADE, ALLOW_TRADE_NO_TRADE, LPToken } from "../consts/index.mjs";
|
|
10
10
|
import { joinSymbol } from "../utils.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { SLPDataAPI } from "./SLPDataAPI.mjs";
|
|
12
12
|
export class SLPAPI extends BaseAPI {
|
|
13
13
|
constructor(network, provider, apiEndpoint, connectionURL) {
|
|
14
14
|
super(network, provider, apiEndpoint, connectionURL, LPToken.SLP);
|
|
15
15
|
this.dataAPI = new SLPDataAPI(network, provider, apiEndpoint, connectionURL);
|
|
16
16
|
}
|
|
17
|
-
valuateVaults(
|
|
18
|
-
throw new Error(
|
|
17
|
+
valuateVaults(_tx) {
|
|
18
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
19
19
|
}
|
|
20
|
-
valuateSymbols(
|
|
21
|
-
throw new Error(
|
|
20
|
+
valuateSymbols(_tx) {
|
|
21
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
22
22
|
}
|
|
23
|
-
valuate(
|
|
24
|
-
throw new Error(
|
|
23
|
+
valuate(_tx) {
|
|
24
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
25
25
|
}
|
|
26
26
|
valuateMarket() {
|
|
27
|
-
throw new Error(
|
|
27
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
28
28
|
}
|
|
29
|
-
fundingFeeRate(
|
|
30
|
-
throw new Error(
|
|
29
|
+
fundingFeeRate(_indexToken, _long, _sender) {
|
|
30
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
31
31
|
}
|
|
32
|
-
rebaseFeeRate(
|
|
33
|
-
throw new Error(
|
|
32
|
+
rebaseFeeRate(_collateralToken, _increase, _amount, _sender) {
|
|
33
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
34
34
|
}
|
|
35
|
-
reservingFeeRate(
|
|
36
|
-
throw new Error(
|
|
35
|
+
reservingFeeRate(_collateralToken, _amount, _sender) {
|
|
36
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
37
37
|
}
|
|
38
|
-
calcPositionReserveFeeAmount(
|
|
39
|
-
throw new Error(
|
|
38
|
+
calcPositionReserveFeeAmount(_position) {
|
|
39
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
40
40
|
}
|
|
41
|
-
calcPositionFundingFeeValue(
|
|
42
|
-
throw new Error(
|
|
41
|
+
calcPositionFundingFeeValue(_position) {
|
|
42
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
43
43
|
}
|
|
44
44
|
getMarketInfo() {
|
|
45
|
-
throw new Error(
|
|
45
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
46
46
|
}
|
|
47
|
-
getVaultInfo(
|
|
48
|
-
throw new Error(
|
|
47
|
+
getVaultInfo(_vault) {
|
|
48
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
49
49
|
}
|
|
50
|
-
getSymbolInfo(
|
|
51
|
-
throw new Error(
|
|
50
|
+
getSymbolInfo(_tokenId, _long) {
|
|
51
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
52
52
|
}
|
|
53
|
-
getPositionConfig(
|
|
54
|
-
throw new Error(
|
|
53
|
+
getPositionConfig(_indexToken, _long) {
|
|
54
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
55
55
|
}
|
|
56
56
|
getRebaseFeeModel() {
|
|
57
|
-
throw new Error(
|
|
57
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
58
58
|
}
|
|
59
59
|
getOpenPositions() {
|
|
60
|
-
throw new Error(
|
|
60
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
61
61
|
}
|
|
62
|
-
getPositionCapInfoList(
|
|
63
|
-
throw new Error(
|
|
62
|
+
getPositionCapInfoList(_owner) {
|
|
63
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
64
64
|
}
|
|
65
|
-
getPositionInfoList(
|
|
66
|
-
throw new Error(
|
|
65
|
+
getPositionInfoList(_positionCapInfoList, _owner) {
|
|
66
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
67
67
|
}
|
|
68
|
-
getOrderCapInfoList(
|
|
69
|
-
throw new Error(
|
|
68
|
+
getOrderCapInfoList(_owner) {
|
|
69
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
70
70
|
}
|
|
71
|
-
getOrderInfoList(
|
|
72
|
-
throw new Error(
|
|
71
|
+
getOrderInfoList(_orderCapInfoList, _owner) {
|
|
72
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
73
73
|
}
|
|
74
|
-
getHistory(
|
|
75
|
-
throw new Error(
|
|
74
|
+
getHistory(_trader, _page, _limit, _orderType, _symbol) {
|
|
75
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
76
76
|
}
|
|
77
|
-
getStaked(
|
|
78
|
-
throw new Error(
|
|
77
|
+
getStaked(_owner) {
|
|
78
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
79
79
|
}
|
|
80
80
|
getStakePool() {
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
82
82
|
}
|
|
83
|
-
hasReferral(
|
|
84
|
-
throw new Error(
|
|
83
|
+
hasReferral(_referree) {
|
|
84
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
85
85
|
}
|
|
86
|
-
getReferralData(
|
|
87
|
-
throw new Error(
|
|
86
|
+
getReferralData(_referree) {
|
|
87
|
+
throw new Error(`Method not implemented in ${this.constructor.name}.`);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Deposits collateral into SLP vault using Sudo SDK approach
|
|
91
91
|
*/
|
|
92
|
-
async deposit(coin, coinObjects, amount, minAmountOut, referralAddress, sender) {
|
|
92
|
+
async deposit(coin, coinObjects, amount, minAmountOut = 0, referralAddress, sender, sponsoredTx, suiCoinObjectsForPythUpdate, isDepositingSui) {
|
|
93
93
|
let tx = new Transaction();
|
|
94
|
+
// Add referral if needed
|
|
94
95
|
if (referralAddress && !(await this.dataAPI.hasReferral(sender || ''))) {
|
|
95
96
|
tx = await this.addReferral(referralAddress, tx);
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
98
|
+
// Initialize oracle transaction
|
|
99
|
+
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
|
|
100
|
+
// Handle sponsored transaction case
|
|
101
|
+
if (sponsoredTx) {
|
|
102
|
+
const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
103
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
|
|
104
|
+
// Process deposit coins
|
|
105
|
+
const depositObject = isDepositingSui
|
|
106
|
+
? tx.splitCoins(suiCoinObject, [tx.pure.u64(amount)])[0]
|
|
107
|
+
: tx.splitCoins(this.processCoins(tx, coin, coinObjects, true), [tx.pure.u64(amount)])[0];
|
|
108
|
+
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
|
|
109
|
+
tx.moveCall({
|
|
110
|
+
target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
|
|
111
|
+
typeArguments: [
|
|
112
|
+
`${this.consts.sudoCore.package}::slp::SLP`,
|
|
113
|
+
this.consts.coins[coin].module,
|
|
114
|
+
],
|
|
115
|
+
arguments: [
|
|
116
|
+
tx.object(this.consts.sudoCore.market),
|
|
117
|
+
tx.object(this.consts.sudoCore.rebaseFeeModel),
|
|
118
|
+
depositObject,
|
|
119
|
+
tx.pure.u64(minAmountOut),
|
|
120
|
+
vaultsValuation,
|
|
121
|
+
symbolsValuation,
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
return tx;
|
|
125
|
+
}
|
|
126
|
+
// Handle non-sponsored transaction case
|
|
127
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx);
|
|
128
|
+
const depositObject = tx.splitCoins(this.processCoins(tx, coin, coinObjects, false), [tx.pure.u64(amount)])[0];
|
|
100
129
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
|
|
101
130
|
tx.moveCall({
|
|
102
131
|
target: `${this.consts.sudoCore.upgradedPackage}::market::deposit`,
|
|
@@ -108,7 +137,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
108
137
|
tx.object(this.consts.sudoCore.market),
|
|
109
138
|
tx.object(this.consts.sudoCore.rebaseFeeModel),
|
|
110
139
|
depositObject,
|
|
111
|
-
tx.pure.u64(minAmountOut
|
|
140
|
+
tx.pure.u64(minAmountOut),
|
|
112
141
|
vaultsValuation,
|
|
113
142
|
symbolsValuation,
|
|
114
143
|
],
|
|
@@ -118,10 +147,19 @@ export class SLPAPI extends BaseAPI {
|
|
|
118
147
|
/**
|
|
119
148
|
* Withdraws collateral from SLP vault using Sudo SDK approach
|
|
120
149
|
*/
|
|
121
|
-
async withdraw(coin, lpCoinObjects, amount, minAmountOut) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
150
|
+
async withdraw(coin, lpCoinObjects, amount, minAmountOut = 0, sponsoredTx, suiCoinObjectsForPythUpdate) {
|
|
151
|
+
let tx = new Transaction();
|
|
152
|
+
// Initialize oracle transaction
|
|
153
|
+
const pythFeederKeys = Object.keys(this.consts.pythFeeder.feeder);
|
|
154
|
+
if (sponsoredTx) {
|
|
155
|
+
const suiCoinObject = this.processCoins(tx, 'sui', suiCoinObjectsForPythUpdate || [], true);
|
|
156
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx, true, suiCoinObject);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
tx = await this.initOracleTxb(pythFeederKeys, tx);
|
|
160
|
+
}
|
|
161
|
+
const slpCoinObject = this.processCoins(tx, 'slp', lpCoinObjects, false);
|
|
162
|
+
const [withdrawObject] = tx.splitCoins(slpCoinObject, [tx.pure.u64(amount)]);
|
|
125
163
|
const { vaultsValuation, symbolsValuation } = this.dataAPI.valuate(tx);
|
|
126
164
|
tx.moveCall({
|
|
127
165
|
target: `${this.consts.sudoCore.upgradedPackage}::market::withdraw`,
|
|
@@ -133,7 +171,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
133
171
|
tx.object(this.consts.sudoCore.market),
|
|
134
172
|
tx.object(this.consts.sudoCore.rebaseFeeModel),
|
|
135
173
|
withdrawObject,
|
|
136
|
-
tx.pure.u64(minAmountOut
|
|
174
|
+
tx.pure.u64(minAmountOut),
|
|
137
175
|
vaultsValuation,
|
|
138
176
|
symbolsValuation,
|
|
139
177
|
],
|
|
@@ -167,7 +205,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
167
205
|
/**
|
|
168
206
|
* Stakes SLP tokens in Sudo staking pools
|
|
169
207
|
*/
|
|
170
|
-
|
|
208
|
+
stake(lpCoinObjects, amount, pool) {
|
|
171
209
|
if (!this.consts.sudoStaking) {
|
|
172
210
|
throw new Error('Sudo staking configuration not found');
|
|
173
211
|
}
|
|
@@ -191,14 +229,16 @@ export class SLPAPI extends BaseAPI {
|
|
|
191
229
|
/**
|
|
192
230
|
* Unstakes SLP tokens from Sudo staking pools
|
|
193
231
|
*/
|
|
194
|
-
|
|
232
|
+
unstake(credentials, amount, pool) {
|
|
195
233
|
if (!this.consts.sudoStaking) {
|
|
196
234
|
throw new Error('Sudo staking configuration not found');
|
|
197
235
|
}
|
|
198
236
|
const tx = new Transaction();
|
|
199
237
|
for (const credential of credentials) {
|
|
200
|
-
|
|
201
|
-
|
|
238
|
+
const withdrawAmount = (() => {
|
|
239
|
+
const min = (a, b) => a < b ? a : b;
|
|
240
|
+
return min(amount, credential.amount);
|
|
241
|
+
})();
|
|
202
242
|
amount -= withdrawAmount;
|
|
203
243
|
tx.moveCall({
|
|
204
244
|
target: `${this.consts.sudoStaking.package}::pool::withdraw`,
|
|
@@ -254,7 +294,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
254
294
|
this.consts.coins[collateralToken].module,
|
|
255
295
|
this.consts.coins[indexToken].module,
|
|
256
296
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
257
|
-
this.consts.coins
|
|
297
|
+
this.consts.coins.sui.module,
|
|
258
298
|
],
|
|
259
299
|
arguments: [
|
|
260
300
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -279,7 +319,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
279
319
|
/**
|
|
280
320
|
* Decreases an existing position in SLP using Sudo SDK approach
|
|
281
321
|
*/
|
|
282
|
-
async decreasePosition(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5)
|
|
322
|
+
async decreasePosition(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5)) {
|
|
283
323
|
const tx = await this.initOracleTxb([collateralToken, indexToken]);
|
|
284
324
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
|
|
285
325
|
const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]); // Sudo contract requires SUI as fee
|
|
@@ -287,12 +327,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
287
327
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
288
328
|
let allowTrade = ALLOW_TRADE_MUST_TRADE;
|
|
289
329
|
if (isTriggerOrder) {
|
|
290
|
-
|
|
291
|
-
allowTrade = ALLOW_TRADE_NO_TRADE;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
allowTrade = ALLOW_TRADE_CAN_TRADE;
|
|
295
|
-
}
|
|
330
|
+
allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
|
|
296
331
|
}
|
|
297
332
|
else {
|
|
298
333
|
isTakeProfitOrder = true;
|
|
@@ -304,7 +339,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
304
339
|
this.consts.coins[collateralToken].module,
|
|
305
340
|
this.consts.coins[indexToken].module,
|
|
306
341
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
307
|
-
this.consts.coins
|
|
342
|
+
this.consts.coins.sui.module,
|
|
308
343
|
],
|
|
309
344
|
arguments: [
|
|
310
345
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -329,15 +364,15 @@ export class SLPAPI extends BaseAPI {
|
|
|
329
364
|
if (!tx) {
|
|
330
365
|
tx = new Transaction();
|
|
331
366
|
}
|
|
332
|
-
tx = await this.initOracleTxb(positions.
|
|
367
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
|
|
333
368
|
for (const position of positions) {
|
|
334
|
-
const { pcpId, collateralToken, coinObjects, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder, isTakeProfitOrder, isIocOrder,
|
|
369
|
+
const { pcpId, collateralToken, coinObjects = [], indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), } = position;
|
|
335
370
|
let innerIsTakeProfitOrder = isTakeProfitOrder;
|
|
336
371
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
|
|
337
372
|
const coinObject = this.processCoins(tx, collateralToken, coinObjects);
|
|
338
373
|
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)]);
|
|
339
|
-
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 :
|
|
340
|
-
const adjustCollateralPrice = this.processSlippage(collateralPrice, false,
|
|
374
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
375
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
341
376
|
let allowTrade = ALLOW_TRADE_MUST_TRADE;
|
|
342
377
|
if (isTriggerOrder) {
|
|
343
378
|
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
|
|
@@ -352,7 +387,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
352
387
|
this.consts.coins[collateralToken].module,
|
|
353
388
|
this.consts.coins[indexToken].module,
|
|
354
389
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
355
|
-
this.consts.coins
|
|
390
|
+
this.consts.coins.sui.module,
|
|
356
391
|
],
|
|
357
392
|
arguments: [
|
|
358
393
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -418,18 +453,21 @@ export class SLPAPI extends BaseAPI {
|
|
|
418
453
|
});
|
|
419
454
|
return tx;
|
|
420
455
|
}
|
|
421
|
-
|
|
456
|
+
cancelOrder(orderCapId, collateralToken, indexToken, long, type) {
|
|
422
457
|
const tx = new Transaction();
|
|
423
458
|
let functionName = '';
|
|
424
459
|
switch (type) {
|
|
425
|
-
case 'OPEN_POSITION':
|
|
460
|
+
case 'OPEN_POSITION': {
|
|
426
461
|
functionName = 'clear_open_position_order_v1_1';
|
|
427
462
|
break;
|
|
428
|
-
|
|
463
|
+
}
|
|
464
|
+
case 'DECREASE_POSITION': {
|
|
429
465
|
functionName = 'clear_decrease_position_order_v1_1';
|
|
430
466
|
break;
|
|
431
|
-
|
|
467
|
+
}
|
|
468
|
+
default: {
|
|
432
469
|
throw new Error('invalid order type');
|
|
470
|
+
}
|
|
433
471
|
}
|
|
434
472
|
tx.moveCall({
|
|
435
473
|
target: `${this.consts.sudoCore.upgradedPackage}::market::${functionName}`,
|
|
@@ -438,7 +476,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
438
476
|
this.consts.coins[collateralToken].module,
|
|
439
477
|
this.consts.coins[indexToken].module,
|
|
440
478
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
441
|
-
this.consts.coins
|
|
479
|
+
this.consts.coins.sui.module,
|
|
442
480
|
],
|
|
443
481
|
arguments: [
|
|
444
482
|
tx.object(this.consts.sudoCore.market),
|
|
@@ -447,7 +485,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
447
485
|
});
|
|
448
486
|
return tx;
|
|
449
487
|
}
|
|
450
|
-
|
|
488
|
+
cancelMultiOrders(orders, tx) {
|
|
451
489
|
if (!tx) {
|
|
452
490
|
tx = new Transaction();
|
|
453
491
|
}
|
|
@@ -495,7 +533,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
495
533
|
arguments: [tx.object(this.consts.sudoCore.market), tx.object(pcpId)],
|
|
496
534
|
});
|
|
497
535
|
}
|
|
498
|
-
clearOpenPositionOrder(orderCapId, collateralToken, indexToken, long, tx
|
|
536
|
+
clearOpenPositionOrder(orderCapId, collateralToken, indexToken, long, tx) {
|
|
499
537
|
tx.moveCall({
|
|
500
538
|
target: `${this.consts.sudoCore.upgradedPackage}::market::clear_open_position_order_v1_1`,
|
|
501
539
|
typeArguments: [
|
|
@@ -503,7 +541,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
503
541
|
this.consts.coins[collateralToken].module,
|
|
504
542
|
this.consts.coins[indexToken].module,
|
|
505
543
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
506
|
-
this.consts.coins
|
|
544
|
+
this.consts.coins.sui.module,
|
|
507
545
|
],
|
|
508
546
|
arguments: [
|
|
509
547
|
tx.object(this.consts.sudoCore.market),
|
|
@@ -519,7 +557,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
519
557
|
this.consts.coins[collateralToken].module,
|
|
520
558
|
this.consts.coins[indexToken].module,
|
|
521
559
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
522
|
-
this.consts.coins
|
|
560
|
+
this.consts.coins.sui.module,
|
|
523
561
|
],
|
|
524
562
|
arguments: [
|
|
525
563
|
tx.object(this.consts.sudoCore.market),
|
|
@@ -561,7 +599,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
561
599
|
this.consts.coins[collateralToken].module,
|
|
562
600
|
this.consts.coins[indexToken].module,
|
|
563
601
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
564
|
-
this.consts.coins
|
|
602
|
+
this.consts.coins.sui.module,
|
|
565
603
|
],
|
|
566
604
|
arguments: [
|
|
567
605
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -586,12 +624,12 @@ export class SLPAPI extends BaseAPI {
|
|
|
586
624
|
.return({
|
|
587
625
|
itemType: `${this.consts.sudoNft.package}::card::SudoCard`,
|
|
588
626
|
item: sudoCard,
|
|
589
|
-
promise
|
|
627
|
+
promise,
|
|
590
628
|
})
|
|
591
629
|
.finalize();
|
|
592
630
|
return tx;
|
|
593
631
|
}
|
|
594
|
-
async decreasePositionWithSCard(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5)
|
|
632
|
+
async decreasePositionWithSCard(pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, kioskClient, kioskCap, scard, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5)) {
|
|
595
633
|
const tx = await this.initOracleTxb([collateralToken, indexToken]);
|
|
596
634
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
|
|
597
635
|
const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee)]); // Sudo contract requires SUI as fee
|
|
@@ -599,12 +637,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
599
637
|
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
600
638
|
let allowTrade = ALLOW_TRADE_MUST_TRADE;
|
|
601
639
|
if (isTriggerOrder) {
|
|
602
|
-
|
|
603
|
-
allowTrade = ALLOW_TRADE_NO_TRADE;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
allowTrade = ALLOW_TRADE_CAN_TRADE;
|
|
607
|
-
}
|
|
640
|
+
allowTrade = isIocOrder || !isTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
|
|
608
641
|
}
|
|
609
642
|
else {
|
|
610
643
|
isTakeProfitOrder = true;
|
|
@@ -625,7 +658,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
625
658
|
this.consts.coins[collateralToken].module,
|
|
626
659
|
this.consts.coins[indexToken].module,
|
|
627
660
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
628
|
-
this.consts.coins
|
|
661
|
+
this.consts.coins.sui.module,
|
|
629
662
|
],
|
|
630
663
|
arguments: [
|
|
631
664
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -649,7 +682,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
649
682
|
.return({
|
|
650
683
|
itemType: `${this.consts.sudoNft.package}::card::SudoCard`,
|
|
651
684
|
item: sudoCard,
|
|
652
|
-
promise
|
|
685
|
+
promise,
|
|
653
686
|
})
|
|
654
687
|
.finalize();
|
|
655
688
|
return tx;
|
|
@@ -658,7 +691,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
658
691
|
if (!tx) {
|
|
659
692
|
tx = new Transaction();
|
|
660
693
|
}
|
|
661
|
-
tx = await this.initOracleTxb(positions.
|
|
694
|
+
tx = await this.initOracleTxb(positions.flatMap(position => [position.collateralToken, position.indexToken]), tx);
|
|
662
695
|
const kioskTx = new KioskTransaction({
|
|
663
696
|
transaction: tx,
|
|
664
697
|
kioskClient,
|
|
@@ -669,13 +702,13 @@ export class SLPAPI extends BaseAPI {
|
|
|
669
702
|
itemId: scard,
|
|
670
703
|
});
|
|
671
704
|
for (const position of positions) {
|
|
672
|
-
const { pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder, isTakeProfitOrder, isIocOrder,
|
|
705
|
+
const { pcpId, collateralToken, indexToken, amount, long, indexPrice, collateralPrice, isTriggerOrder = false, isTakeProfitOrder = true, isIocOrder = false, pricesSlippage = 0.003, collateralSlippage = 0.5, relayerFee = BigInt(0.5), coinObjects = [], } = position;
|
|
673
706
|
let innerIsTakeProfitOrder = isTakeProfitOrder;
|
|
674
707
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
|
|
675
708
|
const coinObject = this.processCoins(tx, collateralToken, coinObjects);
|
|
676
709
|
const feeObject = tx.splitCoins(coinObject, [tx.pure.u64(relayerFee)]);
|
|
677
|
-
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 :
|
|
678
|
-
const adjustCollateralPrice = this.processSlippage(collateralPrice, false,
|
|
710
|
+
const adjustPrice = this.processSlippage(indexPrice, !long, isTriggerOrder ? 0 : pricesSlippage);
|
|
711
|
+
const adjustCollateralPrice = this.processSlippage(collateralPrice, false, collateralSlippage);
|
|
679
712
|
let allowTrade = ALLOW_TRADE_MUST_TRADE;
|
|
680
713
|
if (isTriggerOrder) {
|
|
681
714
|
allowTrade = isIocOrder || !innerIsTakeProfitOrder ? ALLOW_TRADE_NO_TRADE : ALLOW_TRADE_CAN_TRADE;
|
|
@@ -690,7 +723,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
690
723
|
this.consts.coins[collateralToken].module,
|
|
691
724
|
this.consts.coins[indexToken].module,
|
|
692
725
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
693
|
-
this.consts.coins
|
|
726
|
+
this.consts.coins.sui.module,
|
|
694
727
|
],
|
|
695
728
|
arguments: [
|
|
696
729
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
@@ -715,7 +748,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
715
748
|
.return({
|
|
716
749
|
itemType: `${this.consts.sudoNft.package}::card::SudoCard`,
|
|
717
750
|
item: sudoCard,
|
|
718
|
-
promise
|
|
751
|
+
promise,
|
|
719
752
|
})
|
|
720
753
|
.finalize();
|
|
721
754
|
return tx;
|
|
@@ -735,16 +768,16 @@ export class SLPAPI extends BaseAPI {
|
|
|
735
768
|
const tx = await this.initOracleTxb([collateralToken, indexToken]);
|
|
736
769
|
return tx;
|
|
737
770
|
}
|
|
738
|
-
|
|
771
|
+
adminSettlePosition(_positionId, _owner, _collateralToken, _indexToken, _long) {
|
|
739
772
|
// SLP does not support this operation
|
|
740
|
-
throw new Error(
|
|
773
|
+
throw new Error(`Method not implemented for ${this.constructor.name}`);
|
|
741
774
|
}
|
|
742
|
-
|
|
743
|
-
const tx =
|
|
775
|
+
adminDecreasePosition(positionId, owner, collateralToken, indexToken, positionAmount, amount, long, collateralPrice, collateralSlippage, relayerFee) {
|
|
776
|
+
const tx = new Transaction();
|
|
744
777
|
const symbol = joinSymbol(long ? 'long' : 'short', indexToken);
|
|
745
778
|
const feeObject = tx.splitCoins(tx.gas, [tx.pure.u64(relayerFee || BigInt(1))]);
|
|
746
779
|
const adjustCollateralPrice = this.processSlippage(collateralPrice || 0, false, collateralSlippage || 0.5);
|
|
747
|
-
|
|
780
|
+
const allowTrade = ALLOW_TRADE_MUST_TRADE;
|
|
748
781
|
tx.moveCall({
|
|
749
782
|
target: `${this.consts.sudoCore.upgradedPackage}::market::admin_decrease_position_v1_3`,
|
|
750
783
|
typeArguments: [
|
|
@@ -752,7 +785,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
752
785
|
this.consts.coins[collateralToken].module,
|
|
753
786
|
this.consts.coins[indexToken].module,
|
|
754
787
|
`${this.consts.sudoCore.package}::market::${long ? 'LONG' : 'SHORT'}`,
|
|
755
|
-
this.consts.coins
|
|
788
|
+
this.consts.coins.sui.module,
|
|
756
789
|
],
|
|
757
790
|
arguments: [
|
|
758
791
|
tx.object(this.consts.sudoCore.adminCap),
|
|
@@ -775,7 +808,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
775
808
|
}
|
|
776
809
|
return tx;
|
|
777
810
|
}
|
|
778
|
-
|
|
811
|
+
adminClearClosedPosition(positionId, owner, collateralToken, indexToken, long, tx) {
|
|
779
812
|
tx.moveCall({
|
|
780
813
|
target: `${this.consts.sudoCore.upgradedPackage}::market::admin_clear_closed_position_v1_1`,
|
|
781
814
|
typeArguments: [
|
|
@@ -793,7 +826,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
793
826
|
});
|
|
794
827
|
}
|
|
795
828
|
// SLP Specific APIs
|
|
796
|
-
|
|
829
|
+
claimTokenFromSCard(token, coinObjects, kioskClient, kioskCap, scard) {
|
|
797
830
|
const tx = new Transaction();
|
|
798
831
|
const kioskTx = new KioskTransaction({
|
|
799
832
|
transaction: tx,
|
|
@@ -805,7 +838,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
805
838
|
itemId: scard,
|
|
806
839
|
});
|
|
807
840
|
// claim tokens
|
|
808
|
-
coinObjects.forEach(coinObject => {
|
|
841
|
+
coinObjects.forEach((coinObject) => {
|
|
809
842
|
return tx.moveCall({
|
|
810
843
|
target: `${this.consts.sudoNft.upgradedPackage}::card::claim_token`,
|
|
811
844
|
typeArguments: [`${this.consts.coins[token].module}`],
|
|
@@ -816,7 +849,7 @@ export class SLPAPI extends BaseAPI {
|
|
|
816
849
|
.return({
|
|
817
850
|
itemType: `${this.consts.sudoNft.package}::card::SudoCard`,
|
|
818
851
|
item: sudoCard,
|
|
819
|
-
promise
|
|
852
|
+
promise,
|
|
820
853
|
})
|
|
821
854
|
.finalize();
|
|
822
855
|
return tx;
|