@scallop-io/sui-scallop-sdk 0.47.0 → 0.47.2
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 +253 -247
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +256 -250
- package/dist/index.mjs.map +1 -1
- package/dist/queries/borrowIncentiveQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +14 -25
- package/src/builders/vescaBuilder.ts +2 -1
- package/src/queries/borrowIncentiveQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +11 -0
|
@@ -56,4 +56,4 @@ export declare const getBindedObligationId: ({ address, }: {
|
|
|
56
56
|
}, veScaKeyId: string) => Promise<string | null>;
|
|
57
57
|
export declare const getBindedVeScaKey: ({ address, }: {
|
|
58
58
|
address: ScallopAddress;
|
|
59
|
-
},
|
|
59
|
+
}, obligationId: string) => Promise<string | null>;
|
package/package.json
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
|
-
import {
|
|
5
|
-
getObligations,
|
|
6
|
-
getObligationLocked,
|
|
7
|
-
getBindedObligationId,
|
|
8
|
-
} from '../queries';
|
|
4
|
+
import { getObligations, getObligationLocked } from '../queries';
|
|
9
5
|
import { requireSender } from '../utils';
|
|
10
6
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
11
7
|
import type { ScallopBuilder } from 'src/models';
|
|
@@ -18,7 +14,6 @@ import type {
|
|
|
18
14
|
ScallopTxBlock,
|
|
19
15
|
VescaIds,
|
|
20
16
|
} from '../types';
|
|
21
|
-
import { requireVeSca } from './vescaBuilder';
|
|
22
17
|
import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants';
|
|
23
18
|
|
|
24
19
|
/**
|
|
@@ -257,26 +252,20 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
257
252
|
);
|
|
258
253
|
|
|
259
254
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
const bindedObligationId = await getBindedObligationId(
|
|
263
|
-
builder,
|
|
264
|
-
veSca.keyId
|
|
265
|
-
);
|
|
255
|
+
const bindedVeScaKey =
|
|
256
|
+
await builder.query.getBindedVeScaKey(obligationArg);
|
|
266
257
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
279
|
-
}
|
|
258
|
+
if (veScaKey && veScaKey !== bindedVeScaKey) {
|
|
259
|
+
throw new Error(
|
|
260
|
+
'Binded veScaKey is not equal to the provided veScaKey'
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
if (bindedVeScaKey) {
|
|
264
|
+
txBlock.stakeObligationWithVesca(
|
|
265
|
+
obligationArg,
|
|
266
|
+
obligationKeyArg,
|
|
267
|
+
bindedVeScaKey
|
|
268
|
+
);
|
|
280
269
|
} else {
|
|
281
270
|
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
282
271
|
}
|
|
@@ -66,7 +66,8 @@ export const requireVeSca = async (
|
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
// return veSCA with the same veScaKey or the highest veSCA balance
|
|
70
|
+
return veScaKey ? veScas.find(({ keyId }) => veScaKey === keyId) : veScas[0];
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
/**
|
|
@@ -278,7 +278,7 @@ export const getBindedVeScaKey = async (
|
|
|
278
278
|
}: {
|
|
279
279
|
address: ScallopAddress;
|
|
280
280
|
},
|
|
281
|
-
|
|
281
|
+
obligationId: string
|
|
282
282
|
): Promise<string | null> => {
|
|
283
283
|
const borrowIncentiveObjectId = address.get('borrowIncentive.object');
|
|
284
284
|
const incentiveAccountsId = address.get('borrowIncentive.incentiveAccounts');
|
|
@@ -302,7 +302,7 @@ export const getBindedVeScaKey = async (
|
|
|
302
302
|
parentId: incentiveAccountsTableId,
|
|
303
303
|
name: {
|
|
304
304
|
type: `${borrowIncentiveObjectId}::typed_id::TypedID<${corePkg}::obligation::Obligation>`,
|
|
305
|
-
value:
|
|
305
|
+
value: obligationId,
|
|
306
306
|
},
|
|
307
307
|
});
|
|
308
308
|
|
|
@@ -406,6 +406,17 @@ export const getStakeAccounts = async (
|
|
|
406
406
|
points,
|
|
407
407
|
totalPoints,
|
|
408
408
|
});
|
|
409
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.susdc) {
|
|
410
|
+
stakeAccounts.susdc.push({
|
|
411
|
+
id,
|
|
412
|
+
type: normalizeStructTag(type),
|
|
413
|
+
stakePoolId,
|
|
414
|
+
stakeType: normalizeStructTag(stakeType),
|
|
415
|
+
staked,
|
|
416
|
+
index,
|
|
417
|
+
points,
|
|
418
|
+
totalPoints,
|
|
419
|
+
});
|
|
409
420
|
}
|
|
410
421
|
}
|
|
411
422
|
}
|