@scallop-io/sui-scallop-sdk 0.37.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/LICENSE +202 -0
- package/README.md +276 -0
- package/dist/constants/common.d.ts +7 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1487 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1444 -0
- package/dist/index.mjs.map +1 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/scallop.d.ts +46 -0
- package/dist/models/scallopAddress.d.ts +107 -0
- package/dist/models/scallopClient.d.ts +151 -0
- package/dist/models/scallopUtils.d.ts +56 -0
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/market.d.ts +4 -0
- package/dist/queries/obligation.d.ts +8 -0
- package/dist/txBuilders/coin.d.ts +67 -0
- package/dist/txBuilders/index.d.ts +1 -0
- package/dist/txBuilders/normalMethods.d.ts +3 -0
- package/dist/txBuilders/oracle.d.ts +7 -0
- package/dist/txBuilders/quickMethods.d.ts +7 -0
- package/dist/types/data.d.ts +127 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/model.d.ts +9 -0
- package/dist/types/txBuilder.d.ts +66 -0
- package/package.json +147 -0
- package/src/constants/common.ts +36 -0
- package/src/constants/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/models/index.ts +4 -0
- package/src/models/scallop.ts +76 -0
- package/src/models/scallopAddress.ts +460 -0
- package/src/models/scallopClient.ts +461 -0
- package/src/models/scallopUtils.ts +133 -0
- package/src/queries/index.ts +2 -0
- package/src/queries/market.ts +16 -0
- package/src/queries/obligation.ts +44 -0
- package/src/txBuilders/coin.ts +38 -0
- package/src/txBuilders/index.ts +1 -0
- package/src/txBuilders/normalMethods.ts +216 -0
- package/src/txBuilders/oracle.ts +376 -0
- package/src/txBuilders/quickMethods.ts +231 -0
- package/src/types/data.ts +170 -0
- package/src/types/index.ts +3 -0
- package/src/types/model.ts +15 -0
- package/src/types/txBuilder.ts +136 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the complex transaction builder, which contains multiple calls in a single transaction.
|
|
3
|
+
*/
|
|
4
|
+
import { SuiTxBlock, SuiKit } from '@scallop-io/sui-kit';
|
|
5
|
+
import { ScallopAddress, ScallopUtils } from '../models';
|
|
6
|
+
import { getObligations } from '../queries';
|
|
7
|
+
import { newTxBlock } from './normalMethods';
|
|
8
|
+
import {
|
|
9
|
+
updateOraclesForBorrow,
|
|
10
|
+
updateOraclesForWithdrawCollateral,
|
|
11
|
+
updateOracles,
|
|
12
|
+
} from './oracle';
|
|
13
|
+
import { selectCoin, selectMarketCoin } from './coin';
|
|
14
|
+
import type { SuiTxArg } from '@scallop-io/sui-kit';
|
|
15
|
+
import type { ScallopQuickMethodsHandler, ScallopTxBlock } from '../types';
|
|
16
|
+
|
|
17
|
+
const requireSender = (txBlock: SuiTxBlock) => {
|
|
18
|
+
const sender = txBlock.blockData.sender;
|
|
19
|
+
if (!sender) {
|
|
20
|
+
throw new Error('Sender is required');
|
|
21
|
+
}
|
|
22
|
+
return sender;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const requireObligationInfo = async (
|
|
26
|
+
...args: [
|
|
27
|
+
txBlock: SuiTxBlock,
|
|
28
|
+
scallopAddress: ScallopAddress,
|
|
29
|
+
suiKit: SuiKit,
|
|
30
|
+
obligationId?: SuiTxArg | undefined,
|
|
31
|
+
obligationKey?: SuiTxArg | undefined
|
|
32
|
+
]
|
|
33
|
+
) => {
|
|
34
|
+
const [txBlock, scallopAddress, suiKit, obligationId, obligationKey] = args;
|
|
35
|
+
if (args.length === 4 && obligationId) return { obligationId };
|
|
36
|
+
if (args.length === 5 && obligationId && obligationKey)
|
|
37
|
+
return { obligationId, obligationKey };
|
|
38
|
+
const sender = requireSender(txBlock);
|
|
39
|
+
const obligations = await getObligations(sender, scallopAddress, suiKit);
|
|
40
|
+
if (obligations.length === 0) {
|
|
41
|
+
throw new Error(`No obligation found for sender ${sender}`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
obligationId: obligations[0].id,
|
|
45
|
+
obligationKey: obligations[0].keyId,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const scallopQuickMethodsHandler: ScallopQuickMethodsHandler = {
|
|
50
|
+
addCollateralQuick:
|
|
51
|
+
({ txBlock, scallopAddress, scallopUtils, suiKit }) =>
|
|
52
|
+
async (amount, coinName, obligationId) => {
|
|
53
|
+
const sender = requireSender(txBlock);
|
|
54
|
+
const { obligationId: obligationArg } = await requireObligationInfo(
|
|
55
|
+
txBlock,
|
|
56
|
+
scallopAddress,
|
|
57
|
+
suiKit,
|
|
58
|
+
obligationId
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (coinName === 'sui') {
|
|
62
|
+
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
63
|
+
txBlock.addCollateral(obligationArg, suiCoin, coinName);
|
|
64
|
+
} else {
|
|
65
|
+
const { leftCoin, takeCoin } = await selectCoin(
|
|
66
|
+
txBlock,
|
|
67
|
+
scallopAddress,
|
|
68
|
+
scallopUtils,
|
|
69
|
+
coinName,
|
|
70
|
+
amount,
|
|
71
|
+
sender
|
|
72
|
+
);
|
|
73
|
+
txBlock.addCollateral(obligationArg, takeCoin, coinName);
|
|
74
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
takeCollateralQuick:
|
|
78
|
+
({ txBlock, suiKit, scallopUtils, scallopAddress, isTestnet }) =>
|
|
79
|
+
async (amount, coinName, obligationId, obligationKey) => {
|
|
80
|
+
const { obligationId: obligationArg, obligationKey: obligationKeyArg } =
|
|
81
|
+
await requireObligationInfo(
|
|
82
|
+
txBlock,
|
|
83
|
+
scallopAddress,
|
|
84
|
+
suiKit,
|
|
85
|
+
obligationId,
|
|
86
|
+
obligationKey
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
await updateOraclesForWithdrawCollateral(
|
|
90
|
+
txBlock,
|
|
91
|
+
scallopAddress,
|
|
92
|
+
scallopUtils,
|
|
93
|
+
suiKit,
|
|
94
|
+
obligationArg as string,
|
|
95
|
+
isTestnet
|
|
96
|
+
);
|
|
97
|
+
return txBlock.takeCollateral(
|
|
98
|
+
obligationArg,
|
|
99
|
+
obligationKeyArg as SuiTxArg,
|
|
100
|
+
amount,
|
|
101
|
+
coinName
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
depositQuick:
|
|
105
|
+
({ txBlock, scallopUtils, scallopAddress }) =>
|
|
106
|
+
async (amount, coinName) => {
|
|
107
|
+
const sender = requireSender(txBlock);
|
|
108
|
+
if (coinName === 'sui') {
|
|
109
|
+
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
110
|
+
return txBlock.deposit(suiCoin, coinName);
|
|
111
|
+
} else {
|
|
112
|
+
const { leftCoin, takeCoin } = await selectCoin(
|
|
113
|
+
txBlock,
|
|
114
|
+
scallopAddress,
|
|
115
|
+
scallopUtils,
|
|
116
|
+
coinName,
|
|
117
|
+
amount,
|
|
118
|
+
sender
|
|
119
|
+
);
|
|
120
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
121
|
+
return txBlock.deposit(takeCoin, coinName);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
withdrawQuick:
|
|
125
|
+
({ txBlock, scallopUtils, scallopAddress }) =>
|
|
126
|
+
async (amount, coinName) => {
|
|
127
|
+
const sender = requireSender(txBlock);
|
|
128
|
+
const { leftCoin, takeCoin } = await selectMarketCoin(
|
|
129
|
+
txBlock,
|
|
130
|
+
scallopAddress,
|
|
131
|
+
scallopUtils,
|
|
132
|
+
coinName,
|
|
133
|
+
amount,
|
|
134
|
+
sender
|
|
135
|
+
);
|
|
136
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
137
|
+
return txBlock.withdraw(takeCoin, coinName);
|
|
138
|
+
},
|
|
139
|
+
borrowQuick:
|
|
140
|
+
({ txBlock, suiKit, scallopUtils, scallopAddress, isTestnet }) =>
|
|
141
|
+
async (amount, coinName, obligationId, obligationKey) => {
|
|
142
|
+
const { obligationId: obligationArg, obligationKey: obligationKeyArg } =
|
|
143
|
+
await requireObligationInfo(
|
|
144
|
+
txBlock,
|
|
145
|
+
scallopAddress,
|
|
146
|
+
suiKit,
|
|
147
|
+
obligationId,
|
|
148
|
+
obligationKey
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
await updateOraclesForBorrow(
|
|
152
|
+
txBlock,
|
|
153
|
+
scallopAddress,
|
|
154
|
+
scallopUtils,
|
|
155
|
+
suiKit,
|
|
156
|
+
obligationArg as string,
|
|
157
|
+
coinName,
|
|
158
|
+
isTestnet
|
|
159
|
+
);
|
|
160
|
+
return txBlock.borrow(
|
|
161
|
+
obligationArg,
|
|
162
|
+
obligationKeyArg as SuiTxArg,
|
|
163
|
+
amount,
|
|
164
|
+
coinName
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
repayQuick:
|
|
168
|
+
({ txBlock, suiKit, scallopUtils, scallopAddress }) =>
|
|
169
|
+
async (amount, coinName, obligationId) => {
|
|
170
|
+
const sender = requireSender(txBlock);
|
|
171
|
+
const { obligationId: obligationArg } = await requireObligationInfo(
|
|
172
|
+
txBlock,
|
|
173
|
+
scallopAddress,
|
|
174
|
+
suiKit,
|
|
175
|
+
obligationId
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
if (coinName === 'sui') {
|
|
179
|
+
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
180
|
+
return txBlock.repay(obligationArg, suiCoin, coinName);
|
|
181
|
+
} else {
|
|
182
|
+
const { leftCoin, takeCoin } = await selectCoin(
|
|
183
|
+
txBlock,
|
|
184
|
+
scallopAddress,
|
|
185
|
+
scallopUtils,
|
|
186
|
+
coinName,
|
|
187
|
+
amount,
|
|
188
|
+
sender
|
|
189
|
+
);
|
|
190
|
+
txBlock.transferObjects([leftCoin], sender);
|
|
191
|
+
return txBlock.repay(obligationArg, takeCoin, coinName);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
updateAssetPricesQuick:
|
|
195
|
+
({ txBlock, scallopUtils, scallopAddress, isTestnet }) =>
|
|
196
|
+
async (coinNames) => {
|
|
197
|
+
return updateOracles(
|
|
198
|
+
txBlock,
|
|
199
|
+
scallopAddress,
|
|
200
|
+
scallopUtils,
|
|
201
|
+
coinNames,
|
|
202
|
+
isTestnet
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const newScallopTxBlock = (
|
|
208
|
+
suiKit: SuiKit,
|
|
209
|
+
scallopAddress: ScallopAddress,
|
|
210
|
+
scallopUtils: ScallopUtils,
|
|
211
|
+
isTestnet: boolean
|
|
212
|
+
) => {
|
|
213
|
+
const txBlock = newTxBlock(scallopAddress, scallopUtils);
|
|
214
|
+
const txBlockProxy = new Proxy(txBlock, {
|
|
215
|
+
get: (target, prop) => {
|
|
216
|
+
if (prop in scallopQuickMethodsHandler) {
|
|
217
|
+
return scallopQuickMethodsHandler[
|
|
218
|
+
prop as keyof ScallopQuickMethodsHandler
|
|
219
|
+
]({
|
|
220
|
+
txBlock: target,
|
|
221
|
+
suiKit,
|
|
222
|
+
scallopAddress,
|
|
223
|
+
scallopUtils,
|
|
224
|
+
isTestnet,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return target[prop as keyof SuiTxBlock];
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
return txBlockProxy as ScallopTxBlock;
|
|
231
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SUPPORT_ASSET_COINS,
|
|
3
|
+
SUPPORT_COLLATERAL_COINS,
|
|
4
|
+
SUPPORT_ORACLES,
|
|
5
|
+
SUPPORT_PACKAGES,
|
|
6
|
+
} from '../constants/common';
|
|
7
|
+
|
|
8
|
+
export type SupportAssetCoins = (typeof SUPPORT_ASSET_COINS)[number];
|
|
9
|
+
export type SupportCollateralCoins = (typeof SUPPORT_COLLATERAL_COINS)[number];
|
|
10
|
+
export type SupportCoins = SupportAssetCoins | SupportCollateralCoins;
|
|
11
|
+
export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
|
|
12
|
+
export type SupportPackageType = (typeof SUPPORT_PACKAGES)[number];
|
|
13
|
+
|
|
14
|
+
export interface MarketInterface {
|
|
15
|
+
collaterals: {
|
|
16
|
+
collateralFactor: {
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
liquidationDiscount: {
|
|
20
|
+
value: string;
|
|
21
|
+
};
|
|
22
|
+
liquidationFactor: {
|
|
23
|
+
value: string;
|
|
24
|
+
};
|
|
25
|
+
liquidationPanelty: {
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
liquidationReserveFactor: {
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
maxCollateralAmount: string;
|
|
32
|
+
totalCollateralAmount: string;
|
|
33
|
+
type: {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
}[];
|
|
37
|
+
pools: {
|
|
38
|
+
baseBorrowRatePerSec: {
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
borrowIndex: string;
|
|
42
|
+
cash: string;
|
|
43
|
+
debt: string;
|
|
44
|
+
highSlope: {
|
|
45
|
+
value: string;
|
|
46
|
+
};
|
|
47
|
+
interestRate: {
|
|
48
|
+
value: string;
|
|
49
|
+
};
|
|
50
|
+
kink: {
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
53
|
+
lastUpdated: string;
|
|
54
|
+
lowSlope: {
|
|
55
|
+
value: string;
|
|
56
|
+
};
|
|
57
|
+
marketCoinSupply: string;
|
|
58
|
+
minBorrowAmount: string;
|
|
59
|
+
reserve: string;
|
|
60
|
+
reserveFactor: {
|
|
61
|
+
value: string;
|
|
62
|
+
};
|
|
63
|
+
borrowWeight: {
|
|
64
|
+
value: string;
|
|
65
|
+
};
|
|
66
|
+
type: {
|
|
67
|
+
name: string;
|
|
68
|
+
};
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ObligationInterface {
|
|
73
|
+
collaterals: {
|
|
74
|
+
type: {
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
amount: string;
|
|
78
|
+
}[];
|
|
79
|
+
debts: {
|
|
80
|
+
type: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
amount: string;
|
|
84
|
+
borrowIndex: string;
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface AddressesInterface {
|
|
89
|
+
core: {
|
|
90
|
+
version: string;
|
|
91
|
+
versionCap: string;
|
|
92
|
+
market: string;
|
|
93
|
+
adminCap: string;
|
|
94
|
+
coinDecimalsRegistry: string;
|
|
95
|
+
coins: Partial<
|
|
96
|
+
Record<
|
|
97
|
+
SupportCoins,
|
|
98
|
+
{
|
|
99
|
+
id: string;
|
|
100
|
+
treasury: string;
|
|
101
|
+
metaData: string;
|
|
102
|
+
oracle: {
|
|
103
|
+
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
104
|
+
? string
|
|
105
|
+
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
106
|
+
? string
|
|
107
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
108
|
+
? {
|
|
109
|
+
feed: string;
|
|
110
|
+
feedObject: string;
|
|
111
|
+
}
|
|
112
|
+
: never;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
>
|
|
116
|
+
>;
|
|
117
|
+
oracles: {
|
|
118
|
+
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
119
|
+
? {
|
|
120
|
+
registry: string;
|
|
121
|
+
registryCap: string;
|
|
122
|
+
holder: string;
|
|
123
|
+
}
|
|
124
|
+
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
125
|
+
? {
|
|
126
|
+
registry: string;
|
|
127
|
+
registryCap: string;
|
|
128
|
+
}
|
|
129
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
130
|
+
? {
|
|
131
|
+
registry: string;
|
|
132
|
+
registryCap: string;
|
|
133
|
+
state: string;
|
|
134
|
+
wormhole: string;
|
|
135
|
+
wormholeState: string;
|
|
136
|
+
}
|
|
137
|
+
: never;
|
|
138
|
+
} & { xOracle: string; xOracleCap: string };
|
|
139
|
+
packages: Partial<
|
|
140
|
+
Record<
|
|
141
|
+
SupportPackageType,
|
|
142
|
+
{
|
|
143
|
+
id: string;
|
|
144
|
+
upgradeCap: string;
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
>;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type AddressPathsProps<T> = T extends string
|
|
152
|
+
? []
|
|
153
|
+
: {
|
|
154
|
+
[K in Extract<keyof T, string>]: [K, ...AddressPathsProps<T[K]>];
|
|
155
|
+
}[Extract<keyof T, string>];
|
|
156
|
+
|
|
157
|
+
type Join<T extends string[], D extends string> = T extends []
|
|
158
|
+
? never
|
|
159
|
+
: T extends [infer F]
|
|
160
|
+
? F
|
|
161
|
+
: T extends [infer F, ...infer R]
|
|
162
|
+
? F extends string
|
|
163
|
+
? `${F}${D}${Join<Extract<R, string[]>, D>}`
|
|
164
|
+
: never
|
|
165
|
+
: string;
|
|
166
|
+
|
|
167
|
+
export type AddressStringPath = Join<
|
|
168
|
+
AddressPathsProps<AddressesInterface>,
|
|
169
|
+
'.'
|
|
170
|
+
>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SuiTransactionBlockResponse,
|
|
3
|
+
TransactionBlock,
|
|
4
|
+
} from '@mysten/sui.js';
|
|
5
|
+
import type { SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
6
|
+
|
|
7
|
+
export type ScallopClientFnReturnType<T extends boolean> = T extends true
|
|
8
|
+
? SuiTransactionBlockResponse
|
|
9
|
+
: TransactionBlock;
|
|
10
|
+
export type ScallopParams = {} & SuiKitParams;
|
|
11
|
+
export type ScallopAddressParams = {
|
|
12
|
+
id: string;
|
|
13
|
+
auth?: string;
|
|
14
|
+
network?: NetworkType;
|
|
15
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { TransactionArgument } from '@mysten/sui.js';
|
|
2
|
+
import type { SuiTxBlock, SuiTxArg, SuiKit } from '@scallop-io/sui-kit';
|
|
3
|
+
import type { ScallopAddress, ScallopUtils } from '../models';
|
|
4
|
+
import type { SupportCollateralCoins, SupportAssetCoins } from './data';
|
|
5
|
+
|
|
6
|
+
type TransactionResult = TransactionArgument & TransactionArgument[];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ========== Scallop Normal Methods ==========
|
|
10
|
+
*/
|
|
11
|
+
export type ScallopNormalMethods = {
|
|
12
|
+
openObligation: () => TransactionResult;
|
|
13
|
+
returnObligation: (
|
|
14
|
+
obligation: SuiTxArg,
|
|
15
|
+
obligationHotPotato: SuiTxArg
|
|
16
|
+
) => void;
|
|
17
|
+
openObligationEntry: () => void;
|
|
18
|
+
addCollateral: (
|
|
19
|
+
obligation: SuiTxArg,
|
|
20
|
+
coin: SuiTxArg,
|
|
21
|
+
coinName: SupportCollateralCoins
|
|
22
|
+
) => void;
|
|
23
|
+
takeCollateral: (
|
|
24
|
+
obligation: SuiTxArg,
|
|
25
|
+
obligationKey: SuiTxArg,
|
|
26
|
+
amount: number,
|
|
27
|
+
coinName: SupportCollateralCoins
|
|
28
|
+
) => TransactionResult;
|
|
29
|
+
deposit: (coin: SuiTxArg, coinName: SupportAssetCoins) => TransactionResult;
|
|
30
|
+
depositEntry: (coin: SuiTxArg, coinName: SupportAssetCoins) => void;
|
|
31
|
+
withdraw: (
|
|
32
|
+
marketCoin: SuiTxArg,
|
|
33
|
+
coinName: SupportAssetCoins
|
|
34
|
+
) => TransactionResult;
|
|
35
|
+
withdrawEntry: (marketCoin: SuiTxArg, coinName: SupportAssetCoins) => void;
|
|
36
|
+
borrow: (
|
|
37
|
+
obligation: SuiTxArg,
|
|
38
|
+
obligationKey: SuiTxArg,
|
|
39
|
+
amount: number,
|
|
40
|
+
coinName: SupportAssetCoins
|
|
41
|
+
) => TransactionResult;
|
|
42
|
+
borrowEntry: (
|
|
43
|
+
obligation: SuiTxArg,
|
|
44
|
+
obligationKey: SuiTxArg,
|
|
45
|
+
amount: number,
|
|
46
|
+
coinName: SupportAssetCoins
|
|
47
|
+
) => void;
|
|
48
|
+
repay: (
|
|
49
|
+
obligation: SuiTxArg,
|
|
50
|
+
coin: SuiTxArg,
|
|
51
|
+
coinName: SupportAssetCoins
|
|
52
|
+
) => void;
|
|
53
|
+
borrowFlashLoan: (
|
|
54
|
+
amount: number,
|
|
55
|
+
coinName: SupportAssetCoins
|
|
56
|
+
) => TransactionResult;
|
|
57
|
+
repayFlashLoan: (
|
|
58
|
+
coin: SuiTxArg,
|
|
59
|
+
loan: SuiTxArg,
|
|
60
|
+
coinName: SupportAssetCoins
|
|
61
|
+
) => void;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type CoreIds = {
|
|
65
|
+
protocolPkg: string;
|
|
66
|
+
market: string;
|
|
67
|
+
version: string;
|
|
68
|
+
dmlR: string; // coinDecimalsRegistry
|
|
69
|
+
oracle: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type ScallopNormalMethodsHandler = {
|
|
73
|
+
[key in keyof ScallopNormalMethods]: (params: {
|
|
74
|
+
txBlock: SuiTxBlock;
|
|
75
|
+
coreIds: CoreIds;
|
|
76
|
+
scallopAddress: ScallopAddress;
|
|
77
|
+
scallopUtils: ScallopUtils;
|
|
78
|
+
}) => ScallopNormalMethods[key];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type SuiTxBlockWithNormalScallopMethods = SuiTxBlock &
|
|
82
|
+
ScallopNormalMethods;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* ========== Scallop Quick Methods ==========
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
export type ScallopQuickMethods = {
|
|
89
|
+
addCollateralQuick: (
|
|
90
|
+
amount: number,
|
|
91
|
+
coinName: SupportCollateralCoins,
|
|
92
|
+
obligationId?: SuiTxArg
|
|
93
|
+
) => Promise<void>;
|
|
94
|
+
takeCollateralQuick: (
|
|
95
|
+
amount: number,
|
|
96
|
+
coinName: SupportCollateralCoins,
|
|
97
|
+
obligationId?: string,
|
|
98
|
+
obligationKey?: string
|
|
99
|
+
) => Promise<TransactionResult>;
|
|
100
|
+
borrowQuick: (
|
|
101
|
+
amount: number,
|
|
102
|
+
coinName: SupportAssetCoins,
|
|
103
|
+
obligationId?: string,
|
|
104
|
+
obligationKey?: string
|
|
105
|
+
) => Promise<TransactionResult>;
|
|
106
|
+
depositQuick: (
|
|
107
|
+
amount: number,
|
|
108
|
+
coinName: SupportAssetCoins
|
|
109
|
+
) => Promise<TransactionResult>;
|
|
110
|
+
withdrawQuick: (
|
|
111
|
+
amount: number,
|
|
112
|
+
coinName: SupportAssetCoins
|
|
113
|
+
) => Promise<TransactionResult>;
|
|
114
|
+
repayQuick: (
|
|
115
|
+
amount: number,
|
|
116
|
+
coinName: SupportAssetCoins,
|
|
117
|
+
obligationId?: string
|
|
118
|
+
) => Promise<void>;
|
|
119
|
+
updateAssetPricesQuick: (coinNames: SupportAssetCoins[]) => Promise<void>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type ScallopQuickMethodsHandler = {
|
|
123
|
+
[key in keyof ScallopQuickMethods]: (params: {
|
|
124
|
+
txBlock: SuiTxBlockWithNormalScallopMethods;
|
|
125
|
+
suiKit: SuiKit;
|
|
126
|
+
scallopAddress: ScallopAddress;
|
|
127
|
+
scallopUtils: ScallopUtils;
|
|
128
|
+
isTestnet: boolean;
|
|
129
|
+
}) => ScallopQuickMethods[key];
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* ========== Scallop Tx Block ==========
|
|
134
|
+
*/
|
|
135
|
+
export type ScallopTxBlock = SuiTxBlockWithNormalScallopMethods &
|
|
136
|
+
ScallopQuickMethods;
|