@scallop-io/sui-scallop-sdk 1.4.2-rc.5 → 1.4.3-rc.1
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/index.js +92 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -96
- package/dist/index.mjs.map +1 -1
- package/dist/types/builder/borrowIncentive.d.ts +5 -5
- package/dist/types/builder/core.d.ts +15 -19
- package/dist/types/builder/loyaltyProgram.d.ts +1 -1
- package/dist/types/builder/referral.d.ts +4 -4
- package/dist/types/builder/sCoin.d.ts +2 -2
- package/dist/types/builder/spool.d.ts +4 -4
- package/dist/types/builder/vesca.d.ts +6 -6
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +16 -23
- package/src/builders/coreBuilder.ts +42 -40
- package/src/builders/loyaltyProgramBuilder.ts +2 -2
- package/src/builders/referralBuilder.ts +8 -11
- package/src/builders/sCoinBuilder.ts +4 -4
- package/src/builders/spoolBuilder.ts +11 -11
- package/src/builders/vescaBuilder.ts +12 -16
- package/src/models/scallopClient.ts +10 -15
- package/src/types/builder/borrowIncentive.ts +5 -8
- package/src/types/builder/core.ts +30 -17
- package/src/types/builder/loyaltyProgram.ts +1 -1
- package/src/types/builder/referral.ts +4 -6
- package/src/types/builder/sCoin.ts +2 -2
- package/src/types/builder/spool.ts +4 -4
- package/src/types/builder/vesca.ts +6 -9
|
@@ -11,11 +11,11 @@ export type BorrowIncentiveIds = {
|
|
|
11
11
|
obligationAccessStore: string;
|
|
12
12
|
};
|
|
13
13
|
export type BorrowIncentiveNormalMethods = {
|
|
14
|
-
stakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) =>
|
|
15
|
-
stakeObligationWithVesca: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, veScaKey: SuiObjectArg) =>
|
|
16
|
-
unstakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) =>
|
|
17
|
-
claimBorrowIncentive: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, rewardType: SupportBorrowIncentiveRewardCoins) =>
|
|
18
|
-
deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) =>
|
|
14
|
+
stakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) => void;
|
|
15
|
+
stakeObligationWithVesca: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
16
|
+
unstakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) => void;
|
|
17
|
+
claimBorrowIncentive: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, rewardType: SupportBorrowIncentiveRewardCoins) => TransactionResult;
|
|
18
|
+
deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
19
19
|
};
|
|
20
20
|
export type BorrowIncentiveQuickMethods = {
|
|
21
21
|
stakeObligationQuick(obligation?: string, obligationKey?: string): Promise<void>;
|
|
@@ -17,25 +17,21 @@ type Obligation = NestedResult;
|
|
|
17
17
|
type ObligationKey = NestedResult;
|
|
18
18
|
type ObligationHotPotato = NestedResult;
|
|
19
19
|
export type CoreNormalMethods = {
|
|
20
|
-
openObligation: () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
36
|
-
repay: (obligation: SuiObjectArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => Promise<void>;
|
|
37
|
-
borrowFlashLoan: (amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
38
|
-
repayFlashLoan: (coin: SuiObjectArg, loan: SuiObjectArg, poolCoinName: SupportPoolCoins) => Promise<void>;
|
|
20
|
+
openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
|
|
21
|
+
returnObligation: (obligation: SuiObjectArg, obligationHotPotato: SuiObjectArg) => void;
|
|
22
|
+
openObligationEntry: () => void;
|
|
23
|
+
addCollateral: (obligation: SuiObjectArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
|
|
24
|
+
takeCollateral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, collateralCoinName: SupportCollateralCoins) => TransactionResult;
|
|
25
|
+
deposit: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
26
|
+
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
27
|
+
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
28
|
+
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
29
|
+
borrow: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
30
|
+
borrowWithReferral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, borrowReferral: SuiObjectArg, amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
31
|
+
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
32
|
+
repay: (obligation: SuiObjectArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
33
|
+
borrowFlashLoan: (amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
34
|
+
repayFlashLoan: (coin: SuiObjectArg, loan: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
39
35
|
};
|
|
40
36
|
export type CoreQuickMethods = {
|
|
41
37
|
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiObjectArg) => Promise<void>;
|
|
@@ -6,7 +6,7 @@ export type LoyaltyProgramIds = {
|
|
|
6
6
|
userRewardTableId: string;
|
|
7
7
|
};
|
|
8
8
|
export type LoyaltyProgramNormalMethods = {
|
|
9
|
-
claimLoyaltyRevenue: (veScaKey: SuiObjectArg) =>
|
|
9
|
+
claimLoyaltyRevenue: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
10
10
|
};
|
|
11
11
|
export type LoyaltyProgramQuickMethods = {
|
|
12
12
|
claimLoyaltyRevenueQuick: (veScaKey?: SuiObjectArg) => Promise<void>;
|
|
@@ -10,10 +10,10 @@ export type ReferralIds = {
|
|
|
10
10
|
version: string;
|
|
11
11
|
};
|
|
12
12
|
export type ReferralNormalMethods = {
|
|
13
|
-
bindToReferral: (veScaKeyId: string) =>
|
|
14
|
-
claimReferralTicket: (poolCoinName: SupportPoolCoins) =>
|
|
15
|
-
burnReferralTicket: (ticket: SuiObjectArg, poolCoinName: SupportPoolCoins) =>
|
|
16
|
-
claimReferralRevenue: (veScaKey: SuiObjectArg, poolCoinName: SupportPoolCoins) =>
|
|
13
|
+
bindToReferral: (veScaKeyId: string) => void;
|
|
14
|
+
claimReferralTicket: (poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
15
|
+
burnReferralTicket: (ticket: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
16
|
+
claimReferralRevenue: (veScaKey: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
17
17
|
};
|
|
18
18
|
export type ReferralQuickMethods = {
|
|
19
19
|
claimReferralRevenueQuick: (veScaKey: SuiObjectArg, coinNames: SupportPoolCoins[]) => Promise<void>;
|
|
@@ -12,14 +12,14 @@ export type sCoinNormalMethods = {
|
|
|
12
12
|
* @param marketCoin
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
mintSCoin: (marketCoinName: SupportSCoin, marketCoin: SuiObjectArg) =>
|
|
15
|
+
mintSCoin: (marketCoinName: SupportSCoin, marketCoin: SuiObjectArg) => TransactionResult;
|
|
16
16
|
/**
|
|
17
17
|
* Burn sCoin and return marketCoin
|
|
18
18
|
* @param sCoinName
|
|
19
19
|
* @param sCoin
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
|
-
burnSCoin: (sCoinName: SupportSCoin, sCoin: SuiObjectArg) =>
|
|
22
|
+
burnSCoin: (sCoinName: SupportSCoin, sCoin: SuiObjectArg) => TransactionResult;
|
|
23
23
|
};
|
|
24
24
|
export type sCoinQuickMethods = {
|
|
25
25
|
mintSCoinQuick: (marketCoinName: SupportSCoin, amount: number) => Promise<TransactionResult>;
|
|
@@ -7,10 +7,10 @@ export type SpoolIds = {
|
|
|
7
7
|
spoolPkg: string;
|
|
8
8
|
};
|
|
9
9
|
export type SpoolNormalMethods = {
|
|
10
|
-
createStakeAccount: (stakeMarketCoinName: SupportStakeMarketCoins) =>
|
|
11
|
-
stake: (stakeAccount: SuiAddressArg, coin: SuiObjectArg, stakeMarketCoinName: SupportStakeMarketCoins) =>
|
|
12
|
-
unstake: (stakeAccount: SuiAddressArg, amount: number, stakeMarketCoinName: SupportStakeMarketCoins) =>
|
|
13
|
-
claim: (stakeAccount: SuiAddressArg, stakeMarketCoinName: SupportStakeMarketCoins) =>
|
|
10
|
+
createStakeAccount: (stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
11
|
+
stake: (stakeAccount: SuiAddressArg, coin: SuiObjectArg, stakeMarketCoinName: SupportStakeMarketCoins) => void;
|
|
12
|
+
unstake: (stakeAccount: SuiAddressArg, amount: number, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
13
|
+
claim: (stakeAccount: SuiAddressArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
14
14
|
};
|
|
15
15
|
export type SpoolQuickMethods = {
|
|
16
16
|
stakeQuick(amountOrMarketCoin: SuiObjectArg | number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<void>;
|
|
@@ -8,12 +8,12 @@ export type VescaIds = {
|
|
|
8
8
|
config: string;
|
|
9
9
|
};
|
|
10
10
|
export type VeScaNormalMethods = {
|
|
11
|
-
lockSca: (scaCoin: SuiObjectArg, unlockAtInSecondTimestamp: number) =>
|
|
12
|
-
extendLockPeriod: (veScaKey: SuiObjectArg, newUnlockAtInSecondTimestamp: number) =>
|
|
13
|
-
extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) =>
|
|
14
|
-
renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp: number) =>
|
|
15
|
-
redeemSca: (veScaKey: SuiObjectArg) =>
|
|
16
|
-
mintEmptyVeSca: () =>
|
|
11
|
+
lockSca: (scaCoin: SuiObjectArg, unlockAtInSecondTimestamp: number) => TransactionResult;
|
|
12
|
+
extendLockPeriod: (veScaKey: SuiObjectArg, newUnlockAtInSecondTimestamp: number) => void;
|
|
13
|
+
extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) => void;
|
|
14
|
+
renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp: number) => void;
|
|
15
|
+
redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
16
|
+
mintEmptyVeSca: () => TransactionResult;
|
|
17
17
|
};
|
|
18
18
|
export type RedeemScaQuickReturnType<T extends boolean> = T extends true ? void : TransactionResult | undefined;
|
|
19
19
|
export type VeScaQuickMethods = {
|
package/package.json
CHANGED
|
@@ -97,8 +97,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
return {
|
|
100
|
-
stakeObligation:
|
|
101
|
-
|
|
100
|
+
stakeObligation: (obligationId, obligationKey) => {
|
|
101
|
+
builder.moveCall(
|
|
102
102
|
txBlock,
|
|
103
103
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
104
104
|
[
|
|
@@ -112,12 +112,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
112
112
|
]
|
|
113
113
|
);
|
|
114
114
|
},
|
|
115
|
-
stakeObligationWithVesca:
|
|
116
|
-
|
|
117
|
-
obligationKey,
|
|
118
|
-
veScaKey
|
|
119
|
-
) => {
|
|
120
|
-
await builder.moveCall(
|
|
115
|
+
stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
|
|
116
|
+
builder.moveCall(
|
|
121
117
|
txBlock,
|
|
122
118
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
|
|
123
119
|
[
|
|
@@ -136,8 +132,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
136
132
|
[]
|
|
137
133
|
);
|
|
138
134
|
},
|
|
139
|
-
unstakeObligation:
|
|
140
|
-
|
|
135
|
+
unstakeObligation: (obligationId, obligationKey) => {
|
|
136
|
+
builder.moveCall(
|
|
141
137
|
txBlock,
|
|
142
138
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
143
139
|
[
|
|
@@ -150,13 +146,9 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
150
146
|
]
|
|
151
147
|
);
|
|
152
148
|
},
|
|
153
|
-
claimBorrowIncentive:
|
|
154
|
-
obligationId,
|
|
155
|
-
obligationKey,
|
|
156
|
-
rewardCoinName
|
|
157
|
-
) => {
|
|
149
|
+
claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
|
|
158
150
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
159
|
-
return
|
|
151
|
+
return builder.moveCall(
|
|
160
152
|
txBlock,
|
|
161
153
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
162
154
|
[
|
|
@@ -170,8 +162,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
170
162
|
[rewardType]
|
|
171
163
|
);
|
|
172
164
|
},
|
|
173
|
-
deactivateBoost:
|
|
174
|
-
|
|
165
|
+
deactivateBoost: (obligation, veScaKey) => {
|
|
166
|
+
builder.moveCall(
|
|
175
167
|
txBlock,
|
|
176
168
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
|
|
177
169
|
[
|
|
@@ -225,7 +217,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
225
217
|
);
|
|
226
218
|
|
|
227
219
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
228
|
-
|
|
220
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
229
221
|
}
|
|
230
222
|
},
|
|
231
223
|
stakeObligationWithVeScaQuick: async (
|
|
@@ -260,9 +252,9 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
260
252
|
|
|
261
253
|
const _veScaKey = bindedVeScaKey ?? veScaKey;
|
|
262
254
|
if (!_veScaKey) {
|
|
263
|
-
|
|
255
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
264
256
|
} else {
|
|
265
|
-
|
|
257
|
+
txBlock.stakeObligationWithVesca(
|
|
266
258
|
obligationArg,
|
|
267
259
|
obligationKeyArg,
|
|
268
260
|
_veScaKey
|
|
@@ -283,7 +275,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
283
275
|
);
|
|
284
276
|
|
|
285
277
|
if (obligationLocked) {
|
|
286
|
-
|
|
278
|
+
txBlock.unstakeObligation(obligationArg, obligationKeyArg);
|
|
287
279
|
}
|
|
288
280
|
},
|
|
289
281
|
claimBorrowIncentiveQuick: async (
|
|
@@ -300,7 +292,8 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
300
292
|
obligationKey
|
|
301
293
|
);
|
|
302
294
|
|
|
303
|
-
return await txBlock.claimBorrowIncentive(
|
|
295
|
+
// return await txBlock.claimBorrowIncentive(
|
|
296
|
+
return txBlock.claimBorrowIncentive(
|
|
304
297
|
obligationArg,
|
|
305
298
|
obligationKeyArg,
|
|
306
299
|
rewardCoinName
|
|
@@ -77,50 +77,45 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
77
77
|
const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
|
|
78
78
|
|
|
79
79
|
return {
|
|
80
|
-
openObligation:
|
|
81
|
-
const [obligation, obligationKey, obligationHotPotato] =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
80
|
+
openObligation: () => {
|
|
81
|
+
const [obligation, obligationKey, obligationHotPotato] = builder.moveCall(
|
|
82
|
+
txBlock,
|
|
83
|
+
`${coreIds.protocolPkg}::open_obligation::open_obligation`,
|
|
84
|
+
[coreIds.version]
|
|
85
|
+
);
|
|
87
86
|
return [obligation, obligationKey, obligationHotPotato] as [
|
|
88
87
|
NestedResult,
|
|
89
88
|
NestedResult,
|
|
90
89
|
NestedResult,
|
|
91
90
|
];
|
|
92
91
|
},
|
|
93
|
-
returnObligation:
|
|
94
|
-
|
|
92
|
+
returnObligation: (obligation, obligationHotPotato) => {
|
|
93
|
+
builder.moveCall(
|
|
95
94
|
txBlock,
|
|
96
95
|
`${coreIds.protocolPkg}::open_obligation::return_obligation`,
|
|
97
96
|
[coreIds.version, obligation, obligationHotPotato]
|
|
98
97
|
);
|
|
99
98
|
},
|
|
100
|
-
openObligationEntry:
|
|
101
|
-
|
|
99
|
+
openObligationEntry: () => {
|
|
100
|
+
builder.moveCall(
|
|
102
101
|
txBlock,
|
|
103
102
|
`${coreIds.protocolPkg}::open_obligation::open_obligation_entry`,
|
|
104
103
|
[coreIds.version]
|
|
105
104
|
);
|
|
106
105
|
},
|
|
107
|
-
addCollateral:
|
|
106
|
+
addCollateral: (obligation, coin, collateralCoinName) => {
|
|
108
107
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
109
|
-
|
|
108
|
+
builder.moveCall(
|
|
110
109
|
txBlock,
|
|
111
110
|
`${coreIds.protocolPkg}::deposit_collateral::deposit_collateral`,
|
|
112
111
|
[coreIds.version, obligation, coreIds.market, coin],
|
|
113
112
|
[coinType]
|
|
114
113
|
);
|
|
115
114
|
},
|
|
116
|
-
takeCollateral:
|
|
117
|
-
obligation,
|
|
118
|
-
obligationKey,
|
|
119
|
-
amount,
|
|
120
|
-
collateralCoinName
|
|
121
|
-
) => {
|
|
115
|
+
takeCollateral: (obligation, obligationKey, amount, collateralCoinName) => {
|
|
122
116
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
123
|
-
return await builder.moveCall(
|
|
117
|
+
// return await builder.moveCall(
|
|
118
|
+
return builder.moveCall(
|
|
124
119
|
txBlock,
|
|
125
120
|
`${coreIds.protocolPkg}::withdraw_collateral::withdraw_collateral`,
|
|
126
121
|
[
|
|
@@ -136,45 +131,50 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
136
131
|
[coinType]
|
|
137
132
|
);
|
|
138
133
|
},
|
|
139
|
-
deposit:
|
|
134
|
+
deposit: (coin, poolCoinName) => {
|
|
140
135
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
141
|
-
return await builder.moveCall(
|
|
136
|
+
// return await builder.moveCall(
|
|
137
|
+
return builder.moveCall(
|
|
142
138
|
txBlock,
|
|
143
139
|
`${coreIds.protocolPkg}::mint::mint`,
|
|
144
140
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
|
|
145
141
|
[coinType]
|
|
146
142
|
);
|
|
147
143
|
},
|
|
148
|
-
depositEntry:
|
|
144
|
+
depositEntry: (coin, poolCoinName) => {
|
|
149
145
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
150
|
-
return await builder.moveCall(
|
|
146
|
+
// return await builder.moveCall(
|
|
147
|
+
return builder.moveCall(
|
|
151
148
|
txBlock,
|
|
152
149
|
`${coreIds.protocolPkg}::mint::mint_entry`,
|
|
153
150
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
|
|
154
151
|
[coinType]
|
|
155
152
|
);
|
|
156
153
|
},
|
|
157
|
-
withdraw:
|
|
154
|
+
withdraw: (marketCoin, poolCoinName) => {
|
|
158
155
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
159
|
-
return await builder.moveCall(
|
|
156
|
+
// return await builder.moveCall(
|
|
157
|
+
return builder.moveCall(
|
|
160
158
|
txBlock,
|
|
161
159
|
`${coreIds.protocolPkg}::redeem::redeem`,
|
|
162
160
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
|
|
163
161
|
[coinType]
|
|
164
162
|
);
|
|
165
163
|
},
|
|
166
|
-
withdrawEntry:
|
|
164
|
+
withdrawEntry: (marketCoin, poolCoinName) => {
|
|
167
165
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
168
|
-
return await builder.moveCall(
|
|
166
|
+
// return await builder.moveCall(
|
|
167
|
+
return builder.moveCall(
|
|
169
168
|
txBlock,
|
|
170
169
|
`${coreIds.protocolPkg}::redeem::redeem_entry`,
|
|
171
170
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
|
|
172
171
|
[coinType]
|
|
173
172
|
);
|
|
174
173
|
},
|
|
175
|
-
borrow:
|
|
174
|
+
borrow: (obligation, obligationKey, amount, poolCoinName) => {
|
|
176
175
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
177
|
-
return await builder.moveCall(
|
|
176
|
+
// return await builder.moveCall(
|
|
177
|
+
return builder.moveCall(
|
|
178
178
|
txBlock,
|
|
179
179
|
`${coreIds.protocolPkg}::borrow::borrow`,
|
|
180
180
|
[
|
|
@@ -190,7 +190,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
190
190
|
[coinType]
|
|
191
191
|
);
|
|
192
192
|
},
|
|
193
|
-
borrowWithReferral:
|
|
193
|
+
borrowWithReferral: (
|
|
194
194
|
obligation,
|
|
195
195
|
obligationKey,
|
|
196
196
|
borrowReferral,
|
|
@@ -198,7 +198,8 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
198
198
|
poolCoinName
|
|
199
199
|
) => {
|
|
200
200
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
201
|
-
return await builder.moveCall(
|
|
201
|
+
// return await builder.moveCall(
|
|
202
|
+
return builder.moveCall(
|
|
202
203
|
txBlock,
|
|
203
204
|
`${coreIds.protocolPkg}::borrow::borrow_with_referral`,
|
|
204
205
|
[
|
|
@@ -215,9 +216,10 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
215
216
|
[coinType, referralWitnessType]
|
|
216
217
|
);
|
|
217
218
|
},
|
|
218
|
-
borrowEntry:
|
|
219
|
+
borrowEntry: (obligation, obligationKey, amount, poolCoinName) => {
|
|
219
220
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
220
|
-
return await builder.moveCall(
|
|
221
|
+
// return await builder.moveCall(
|
|
222
|
+
return builder.moveCall(
|
|
221
223
|
txBlock,
|
|
222
224
|
`${coreIds.protocolPkg}::borrow::borrow_entry`,
|
|
223
225
|
[
|
|
@@ -233,9 +235,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
233
235
|
[coinType]
|
|
234
236
|
);
|
|
235
237
|
},
|
|
236
|
-
repay:
|
|
238
|
+
repay: (obligation, coin, poolCoinName) => {
|
|
237
239
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
238
|
-
|
|
240
|
+
builder.moveCall(
|
|
239
241
|
txBlock,
|
|
240
242
|
`${coreIds.protocolPkg}::repay::repay`,
|
|
241
243
|
[
|
|
@@ -248,18 +250,18 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
248
250
|
[coinType]
|
|
249
251
|
);
|
|
250
252
|
},
|
|
251
|
-
borrowFlashLoan:
|
|
253
|
+
borrowFlashLoan: (amount, poolCoinName) => {
|
|
252
254
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
253
|
-
return
|
|
255
|
+
return builder.moveCall(
|
|
254
256
|
txBlock,
|
|
255
257
|
`${coreIds.protocolPkg}::flash_loan::borrow_flash_loan`,
|
|
256
258
|
[coreIds.version, coreIds.market, amount],
|
|
257
259
|
[coinType]
|
|
258
260
|
);
|
|
259
261
|
},
|
|
260
|
-
repayFlashLoan:
|
|
262
|
+
repayFlashLoan: (coin, loan, poolCoinName) => {
|
|
261
263
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
262
|
-
|
|
264
|
+
builder.moveCall(
|
|
263
265
|
txBlock,
|
|
264
266
|
`${coreIds.protocolPkg}::flash_loan::repay_flash_loan`,
|
|
265
267
|
[coreIds.version, coreIds.market, coin, loan],
|
|
@@ -23,8 +23,8 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
|
-
claimLoyaltyRevenue:
|
|
27
|
-
return
|
|
26
|
+
claimLoyaltyRevenue: (veScaKey) => {
|
|
27
|
+
return builder.moveCall(
|
|
28
28
|
txBlock,
|
|
29
29
|
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
30
30
|
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
@@ -34,8 +34,8 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
34
34
|
const veScaTable = builder.address.get('vesca.table');
|
|
35
35
|
|
|
36
36
|
return {
|
|
37
|
-
bindToReferral:
|
|
38
|
-
|
|
37
|
+
bindToReferral: (veScaKeyId: string) => {
|
|
38
|
+
builder.moveCall(
|
|
39
39
|
txBlock,
|
|
40
40
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
41
41
|
[
|
|
@@ -47,9 +47,9 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
47
47
|
[]
|
|
48
48
|
);
|
|
49
49
|
},
|
|
50
|
-
claimReferralTicket:
|
|
50
|
+
claimReferralTicket: (poolCoinName: SupportCoins) => {
|
|
51
51
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
52
|
-
return
|
|
52
|
+
return builder.moveCall(
|
|
53
53
|
txBlock,
|
|
54
54
|
`${referralIds.referralPgkId}::scallop_referral_program::claim_ve_sca_referral_ticket`,
|
|
55
55
|
[
|
|
@@ -63,12 +63,9 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
63
63
|
[coinType]
|
|
64
64
|
);
|
|
65
65
|
},
|
|
66
|
-
burnReferralTicket:
|
|
67
|
-
ticket: SuiObjectArg,
|
|
68
|
-
poolCoinName: SupportCoins
|
|
69
|
-
) => {
|
|
66
|
+
burnReferralTicket: (ticket: SuiObjectArg, poolCoinName: SupportCoins) => {
|
|
70
67
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
71
|
-
|
|
68
|
+
builder.moveCall(
|
|
72
69
|
txBlock,
|
|
73
70
|
`${referralIds.referralPgkId}::scallop_referral_program::burn_ve_sca_referral_ticket`,
|
|
74
71
|
[
|
|
@@ -80,12 +77,12 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
80
77
|
[coinType]
|
|
81
78
|
);
|
|
82
79
|
},
|
|
83
|
-
claimReferralRevenue:
|
|
80
|
+
claimReferralRevenue: (
|
|
84
81
|
veScaKey: SuiObjectArg,
|
|
85
82
|
poolCoinName: SupportCoins
|
|
86
83
|
) => {
|
|
87
84
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
88
|
-
return
|
|
85
|
+
return builder.moveCall(
|
|
89
86
|
txBlock,
|
|
90
87
|
`${referralIds.referralPgkId}::referral_revenue_pool::claim_revenue_with_ve_sca_key`,
|
|
91
88
|
[
|
|
@@ -20,8 +20,8 @@ const generateSCoinNormalMethod: GenerateSCoinNormalMethod = ({
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
return {
|
|
23
|
-
mintSCoin:
|
|
24
|
-
return
|
|
23
|
+
mintSCoin: (marketCoinName, marketCoin) => {
|
|
24
|
+
return builder.moveCall(
|
|
25
25
|
txBlock,
|
|
26
26
|
`${sCoinPkgIds.pkgId}::s_coin_converter::mint_s_coin`,
|
|
27
27
|
[builder.utils.getSCoinTreasury(marketCoinName), marketCoin],
|
|
@@ -31,8 +31,8 @@ const generateSCoinNormalMethod: GenerateSCoinNormalMethod = ({
|
|
|
31
31
|
]
|
|
32
32
|
);
|
|
33
33
|
},
|
|
34
|
-
burnSCoin:
|
|
35
|
-
return
|
|
34
|
+
burnSCoin: (sCoinName, sCoin) => {
|
|
35
|
+
return builder.moveCall(
|
|
36
36
|
txBlock,
|
|
37
37
|
`${sCoinPkgIds.pkgId}::s_coin_converter::burn_s_coin`,
|
|
38
38
|
[builder.utils.getSCoinTreasury(sCoinName), sCoin],
|
|
@@ -100,10 +100,10 @@ const stakeHelper = async (
|
|
|
100
100
|
? await builder.selectSCoin(txBlock, coinName, amount, sender)
|
|
101
101
|
: await builder.selectMarketCoin(txBlock, coinName, amount, sender);
|
|
102
102
|
if (isSCoin) {
|
|
103
|
-
const marketCoin =
|
|
104
|
-
|
|
103
|
+
const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
|
|
104
|
+
txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
105
105
|
} else {
|
|
106
|
-
|
|
106
|
+
txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
107
107
|
}
|
|
108
108
|
txBlock.transferObjects([leftCoin], sender);
|
|
109
109
|
return totalAmount;
|
|
@@ -127,46 +127,46 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
127
127
|
spoolPkg: builder.address.get('spool.id'),
|
|
128
128
|
};
|
|
129
129
|
return {
|
|
130
|
-
createStakeAccount:
|
|
130
|
+
createStakeAccount: (stakeMarketCoinName) => {
|
|
131
131
|
const marketCoinType =
|
|
132
132
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
133
133
|
const stakePoolId = builder.address.get(
|
|
134
134
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
135
135
|
);
|
|
136
|
-
return
|
|
136
|
+
return builder.moveCall(
|
|
137
137
|
txBlock,
|
|
138
138
|
`${spoolIds.spoolPkg}::user::new_spool_account`,
|
|
139
139
|
[stakePoolId, SUI_CLOCK_OBJECT_ID],
|
|
140
140
|
[marketCoinType]
|
|
141
141
|
);
|
|
142
142
|
},
|
|
143
|
-
stake:
|
|
143
|
+
stake: (stakeAccount, coin, stakeMarketCoinName) => {
|
|
144
144
|
const marketCoinType =
|
|
145
145
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
146
146
|
const stakePoolId = builder.address.get(
|
|
147
147
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
148
148
|
);
|
|
149
|
-
|
|
149
|
+
builder.moveCall(
|
|
150
150
|
txBlock,
|
|
151
151
|
`${spoolIds.spoolPkg}::user::stake`,
|
|
152
152
|
[stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID],
|
|
153
153
|
[marketCoinType]
|
|
154
154
|
);
|
|
155
155
|
},
|
|
156
|
-
unstake:
|
|
156
|
+
unstake: (stakeAccount, amount, stakeMarketCoinName) => {
|
|
157
157
|
const marketCoinType =
|
|
158
158
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
159
159
|
const stakePoolId = builder.address.get(
|
|
160
160
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
161
161
|
);
|
|
162
|
-
return
|
|
162
|
+
return builder.moveCall(
|
|
163
163
|
txBlock,
|
|
164
164
|
`${spoolIds.spoolPkg}::user::unstake`,
|
|
165
165
|
[stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID],
|
|
166
166
|
[marketCoinType]
|
|
167
167
|
);
|
|
168
168
|
},
|
|
169
|
-
claim:
|
|
169
|
+
claim: (stakeAccount, stakeMarketCoinName) => {
|
|
170
170
|
const stakePoolId = builder.address.get(
|
|
171
171
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
172
172
|
) as string;
|
|
@@ -177,7 +177,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
177
177
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
178
178
|
const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
|
|
179
179
|
const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
|
|
180
|
-
return
|
|
180
|
+
return builder.moveCall(
|
|
181
181
|
txBlock,
|
|
182
182
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
183
183
|
[stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID],
|