@tradeport/sui-trading-sdk 0.0.0 → 0.0.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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +128 -150
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -150
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/SuiTradingClient.ts +2 -2
- package/src/helpers/getMarketFeePrice.ts +1 -6
- package/src/helpers/getSharedObjects.ts +4 -5
- package/src/helpers/{getTradeportBiddingContractParsedBidAmount.ts → getTradeportBiddingContractBidAmount.ts} +2 -3
- package/src/helpers/hasRoyaltyRule.ts +4 -9
- package/src/helpers/hasTransferPolicyRules.ts +3 -18
- package/src/helpers/kiosk/getKioskTransferPolicies.ts +16 -0
- package/src/helpers/kiosk/resolveTransferPolicies.ts +1 -1
- package/src/methods/listNfts/addListTxs.ts +6 -24
- package/src/methods/listNfts/addRelistTxs.ts +2 -9
- package/src/methods/listNfts/listNfts.ts +4 -4
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +36 -41
- package/src/methods/placeCollectionBids/placeCollectionBids.ts +5 -5
- package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +12 -25
- package/src/methods/placeNftBids/placeNftBids.ts +3 -3
- package/src/utils/parseSUI.ts +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradeport/sui-trading-sdk",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"typescript": "^5.3.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@mysten/kiosk": "^0.7.
|
|
30
|
+
"@mysten/kiosk": "^0.7.13",
|
|
31
31
|
"@mysten/sui.js": "^0.47.0",
|
|
32
32
|
"graphql-request": "^6.1.0"
|
|
33
33
|
},
|
package/src/SuiTradingClient.ts
CHANGED
|
@@ -68,7 +68,7 @@ class SuiTradingClient {
|
|
|
68
68
|
|
|
69
69
|
public async placeCollectionBid({
|
|
70
70
|
collectionId,
|
|
71
|
-
|
|
71
|
+
bidAmountInMist,
|
|
72
72
|
numOfBids,
|
|
73
73
|
walletAddress,
|
|
74
74
|
}: PlaceCollectionBid): Promise<TransactionBlock> {
|
|
@@ -76,7 +76,7 @@ class SuiTradingClient {
|
|
|
76
76
|
collections: [
|
|
77
77
|
{
|
|
78
78
|
id: collectionId,
|
|
79
|
-
|
|
79
|
+
bidAmountInMist,
|
|
80
80
|
numOfBids,
|
|
81
81
|
},
|
|
82
82
|
],
|
|
@@ -44,10 +44,9 @@ export const getDSLLegacyMarketFeePrice = (price: number) => {
|
|
|
44
44
|
type GetMarketFeePrice = {
|
|
45
45
|
price: number;
|
|
46
46
|
collectionId: string;
|
|
47
|
-
walletId: string;
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
export const getMarketFeePrice = ({ price, collectionId
|
|
49
|
+
export const getMarketFeePrice = ({ price, collectionId }: GetMarketFeePrice) => {
|
|
51
50
|
if (collectionId === '6824e1ff-477e-4810-9ba7-8d6387b68c7d') {
|
|
52
51
|
return getBASCMarketFeePrice(price);
|
|
53
52
|
}
|
|
@@ -60,10 +59,6 @@ export const getMarketFeePrice = ({ price, collectionId, walletId }: GetMarketFe
|
|
|
60
59
|
return getDSLLegacyMarketFeePrice(price);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
// if (collectionId === 'c3d1ce36-6afd-4336-b619-44c745dd7569') {
|
|
64
|
-
// return getEggMarketFeePrice(price);
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
62
|
let marketFeePrice = 0;
|
|
68
63
|
|
|
69
64
|
if (!COLLECTION_IDS_WITH_ZERO_COMMISSION?.includes(collectionId)) {
|
|
@@ -87,11 +87,10 @@ export const getSharedObjects = async (nftType: string): Promise<SuiSharedObject
|
|
|
87
87
|
)?.[0]?.id;
|
|
88
88
|
|
|
89
89
|
if (nftTypeSplit?.join('::')?.includes('keepsake_nft::KEEPSAKE')) {
|
|
90
|
-
transferPolicy = res?.sharedObjects?.filter(
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
),
|
|
90
|
+
transferPolicy = res?.sharedObjects?.filter((object: any) =>
|
|
91
|
+
object?.type?.includes(
|
|
92
|
+
'0x02be8c4a1a3cea4d3255d870d367c87838a8cc2bfe4f216a6b67b153027087a7::transfer_policy::TransferPolicy',
|
|
93
|
+
),
|
|
95
94
|
)?.[0]?.id;
|
|
96
95
|
}
|
|
97
96
|
|
|
@@ -3,14 +3,13 @@ import {
|
|
|
3
3
|
DSL_LEGACY_ROYALTY_DECIMAL_PERCENT,
|
|
4
4
|
MASC_ROYALTY_DECIMAL_PERCENT,
|
|
5
5
|
} from '../constants';
|
|
6
|
-
import { parseSUI } from '../utils/parseSUI';
|
|
7
6
|
|
|
8
7
|
interface Args {
|
|
9
8
|
bidAmount: number;
|
|
10
9
|
collectionId: string;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export const
|
|
12
|
+
export const getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }: Args) => {
|
|
14
13
|
let amount = bidAmount;
|
|
15
14
|
|
|
16
15
|
// MASC
|
|
@@ -28,5 +27,5 @@ export const getTradeportBiddingContractParsedBidAmount = ({ bidAmount, collecti
|
|
|
28
27
|
amount = bidAmount - bidAmount * DSL_LEGACY_ROYALTY_DECIMAL_PERCENT;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
return
|
|
30
|
+
return amount;
|
|
32
31
|
};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { addLeadingZerosAfter0x } from '../utils/addLeadingZerosAfter0x';
|
|
1
|
+
import { getKioskTransferPolicies } from './kiosk/getKioskTransferPolicies';
|
|
3
2
|
|
|
4
3
|
export const hasRoyaltyRule = async (nftType: string): Promise<boolean> => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const res = await kioskClient.getTransferPolicies({ type: nftTypeSplit?.join('::') });
|
|
9
|
-
|
|
10
|
-
return res?.some(
|
|
4
|
+
const transferPolicies = await getKioskTransferPolicies(nftType);
|
|
5
|
+
return transferPolicies?.some(
|
|
11
6
|
(policy: any) =>
|
|
12
|
-
policy?.rules?.filter((rule: any) => rule?.includes('royalty_rule'))?.length > 0,
|
|
7
|
+
policy?.rules?.filter((rule: any) => rule?.type?.includes('royalty_rule'))?.length > 0,
|
|
13
8
|
);
|
|
14
9
|
};
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { addLeadingZerosAfter0x } from '../utils/addLeadingZerosAfter0x';
|
|
1
|
+
import { getKioskTransferPolicies } from './kiosk/getKioskTransferPolicies';
|
|
3
2
|
|
|
4
3
|
export const hasTransferPolicyRules = async (nftType: string): Promise<boolean> => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// const res = await gqlChainRequest({
|
|
9
|
-
// chain: 'sui',
|
|
10
|
-
// query: fetchTransferPoliciesByType,
|
|
11
|
-
// variables: { type: nftTypeSplit?.join('::') },
|
|
12
|
-
// });
|
|
13
|
-
|
|
14
|
-
// return res?.transfer_policies_by_type
|
|
15
|
-
// ?.filter((policy: any) => !policy?.is_origin_byte)
|
|
16
|
-
// ?.some((policy: any) => policy?.rules?.length > 0);
|
|
17
|
-
|
|
18
|
-
const res = await kioskClient.getTransferPolicies({ type: nftTypeSplit?.join('::') });
|
|
19
|
-
|
|
20
|
-
return res?.some((policy: any) => policy?.rules?.length > 0);
|
|
4
|
+
const transferPolicies = await getKioskTransferPolicies(nftType);
|
|
5
|
+
return transferPolicies?.some((policy: any) => policy?.rules?.length > 0);
|
|
21
6
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { gqlChainRequest } from '../../graphql/gqlChainRequest';
|
|
2
|
+
import { fetchTransferPoliciesByType } from '../../graphql/queries/fetchTransferPoliciesByType';
|
|
3
|
+
import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
|
|
4
|
+
|
|
5
|
+
export const getKioskTransferPolicies = async (nftType: string) => {
|
|
6
|
+
const nftTypeSplit = nftType?.split('::');
|
|
7
|
+
if (nftTypeSplit?.[0]) nftTypeSplit[0] = addLeadingZerosAfter0x(nftTypeSplit[0]);
|
|
8
|
+
|
|
9
|
+
const res = await gqlChainRequest({
|
|
10
|
+
chain: 'sui',
|
|
11
|
+
query: fetchTransferPoliciesByType,
|
|
12
|
+
variables: { type: nftTypeSplit?.join('::') },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return res?.transfer_policies_by_type?.filter((policy: any) => !policy?.is_origin_byte);
|
|
16
|
+
};
|
|
@@ -10,7 +10,6 @@ import { depositItemIntoOBKiosk } from '../../helpers/originByte/depositNftIntoO
|
|
|
10
10
|
import { getOrCreateOBKiosk } from '../../helpers/originByte/getOrCreateOBKiosk';
|
|
11
11
|
import { isOriginByteTx } from '../../helpers/originByte/isOriginByteTx';
|
|
12
12
|
import { shareOriginByteKiosk } from '../../helpers/originByte/shareOriginByteKiosk';
|
|
13
|
-
import { parseSUI } from '../../utils/parseSUI';
|
|
14
13
|
import { type ListNftTx } from './listNfts';
|
|
15
14
|
|
|
16
15
|
export async function addOriginByteListTx({
|
|
@@ -40,12 +39,7 @@ export async function addOriginByteListTx({
|
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const
|
|
44
|
-
const marketFeePrice = getMarketFeePrice({
|
|
45
|
-
price: parsedListPrice,
|
|
46
|
-
collectionId,
|
|
47
|
-
walletId: seller,
|
|
48
|
-
});
|
|
42
|
+
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
49
43
|
|
|
50
44
|
txBlock.moveCall({
|
|
51
45
|
target:
|
|
@@ -53,7 +47,7 @@ export async function addOriginByteListTx({
|
|
|
53
47
|
arguments: [
|
|
54
48
|
txBlock.object(orderbook),
|
|
55
49
|
txBlock.object(kiosk),
|
|
56
|
-
txBlock.pure(
|
|
50
|
+
txBlock.pure(listPrice),
|
|
57
51
|
txBlock.pure(nftTokenId),
|
|
58
52
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
59
53
|
txBlock.pure(marketFeePrice),
|
|
@@ -73,21 +67,15 @@ export function addTradePortListTx({
|
|
|
73
67
|
nftType,
|
|
74
68
|
collectionId,
|
|
75
69
|
listPrice,
|
|
76
|
-
seller,
|
|
77
70
|
}: ListNftTx) {
|
|
78
|
-
const
|
|
79
|
-
const marketFeePrice = getMarketFeePrice({
|
|
80
|
-
price: parsedListPrice,
|
|
81
|
-
collectionId,
|
|
82
|
-
walletId: seller,
|
|
83
|
-
});
|
|
71
|
+
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
84
72
|
|
|
85
73
|
txBlock.moveCall({
|
|
86
74
|
target: '0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::list',
|
|
87
75
|
arguments: [
|
|
88
76
|
txBlock.object(TRADEPORT_LISTING_STORE),
|
|
89
77
|
borrowedItem ? txBlock.object(borrowedItem) : txBlock.pure(nftTokenId),
|
|
90
|
-
txBlock.pure(
|
|
78
|
+
txBlock.pure(listPrice),
|
|
91
79
|
txBlock.pure(marketFeePrice),
|
|
92
80
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
93
81
|
],
|
|
@@ -102,14 +90,8 @@ export async function addTradePortKioskListTx({
|
|
|
102
90
|
nftType,
|
|
103
91
|
collectionId,
|
|
104
92
|
listPrice,
|
|
105
|
-
seller,
|
|
106
93
|
}: ListNftTx) {
|
|
107
|
-
const
|
|
108
|
-
const marketFeePrice = getMarketFeePrice({
|
|
109
|
-
price: parsedListPrice,
|
|
110
|
-
collectionId,
|
|
111
|
-
walletId: seller,
|
|
112
|
-
});
|
|
94
|
+
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
113
95
|
|
|
114
96
|
txBlock.moveCall({
|
|
115
97
|
target:
|
|
@@ -119,7 +101,7 @@ export async function addTradePortKioskListTx({
|
|
|
119
101
|
txBlock.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
|
|
120
102
|
txBlock.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
|
|
121
103
|
txBlock.pure(nftTokenId),
|
|
122
|
-
txBlock.pure(
|
|
104
|
+
txBlock.pure(listPrice + marketFeePrice),
|
|
123
105
|
txBlock.pure(marketFeePrice),
|
|
124
106
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
125
107
|
],
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
TRADEPORT_LISTING_STORE,
|
|
8
8
|
} from '../../constants';
|
|
9
9
|
import { getMarketFeePrice } from '../../helpers/getMarketFeePrice';
|
|
10
|
-
import { parseSUI } from '../../utils/parseSUI';
|
|
11
10
|
import { addTradePortListTx } from './addListTxs';
|
|
12
11
|
|
|
13
12
|
export type RelistNftTx = {
|
|
@@ -30,21 +29,15 @@ export function addTradePortRelistTx({
|
|
|
30
29
|
collectionId,
|
|
31
30
|
listingNonce,
|
|
32
31
|
listPrice,
|
|
33
|
-
seller,
|
|
34
32
|
}: RelistNftTx) {
|
|
35
|
-
const
|
|
36
|
-
const marketFeePrice = getMarketFeePrice({
|
|
37
|
-
price: parsedListPrice,
|
|
38
|
-
collectionId,
|
|
39
|
-
walletId: seller,
|
|
40
|
-
});
|
|
33
|
+
const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
|
|
41
34
|
|
|
42
35
|
txBlock.moveCall({
|
|
43
36
|
target: '0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::listings::relist',
|
|
44
37
|
arguments: [
|
|
45
38
|
txBlock.object(TRADEPORT_LISTING_STORE),
|
|
46
39
|
txBlock.pure(listingNonce),
|
|
47
|
-
txBlock.pure(
|
|
40
|
+
txBlock.pure(listPrice),
|
|
48
41
|
txBlock.pure(marketFeePrice),
|
|
49
42
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
50
43
|
],
|
|
@@ -22,14 +22,14 @@ export type ListNftTx = {
|
|
|
22
22
|
|
|
23
23
|
export type ListNft = {
|
|
24
24
|
nftId: string;
|
|
25
|
-
|
|
25
|
+
listPriceInMist: number;
|
|
26
26
|
walletAddress: string;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export type ListNfts = {
|
|
30
30
|
nfts: Array<{
|
|
31
31
|
id: string;
|
|
32
|
-
|
|
32
|
+
listPriceInMist: number;
|
|
33
33
|
}>;
|
|
34
34
|
walletAddress: string;
|
|
35
35
|
};
|
|
@@ -57,7 +57,7 @@ export const listNfts = async ({ nfts, walletAddress }: ListNfts): Promise<Trans
|
|
|
57
57
|
txBlock,
|
|
58
58
|
sharedObjects,
|
|
59
59
|
nft,
|
|
60
|
-
listPrice: nfts?.find((n) => n.id === nft?.id)?.
|
|
60
|
+
listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
|
|
61
61
|
walletAddress,
|
|
62
62
|
});
|
|
63
63
|
} else {
|
|
@@ -68,7 +68,7 @@ export const listNfts = async ({ nfts, walletAddress }: ListNfts): Promise<Trans
|
|
|
68
68
|
collectionId: nft?.collection_id,
|
|
69
69
|
nftTokenId: nft?.token_id,
|
|
70
70
|
nftType: getNftTypeFromNft(nft),
|
|
71
|
-
listPrice: nfts?.find((n) => n.id === nft?.id)?.
|
|
71
|
+
listPrice: nfts?.find((n) => n.id === nft?.id)?.listPriceInMist,
|
|
72
72
|
sellerKiosk: nft?.chain_state?.kiosk_id,
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
} from '../../constants';
|
|
6
6
|
import { destroyZeroCoin } from '../../helpers/destroyZeroCoin';
|
|
7
7
|
import { getMarketFeePrice } from '../../helpers/getMarketFeePrice';
|
|
8
|
-
import {
|
|
8
|
+
import { getTradeportBiddingContractBidAmount } from '../../helpers/getTradeportBiddingContractBidAmount';
|
|
9
9
|
import { hasRoyaltyRule } from '../../helpers/hasRoyaltyRule';
|
|
10
10
|
import { getRulePackageId } from '../../helpers/kiosk/getRulePackageId';
|
|
11
11
|
import { splitCoins } from '../../helpers/splitCoins';
|
|
12
|
-
import { parseSUI } from '../../utils/parseSUI';
|
|
13
12
|
import { type PlaceCollectionBidTx } from './placeCollectionBids';
|
|
14
13
|
|
|
15
14
|
export function addTradePortCollectionBidTx({
|
|
@@ -17,23 +16,18 @@ export function addTradePortCollectionBidTx({
|
|
|
17
16
|
collectionId,
|
|
18
17
|
nftType,
|
|
19
18
|
bidAmount,
|
|
20
|
-
bidder,
|
|
21
19
|
}: PlaceCollectionBidTx) {
|
|
22
|
-
const
|
|
23
|
-
const marketFeePrice = getMarketFeePrice({
|
|
24
|
-
price: Number(parseSUI(bidAmount)),
|
|
25
|
-
collectionId,
|
|
26
|
-
walletId: bidder,
|
|
27
|
-
});
|
|
20
|
+
const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
|
|
21
|
+
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
28
22
|
|
|
29
|
-
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(
|
|
23
|
+
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
|
|
30
24
|
|
|
31
25
|
txBlock.moveCall({
|
|
32
26
|
target:
|
|
33
27
|
'0xb42dbb7413b79394e1a0175af6ae22b69a5c7cc5df259cd78072b6818217c027::biddings::collection_bid',
|
|
34
28
|
arguments: [
|
|
35
29
|
txBlock.object(TRADEPORT_BIDDING_STORE),
|
|
36
|
-
txBlock.pure(
|
|
30
|
+
txBlock.pure(amountToBid),
|
|
37
31
|
txBlock.object(coin),
|
|
38
32
|
txBlock.pure(marketFeePrice),
|
|
39
33
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
@@ -50,48 +44,55 @@ export function addTradePortKioskCollectionBidTx({
|
|
|
50
44
|
nftType,
|
|
51
45
|
bidAmount,
|
|
52
46
|
sharedObjects,
|
|
53
|
-
bidder,
|
|
54
47
|
royaltyRulePackageId,
|
|
55
48
|
royaltyRuleModule,
|
|
56
49
|
}: PlaceCollectionBidTx) {
|
|
57
50
|
const { transferPolicy } = sharedObjects;
|
|
58
51
|
|
|
59
|
-
const parsedBidAmount = Number(parseSUI(bidAmount));
|
|
60
52
|
const marketFeePrice = getMarketFeePrice({
|
|
61
|
-
price:
|
|
53
|
+
price: bidAmount,
|
|
62
54
|
collectionId,
|
|
63
|
-
walletId: bidder,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const fee = txBlock.moveCall({
|
|
67
|
-
target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
|
|
68
|
-
arguments: [txBlock.object(transferPolicy), txBlock.pure(parsedBidAmount)],
|
|
69
|
-
typeArguments: [nftType],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const [coin1, coin2] = splitCoins({
|
|
73
|
-
txBlock,
|
|
74
|
-
amounts: [txBlock.pure(parsedBidAmount + marketFeePrice), txBlock.object(fee)],
|
|
75
55
|
});
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
57
|
+
let coin;
|
|
58
|
+
if (royaltyRulePackageId && royaltyRuleModule) {
|
|
59
|
+
const fee = txBlock.moveCall({
|
|
60
|
+
target: `${royaltyRulePackageId}::${royaltyRuleModule}::fee_amount`,
|
|
61
|
+
arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount)],
|
|
62
|
+
typeArguments: [nftType],
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const [coin1, coin2] = splitCoins({
|
|
66
|
+
txBlock,
|
|
67
|
+
amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(fee)],
|
|
68
|
+
});
|
|
69
|
+
coin = coin1;
|
|
70
|
+
|
|
71
|
+
if (!coin1 || !coin2) throw new Error('Coin could not be split');
|
|
72
|
+
|
|
73
|
+
txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
|
|
74
|
+
} else {
|
|
75
|
+
const [coin1] = splitCoins({
|
|
76
|
+
txBlock,
|
|
77
|
+
amounts: [txBlock.pure(bidAmount + marketFeePrice)],
|
|
78
|
+
});
|
|
79
|
+
coin = coin1;
|
|
80
|
+
}
|
|
80
81
|
|
|
81
82
|
txBlock.moveCall({
|
|
82
83
|
target:
|
|
83
84
|
'0x33a9e4a3089d911c2a2bf16157a1d6a4a8cbd9a2106a98ecbaefe6ed370d7a25::kiosk_biddings::collection_bid',
|
|
84
85
|
arguments: [
|
|
85
86
|
txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
86
|
-
txBlock.pure(
|
|
87
|
-
txBlock.object(
|
|
87
|
+
txBlock.pure(bidAmount),
|
|
88
|
+
txBlock.object(coin),
|
|
88
89
|
txBlock.pure(marketFeePrice),
|
|
89
90
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
90
91
|
],
|
|
91
92
|
typeArguments: [nftType],
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
destroyZeroCoin({ txBlock, coin
|
|
95
|
+
destroyZeroCoin({ txBlock, coin });
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export async function addOriginByteCollectionBidTx({
|
|
@@ -99,20 +100,14 @@ export async function addOriginByteCollectionBidTx({
|
|
|
99
100
|
collectionId,
|
|
100
101
|
nftType,
|
|
101
102
|
bidAmount,
|
|
102
|
-
bidder,
|
|
103
103
|
sharedObjects,
|
|
104
104
|
bidderKiosk,
|
|
105
105
|
}: PlaceCollectionBidTx) {
|
|
106
106
|
const { orderbook } = sharedObjects;
|
|
107
107
|
|
|
108
|
-
const
|
|
109
|
-
const marketFeePrice = getMarketFeePrice({
|
|
110
|
-
price: parsedBidAmount,
|
|
111
|
-
collectionId,
|
|
112
|
-
walletId: bidder,
|
|
113
|
-
});
|
|
108
|
+
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
114
109
|
|
|
115
|
-
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(
|
|
110
|
+
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
|
|
116
111
|
|
|
117
112
|
txBlock.moveCall({
|
|
118
113
|
target:
|
|
@@ -120,7 +115,7 @@ export async function addOriginByteCollectionBidTx({
|
|
|
120
115
|
arguments: [
|
|
121
116
|
txBlock.object(orderbook),
|
|
122
117
|
txBlock.object(bidderKiosk),
|
|
123
|
-
txBlock.pure(
|
|
118
|
+
txBlock.pure(bidAmount),
|
|
124
119
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
125
120
|
txBlock.pure(marketFeePrice),
|
|
126
121
|
txBlock.object(coin),
|
|
@@ -28,7 +28,7 @@ export type PlaceCollectionBidTx = {
|
|
|
28
28
|
|
|
29
29
|
export type PlaceCollectionBid = {
|
|
30
30
|
collectionId: string;
|
|
31
|
-
|
|
31
|
+
bidAmountInMist: number;
|
|
32
32
|
numOfBids: number;
|
|
33
33
|
walletAddress: string;
|
|
34
34
|
};
|
|
@@ -36,7 +36,7 @@ export type PlaceCollectionBid = {
|
|
|
36
36
|
export type PlaceCollectionBids = {
|
|
37
37
|
collections: Array<{
|
|
38
38
|
id: string;
|
|
39
|
-
|
|
39
|
+
bidAmountInMist: number;
|
|
40
40
|
numOfBids: number;
|
|
41
41
|
}>;
|
|
42
42
|
walletAddress: string;
|
|
@@ -80,8 +80,8 @@ export const placeCollectionBids = async ({
|
|
|
80
80
|
)
|
|
81
81
|
? getNftTypeFromNft(collection?.nfts?.[0])
|
|
82
82
|
: collection.id === '07231735-96de-4710-8e11-52c61a482578'
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
? '0x034c162f6b594cb5a1805264dd01ca5d80ce3eca6522e6ee37fd9ebfb9d3ddca::factory::PrimeMachin'
|
|
84
|
+
: collection?.contract?.properties?.nft_type; // Prime Machin
|
|
85
85
|
|
|
86
86
|
const sharedObjects = await getSharedObjects(nftType);
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ export const placeCollectionBids = async ({
|
|
|
91
91
|
bidder: walletAddress,
|
|
92
92
|
collectionId: collection?.id,
|
|
93
93
|
nftType,
|
|
94
|
-
bidAmount: collections?.find((c) => c.id === collection?.id)?.
|
|
94
|
+
bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
|
|
@@ -5,13 +5,12 @@ import {
|
|
|
5
5
|
} from '../../constants';
|
|
6
6
|
import { destroyZeroCoin } from '../../helpers/destroyZeroCoin';
|
|
7
7
|
import { getMarketFeePrice } from '../../helpers/getMarketFeePrice';
|
|
8
|
-
import {
|
|
8
|
+
import { getTradeportBiddingContractBidAmount } from '../../helpers/getTradeportBiddingContractBidAmount';
|
|
9
9
|
import { hasTransferPolicyRules } from '../../helpers/hasTransferPolicyRules';
|
|
10
10
|
import { getRulePackageId } from '../../helpers/kiosk/getRulePackageId';
|
|
11
11
|
import { getOrCreateOBKiosk } from '../../helpers/originByte/getOrCreateOBKiosk';
|
|
12
12
|
import { isOriginByteTx } from '../../helpers/originByte/isOriginByteTx';
|
|
13
13
|
import { splitCoins } from '../../helpers/splitCoins';
|
|
14
|
-
import { parseSUI } from '../../utils/parseSUI';
|
|
15
14
|
import { type PlaceNftBidTx } from './placeNftBids';
|
|
16
15
|
|
|
17
16
|
function addTradePortPlaceNftBidTx({
|
|
@@ -20,23 +19,18 @@ function addTradePortPlaceNftBidTx({
|
|
|
20
19
|
nftTokenId,
|
|
21
20
|
nftType,
|
|
22
21
|
bidAmount,
|
|
23
|
-
bidder,
|
|
24
22
|
}: PlaceNftBidTx) {
|
|
25
|
-
const
|
|
26
|
-
const marketFeePrice = getMarketFeePrice({
|
|
27
|
-
price: Number(parseSUI(bidAmount)),
|
|
28
|
-
collectionId,
|
|
29
|
-
walletId: bidder,
|
|
30
|
-
});
|
|
23
|
+
const amountToBid = getTradeportBiddingContractBidAmount({ bidAmount, collectionId });
|
|
24
|
+
const marketFeePrice = getMarketFeePrice({ price: amountToBid, collectionId });
|
|
31
25
|
|
|
32
|
-
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(
|
|
26
|
+
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(amountToBid + marketFeePrice)] });
|
|
33
27
|
|
|
34
28
|
txBlock.moveCall({
|
|
35
29
|
target: '0x398aae1ad267d989dcc99ba449b0a30101a6b851ec1284ccddab5937df66bfcf::biddings::bid',
|
|
36
30
|
arguments: [
|
|
37
31
|
txBlock.object(TRADEPORT_BIDDING_STORE),
|
|
38
32
|
txBlock.pure(nftTokenId),
|
|
39
|
-
txBlock.pure(
|
|
33
|
+
txBlock.pure(amountToBid),
|
|
40
34
|
txBlock.object(coin),
|
|
41
35
|
txBlock.pure(marketFeePrice),
|
|
42
36
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
@@ -54,22 +48,20 @@ function addTradePortKioskPlaceNftBidTx({
|
|
|
54
48
|
nftTokenId,
|
|
55
49
|
nftType,
|
|
56
50
|
bidAmount,
|
|
57
|
-
bidder,
|
|
58
51
|
royaltyRulePackageId,
|
|
59
52
|
}: PlaceNftBidTx) {
|
|
60
53
|
const { transferPolicy } = sharedObjects;
|
|
61
|
-
const
|
|
62
|
-
const marketFeePrice = getMarketFeePrice({ price: bidPrice, collectionId, walletId: bidder });
|
|
54
|
+
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
63
55
|
|
|
64
56
|
const royaltyCoin = txBlock.moveCall({
|
|
65
57
|
target: `${royaltyRulePackageId}::royalty_rule::fee_amount`,
|
|
66
|
-
arguments: [txBlock.object(transferPolicy), txBlock.pure(
|
|
58
|
+
arguments: [txBlock.object(transferPolicy), txBlock.pure(bidAmount?.toString())],
|
|
67
59
|
typeArguments: [nftType],
|
|
68
60
|
});
|
|
69
61
|
|
|
70
62
|
const [coin1, coin2] = splitCoins({
|
|
71
63
|
txBlock,
|
|
72
|
-
amounts: [txBlock.pure(
|
|
64
|
+
amounts: [txBlock.pure(bidAmount + marketFeePrice), txBlock.object(royaltyCoin)],
|
|
73
65
|
});
|
|
74
66
|
|
|
75
67
|
txBlock.mergeCoins(txBlock.object(coin1), [txBlock.object(coin2)]);
|
|
@@ -80,7 +72,7 @@ function addTradePortKioskPlaceNftBidTx({
|
|
|
80
72
|
arguments: [
|
|
81
73
|
txBlock.object(TRADEPORT_KIOSK_BIDDING_STORE),
|
|
82
74
|
txBlock.pure(nftTokenId),
|
|
83
|
-
txBlock.pure(
|
|
75
|
+
txBlock.pure(bidAmount),
|
|
84
76
|
txBlock.object(coin1),
|
|
85
77
|
txBlock.pure(marketFeePrice),
|
|
86
78
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
@@ -104,14 +96,9 @@ async function addOriginBytePlaceNftBidTx({
|
|
|
104
96
|
createMethod: 'create_for_sender',
|
|
105
97
|
});
|
|
106
98
|
|
|
107
|
-
const
|
|
108
|
-
const marketFeePrice = getMarketFeePrice({
|
|
109
|
-
price: parsedBidAmount,
|
|
110
|
-
collectionId,
|
|
111
|
-
walletId: bidder,
|
|
112
|
-
});
|
|
99
|
+
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
113
100
|
|
|
114
|
-
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(
|
|
101
|
+
const [coin] = splitCoins({ txBlock, amounts: [txBlock.pure(bidAmount + marketFeePrice)] });
|
|
115
102
|
|
|
116
103
|
txBlock.moveCall({
|
|
117
104
|
target:
|
|
@@ -119,7 +106,7 @@ async function addOriginBytePlaceNftBidTx({
|
|
|
119
106
|
arguments: [
|
|
120
107
|
isNewBidderKiosk ? txBlock.object(bidderKiosk) : txBlock.pure(bidderKiosk),
|
|
121
108
|
txBlock.pure(nftTokenId),
|
|
122
|
-
txBlock.pure(
|
|
109
|
+
txBlock.pure(bidAmount),
|
|
123
110
|
txBlock.pure(TRADEPORT_BENEFICIARY_ADDRESS),
|
|
124
111
|
txBlock.pure(marketFeePrice),
|
|
125
112
|
txBlock.object(coin),
|
|
@@ -18,14 +18,14 @@ export type PlaceNftBidTx = {
|
|
|
18
18
|
|
|
19
19
|
export type PlaceNftBid = {
|
|
20
20
|
nftId: string;
|
|
21
|
-
|
|
21
|
+
bidAmountInMist: number;
|
|
22
22
|
walletAddress: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type PlaceNftBids = {
|
|
26
26
|
nfts: Array<{
|
|
27
27
|
id: string;
|
|
28
|
-
|
|
28
|
+
bidAmountInMist: number;
|
|
29
29
|
}>;
|
|
30
30
|
walletAddress: string;
|
|
31
31
|
};
|
|
@@ -58,7 +58,7 @@ export const placeNftBids = async ({
|
|
|
58
58
|
collectionId: nft?.collection_id,
|
|
59
59
|
nftTokenId: nft?.token_id,
|
|
60
60
|
nftType: nft?.properties?.nft_type || nft?.contract?.properties?.nft_type,
|
|
61
|
-
bidAmount: nfts?.find((n) => n.id === nft?.id)?.
|
|
61
|
+
bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
|
|
62
62
|
sellerKiosk: nft?.chain_state?.kiosk_id,
|
|
63
63
|
};
|
|
64
64
|
|
package/src/utils/parseSUI.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const parseSUI = (num: number) => parseInt((1000000000 * num).toFixed(0), 10);
|