@kaspacom/kcc20-tx-builder 0.1.0
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 +201 -0
- package/README.md +104 -0
- package/artifacts/KCC20.placeholder.json +77479 -0
- package/artifacts/KCC20FeeTicket.placeholder.json +16846 -0
- package/artifacts/KCC20Orderbook.placeholder.json +78001 -0
- package/artifacts/KCC20Vesting.placeholder.json +4298 -0
- package/artifacts/KCC20Wrapper.placeholder.json +12246 -0
- package/dist/abi.d.ts +44 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +336 -0
- package/dist/abi.js.map +1 -0
- package/dist/action-source-resolver.d.ts +80 -0
- package/dist/action-source-resolver.d.ts.map +1 -0
- package/dist/action-source-resolver.js +412 -0
- package/dist/action-source-resolver.js.map +1 -0
- package/dist/artifacts.d.ts +14 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +44 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/builder.d.ts +12 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +18 -0
- package/dist/builder.js.map +1 -0
- package/dist/cjs/abi.d.ts +43 -0
- package/dist/cjs/abi.js +361 -0
- package/dist/cjs/abi.js.map +1 -0
- package/dist/cjs/action-source-resolver.d.ts +79 -0
- package/dist/cjs/action-source-resolver.js +435 -0
- package/dist/cjs/action-source-resolver.js.map +1 -0
- package/dist/cjs/artifacts.d.ts +13 -0
- package/dist/cjs/artifacts.js +51 -0
- package/dist/cjs/artifacts.js.map +1 -0
- package/dist/cjs/builder.d.ts +11 -0
- package/dist/cjs/builder.js +22 -0
- package/dist/cjs/builder.js.map +1 -0
- package/dist/cjs/deploy-operation.d.ts +103 -0
- package/dist/cjs/deploy-operation.js +335 -0
- package/dist/cjs/deploy-operation.js.map +1 -0
- package/dist/cjs/encoding.d.ts +5 -0
- package/dist/cjs/encoding.js +51 -0
- package/dist/cjs/encoding.js.map +1 -0
- package/dist/cjs/engine.d.ts +40 -0
- package/dist/cjs/engine.js +8972 -0
- package/dist/cjs/engine.js.map +1 -0
- package/dist/cjs/errors.d.ts +7 -0
- package/dist/cjs/errors.js +23 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/fee-ticket-operation.d.ts +204 -0
- package/dist/cjs/fee-ticket-operation.js +327 -0
- package/dist/cjs/fee-ticket-operation.js.map +1 -0
- package/dist/cjs/index.d.ts +27 -0
- package/dist/cjs/index.js +45 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/ladder-limit-orders.d.ts +41 -0
- package/dist/cjs/ladder-limit-orders.js +129 -0
- package/dist/cjs/ladder-limit-orders.js.map +1 -0
- package/dist/cjs/mint-availability-operation.d.ts +56 -0
- package/dist/cjs/mint-availability-operation.js +95 -0
- package/dist/cjs/mint-availability-operation.js.map +1 -0
- package/dist/cjs/models.d.ts +90 -0
- package/dist/cjs/models.js +6 -0
- package/dist/cjs/models.js.map +1 -0
- package/dist/cjs/operations.d.ts +6 -0
- package/dist/cjs/operations.js +41 -0
- package/dist/cjs/operations.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/paid-mint-amount.d.ts +69 -0
- package/dist/cjs/paid-mint-amount.js +281 -0
- package/dist/cjs/paid-mint-amount.js.map +1 -0
- package/dist/cjs/protocol.d.ts +21 -0
- package/dist/cjs/protocol.js +25 -0
- package/dist/cjs/protocol.js.map +1 -0
- package/dist/cjs/runtime.d.ts +27 -0
- package/dist/cjs/runtime.js +3 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/cjs/sale-common.d.ts +287 -0
- package/dist/cjs/sale-common.js +928 -0
- package/dist/cjs/sale-common.js.map +1 -0
- package/dist/cjs/source-provider.d.ts +11 -0
- package/dist/cjs/source-provider.js +3 -0
- package/dist/cjs/source-provider.js.map +1 -0
- package/dist/cjs/source-validation.d.ts +9 -0
- package/dist/cjs/source-validation.js +33 -0
- package/dist/cjs/source-validation.js.map +1 -0
- package/dist/cjs/token-amount.d.ts +31 -0
- package/dist/cjs/token-amount.js +252 -0
- package/dist/cjs/token-amount.js.map +1 -0
- package/dist/cjs/token-operation.d.ts +135 -0
- package/dist/cjs/token-operation.js +236 -0
- package/dist/cjs/token-operation.js.map +1 -0
- package/dist/cjs/trade-fee.d.ts +60 -0
- package/dist/cjs/trade-fee.js +185 -0
- package/dist/cjs/trade-fee.js.map +1 -0
- package/dist/cjs/trading-operation.d.ts +212 -0
- package/dist/cjs/trading-operation.js +587 -0
- package/dist/cjs/trading-operation.js.map +1 -0
- package/dist/cjs/verify-operation.d.ts +79 -0
- package/dist/cjs/verify-operation.js +246 -0
- package/dist/cjs/verify-operation.js.map +1 -0
- package/dist/cjs/wallet-operation.d.ts +52 -0
- package/dist/cjs/wallet-operation.js +58 -0
- package/dist/cjs/wallet-operation.js.map +1 -0
- package/dist/cjs/wasm-provider.d.ts +15 -0
- package/dist/cjs/wasm-provider.js +20 -0
- package/dist/cjs/wasm-provider.js.map +1 -0
- package/dist/cjs/wrapper-operation.d.ts +196 -0
- package/dist/cjs/wrapper-operation.js +317 -0
- package/dist/cjs/wrapper-operation.js.map +1 -0
- package/dist/deploy-operation.d.ts +104 -0
- package/dist/deploy-operation.d.ts.map +1 -0
- package/dist/deploy-operation.js +327 -0
- package/dist/deploy-operation.js.map +1 -0
- package/dist/encoding.d.ts +6 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +44 -0
- package/dist/encoding.js.map +1 -0
- package/dist/engine.d.ts +41 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +8969 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -0
- package/dist/fee-ticket-operation.d.ts +205 -0
- package/dist/fee-ticket-operation.d.ts.map +1 -0
- package/dist/fee-ticket-operation.js +320 -0
- package/dist/fee-ticket-operation.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/ladder-limit-orders.d.ts +42 -0
- package/dist/ladder-limit-orders.d.ts.map +1 -0
- package/dist/ladder-limit-orders.js +121 -0
- package/dist/ladder-limit-orders.js.map +1 -0
- package/dist/mint-availability-operation.d.ts +57 -0
- package/dist/mint-availability-operation.d.ts.map +1 -0
- package/dist/mint-availability-operation.js +91 -0
- package/dist/mint-availability-operation.js.map +1 -0
- package/dist/models.d.ts +91 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +3 -0
- package/dist/models.js.map +1 -0
- package/dist/operations.d.ts +7 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +36 -0
- package/dist/operations.js.map +1 -0
- package/dist/paid-mint-amount.d.ts +70 -0
- package/dist/paid-mint-amount.d.ts.map +1 -0
- package/dist/paid-mint-amount.js +268 -0
- package/dist/paid-mint-amount.js.map +1 -0
- package/dist/protocol.d.ts +22 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +22 -0
- package/dist/protocol.js.map +1 -0
- package/dist/runtime.d.ts +28 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sale-common.d.ts +288 -0
- package/dist/sale-common.d.ts.map +1 -0
- package/dist/sale-common.js +844 -0
- package/dist/sale-common.js.map +1 -0
- package/dist/source-provider.d.ts +12 -0
- package/dist/source-provider.d.ts.map +1 -0
- package/dist/source-provider.js +2 -0
- package/dist/source-provider.js.map +1 -0
- package/dist/source-validation.d.ts +10 -0
- package/dist/source-validation.d.ts.map +1 -0
- package/dist/source-validation.js +28 -0
- package/dist/source-validation.js.map +1 -0
- package/dist/token-amount.d.ts +32 -0
- package/dist/token-amount.d.ts.map +1 -0
- package/dist/token-amount.js +237 -0
- package/dist/token-amount.js.map +1 -0
- package/dist/token-operation.d.ts +136 -0
- package/dist/token-operation.d.ts.map +1 -0
- package/dist/token-operation.js +231 -0
- package/dist/token-operation.js.map +1 -0
- package/dist/trade-fee.d.ts +61 -0
- package/dist/trade-fee.d.ts.map +1 -0
- package/dist/trade-fee.js +173 -0
- package/dist/trade-fee.js.map +1 -0
- package/dist/trading-operation.d.ts +213 -0
- package/dist/trading-operation.d.ts.map +1 -0
- package/dist/trading-operation.js +580 -0
- package/dist/trading-operation.js.map +1 -0
- package/dist/verify-operation.d.ts +80 -0
- package/dist/verify-operation.d.ts.map +1 -0
- package/dist/verify-operation.js +243 -0
- package/dist/verify-operation.js.map +1 -0
- package/dist/wallet-operation.d.ts +53 -0
- package/dist/wallet-operation.d.ts.map +1 -0
- package/dist/wallet-operation.js +55 -0
- package/dist/wallet-operation.js.map +1 -0
- package/dist/wasm-provider.d.ts +16 -0
- package/dist/wasm-provider.d.ts.map +1 -0
- package/dist/wasm-provider.js +17 -0
- package/dist/wasm-provider.js.map +1 -0
- package/dist/wrapper-operation.d.ts +197 -0
- package/dist/wrapper-operation.d.ts.map +1 -0
- package/dist/wrapper-operation.js +311 -0
- package/dist/wrapper-operation.js.map +1 -0
- package/index.d.ts +1 -0
- package/package.json +84 -0
- package/src/abi.ts +493 -0
- package/src/action-source-resolver.ts +660 -0
- package/src/artifacts.ts +87 -0
- package/src/builder.ts +37 -0
- package/src/deploy-operation.ts +458 -0
- package/src/encoding.ts +58 -0
- package/src/engine.ts +13226 -0
- package/src/errors.ts +35 -0
- package/src/fee-ticket-operation.ts +518 -0
- package/src/index.ts +27 -0
- package/src/ladder-limit-orders.ts +184 -0
- package/src/mint-availability-operation.ts +146 -0
- package/src/models.ts +103 -0
- package/src/operations.ts +46 -0
- package/src/paid-mint-amount.ts +402 -0
- package/src/protocol.ts +28 -0
- package/src/runtime.ts +29 -0
- package/src/sale-common.ts +1238 -0
- package/src/source-provider.ts +12 -0
- package/src/source-validation.ts +47 -0
- package/src/token-amount.ts +302 -0
- package/src/token-operation.ts +384 -0
- package/src/trade-fee.ts +264 -0
- package/src/trading-operation.ts +842 -0
- package/src/verify-operation.ts +400 -0
- package/src/wallet-operation.ts +86 -0
- package/src/wasm-provider.ts +32 -0
- package/src/wrapper-operation.ts +531 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export const KCC20_PAID_MINT_MIN_GROSS_SOMPI = 50000000n;
|
|
2
|
+
export const KCC20_VERIFY_PAID_MINT_MIN_GROSS_SOMPI = 100000000n;
|
|
3
|
+
export const KCC20_RECOMMENDED_PAID_MINT_MIN_GROSS_SOMPI = 55000000n;
|
|
4
|
+
export const KCC20_MIN_PAID_MINT_TREASURY_OUTPUT_SOMPI = 2003085n;
|
|
5
|
+
const KCC20_FEE_DENOMINATOR_BPS = 10000n;
|
|
6
|
+
const KCC20_PAID_MINT_GROSS_SEARCH_MAX_DOUBLINGS = 64;
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether all remaining paid-mint supply can produce at least the
|
|
9
|
+
* required gross amount. The comparison is cross-multiplied so fractional
|
|
10
|
+
* display scales are handled without rounding or floating-point arithmetic.
|
|
11
|
+
*/
|
|
12
|
+
export function kcc20PaidMintCapacityMeetsMinimumGross(input) {
|
|
13
|
+
assertPositivePriceScale(input.priceScale);
|
|
14
|
+
if (input.unitPriceSompi <= 0n)
|
|
15
|
+
return true;
|
|
16
|
+
if (input.remainingTokenAmount <= 0n)
|
|
17
|
+
return false;
|
|
18
|
+
const minimumGrossSompi = input.minimumGrossSompi ?? KCC20_PAID_MINT_MIN_GROSS_SOMPI;
|
|
19
|
+
if (minimumGrossSompi < 0n) {
|
|
20
|
+
throw new Error("minimumGrossSompi must not be negative");
|
|
21
|
+
}
|
|
22
|
+
return (input.remainingTokenAmount * input.unitPriceSompi >=
|
|
23
|
+
minimumGrossSompi * input.priceScale);
|
|
24
|
+
}
|
|
25
|
+
export function kcc20PaidMintExactGrossSompi(input) {
|
|
26
|
+
if (input.unitPriceSompi <= 0n) {
|
|
27
|
+
return 0n;
|
|
28
|
+
}
|
|
29
|
+
assertPositivePriceScale(input.priceScale);
|
|
30
|
+
const numerator = input.tokenAmount * input.unitPriceSompi;
|
|
31
|
+
const remainder = numerator % input.priceScale;
|
|
32
|
+
if (remainder !== 0n) {
|
|
33
|
+
throw new Error(`paid mint amount is not valid for token decimals: tokenAmount=${input.tokenAmount} unitPriceSompi=${input.unitPriceSompi} priceScale=${input.priceScale}`);
|
|
34
|
+
}
|
|
35
|
+
return numerator / input.priceScale;
|
|
36
|
+
}
|
|
37
|
+
export function kcc20PaidMintAmountStep(unitPriceSompi, priceScale) {
|
|
38
|
+
if (unitPriceSompi <= 0n) {
|
|
39
|
+
return 1n;
|
|
40
|
+
}
|
|
41
|
+
assertPositivePriceScale(priceScale);
|
|
42
|
+
return priceScale / gcd(priceScale, unitPriceSompi);
|
|
43
|
+
}
|
|
44
|
+
export function kcc20SnapPaidMintAmountUp(input) {
|
|
45
|
+
const step = kcc20PaidMintAmountStep(input.unitPriceSompi, input.priceScale);
|
|
46
|
+
const remainder = input.tokenAmount % step;
|
|
47
|
+
return remainder === 0n
|
|
48
|
+
? input.tokenAmount
|
|
49
|
+
: input.tokenAmount + step - remainder;
|
|
50
|
+
}
|
|
51
|
+
export function kcc20MinimumPaidMintAmount(input) {
|
|
52
|
+
if (input.unitPriceSompi <= 0n) {
|
|
53
|
+
return input.priceScale;
|
|
54
|
+
}
|
|
55
|
+
const minGrossSompi = input.minGrossSompi ?? KCC20_PAID_MINT_MIN_GROSS_SOMPI;
|
|
56
|
+
const minimumAmountAtProtocolFloor = kcc20SnapPaidMintAmountUp({
|
|
57
|
+
tokenAmount: ceilDiv(minGrossSompi * input.priceScale, input.unitPriceSompi),
|
|
58
|
+
unitPriceSompi: input.unitPriceSompi,
|
|
59
|
+
priceScale: input.priceScale,
|
|
60
|
+
});
|
|
61
|
+
if (normalizeFeeBps(input.protocolFeeBps) >= Number(KCC20_FEE_DENOMINATOR_BPS)) {
|
|
62
|
+
return minimumAmountAtProtocolFloor;
|
|
63
|
+
}
|
|
64
|
+
const wholeDisplayTokens = ceilDiv(minimumAmountAtProtocolFloor, input.priceScale);
|
|
65
|
+
return kcc20SnapPaidMintAmountUp({
|
|
66
|
+
tokenAmount: wholeDisplayTokens * input.priceScale,
|
|
67
|
+
unitPriceSompi: input.unitPriceSompi,
|
|
68
|
+
priceScale: input.priceScale,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function kcc20ValidatePaidMintAmount(input) {
|
|
72
|
+
const grossSompi = kcc20PaidMintExactGrossSompi(input);
|
|
73
|
+
const minGrossSompi = input.minGrossSompi ?? KCC20_PAID_MINT_MIN_GROSS_SOMPI;
|
|
74
|
+
if (grossSompi > 0n && grossSompi < minGrossSompi) {
|
|
75
|
+
throw new Error(`paid mint gross ${formatSompiAsKas(grossSompi)} KAS is below ${input.minimumGrossLabel ?? "minimum protocol fee"} ${formatSompiAsKas(minGrossSompi)} KAS`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function kcc20PaidMintFeeSplit(grossSompi, protocolFeeBps, minGrossSompi = KCC20_PAID_MINT_MIN_GROSS_SOMPI) {
|
|
79
|
+
if (grossSompi <= 0n) {
|
|
80
|
+
return { fee: 0n, net: 0n };
|
|
81
|
+
}
|
|
82
|
+
const bps = normalizeFeeBps(protocolFeeBps);
|
|
83
|
+
const percentageFee = (grossSompi * BigInt(bps)) / KCC20_FEE_DENOMINATOR_BPS;
|
|
84
|
+
const fee = percentageFee < minGrossSompi ? minGrossSompi : percentageFee;
|
|
85
|
+
return { fee, net: grossSompi - fee };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Produces a transaction-safe paid-mint amount. It enforces exact sompi,
|
|
89
|
+
* protocol-fee, and non-zero treasury-output dust constraints in one place.
|
|
90
|
+
*/
|
|
91
|
+
export function buildKcc20PaidMintAmountQuote(input) {
|
|
92
|
+
if (input.tokenAmount <= 0n || input.unitPriceSompi < 0n)
|
|
93
|
+
return undefined;
|
|
94
|
+
assertPositivePriceScale(input.priceScale);
|
|
95
|
+
if (input.unitPriceSompi === 0n) {
|
|
96
|
+
return {
|
|
97
|
+
tokenAmount: input.tokenAmount,
|
|
98
|
+
adjustedTokenAmount: input.tokenAmount,
|
|
99
|
+
grossSompi: 0n,
|
|
100
|
+
adjusted: false,
|
|
101
|
+
belowMinimumGross: false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const minimumGrossSompi = input.minimumGrossSompi ?? KCC20_RECOMMENDED_PAID_MINT_MIN_GROSS_SOMPI;
|
|
105
|
+
const step = kcc20PaidMintAmountStep(input.unitPriceSompi, input.priceScale);
|
|
106
|
+
let adjustedTokenAmount = roundUpToStep(input.tokenAmount, step);
|
|
107
|
+
const typedGrossSompi = kcc20PaidMintExactGrossSompi({
|
|
108
|
+
...input,
|
|
109
|
+
tokenAmount: adjustedTokenAmount,
|
|
110
|
+
});
|
|
111
|
+
if (typedGrossSompi < minimumGrossSompi) {
|
|
112
|
+
return {
|
|
113
|
+
tokenAmount: input.tokenAmount,
|
|
114
|
+
adjustedTokenAmount,
|
|
115
|
+
grossSompi: typedGrossSompi,
|
|
116
|
+
adjusted: adjustedTokenAmount !== input.tokenAmount,
|
|
117
|
+
belowMinimumGross: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const feeBps = normalizeUiFeeBps(input.protocolFeeBps);
|
|
121
|
+
if (!isKcc20SafePaidMintGross(typedGrossSompi, feeBps)) {
|
|
122
|
+
const safeTokenAmount = feeBps < Number(KCC20_FEE_DENOMINATOR_BPS)
|
|
123
|
+
? snapPaidMintToSafeWholeTokens(adjustedTokenAmount, input.unitPriceSompi, input.priceScale, step, feeBps)
|
|
124
|
+
: snapPaidMintToSafeExact(adjustedTokenAmount, input.unitPriceSompi, input.priceScale, step, feeBps);
|
|
125
|
+
if (safeTokenAmount === undefined)
|
|
126
|
+
return undefined;
|
|
127
|
+
adjustedTokenAmount = safeTokenAmount;
|
|
128
|
+
}
|
|
129
|
+
const grossSompi = kcc20PaidMintExactGrossSompi({
|
|
130
|
+
...input,
|
|
131
|
+
tokenAmount: adjustedTokenAmount,
|
|
132
|
+
});
|
|
133
|
+
if (!isKcc20SafePaidMintGross(grossSompi, feeBps))
|
|
134
|
+
return undefined;
|
|
135
|
+
return {
|
|
136
|
+
tokenAmount: input.tokenAmount,
|
|
137
|
+
adjustedTokenAmount,
|
|
138
|
+
grossSompi,
|
|
139
|
+
adjusted: adjustedTokenAmount !== input.tokenAmount,
|
|
140
|
+
belowMinimumGross: false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function kcc20MinimumSafePaidMintAmount(input) {
|
|
144
|
+
if (input.unitPriceSompi <= 0n)
|
|
145
|
+
return undefined;
|
|
146
|
+
const minimumGrossSompi = input.minimumGrossSompi ?? KCC20_RECOMMENDED_PAID_MINT_MIN_GROSS_SOMPI;
|
|
147
|
+
const minimum = kcc20SnapPaidMintAmountUp({
|
|
148
|
+
tokenAmount: ceilDiv(minimumGrossSompi * input.priceScale, input.unitPriceSompi),
|
|
149
|
+
unitPriceSompi: input.unitPriceSompi,
|
|
150
|
+
priceScale: input.priceScale,
|
|
151
|
+
});
|
|
152
|
+
const quote = buildKcc20PaidMintAmountQuote({
|
|
153
|
+
...input,
|
|
154
|
+
tokenAmount: minimum,
|
|
155
|
+
minimumGrossSompi,
|
|
156
|
+
});
|
|
157
|
+
return quote?.adjustedTokenAmount ?? minimum;
|
|
158
|
+
}
|
|
159
|
+
export function isKcc20SafePaidMintGross(grossSompi, protocolFeeBps) {
|
|
160
|
+
if (grossSompi < KCC20_PAID_MINT_MIN_GROSS_SOMPI)
|
|
161
|
+
return false;
|
|
162
|
+
const split = kcc20PaidMintFeeSplit(grossSompi, normalizeUiFeeBps(protocolFeeBps));
|
|
163
|
+
return (split.net >= 0n &&
|
|
164
|
+
(split.net === 0n || split.net >= KCC20_MIN_PAID_MINT_TREASURY_OUTPUT_SOMPI));
|
|
165
|
+
}
|
|
166
|
+
function snapPaidMintToSafeExact(start, price, scale, step, feeBps) {
|
|
167
|
+
let amount = start;
|
|
168
|
+
for (let index = 0; index < KCC20_PAID_MINT_GROSS_SEARCH_MAX_DOUBLINGS; index += 1) {
|
|
169
|
+
const gross = kcc20PaidMintExactGrossSompi({
|
|
170
|
+
tokenAmount: amount,
|
|
171
|
+
unitPriceSompi: price,
|
|
172
|
+
priceScale: scale,
|
|
173
|
+
});
|
|
174
|
+
if (isKcc20SafePaidMintGross(gross, feeBps))
|
|
175
|
+
return amount;
|
|
176
|
+
const nextGross = smallestSafePaidMintGrossSompi(gross + 1n, feeBps);
|
|
177
|
+
if (nextGross === undefined)
|
|
178
|
+
return undefined;
|
|
179
|
+
const next = roundUpToStep(ceilDiv(nextGross * scale, price), step);
|
|
180
|
+
amount = next > amount ? next : amount + step;
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
function snapPaidMintToSafeWholeTokens(start, price, scale, step, feeBps) {
|
|
185
|
+
let amount = roundUpToStep(ceilDiv(start, scale) * scale, step);
|
|
186
|
+
for (let index = 0; index < KCC20_PAID_MINT_GROSS_SEARCH_MAX_DOUBLINGS; index += 1) {
|
|
187
|
+
const gross = kcc20PaidMintExactGrossSompi({
|
|
188
|
+
tokenAmount: amount,
|
|
189
|
+
unitPriceSompi: price,
|
|
190
|
+
priceScale: scale,
|
|
191
|
+
});
|
|
192
|
+
if (isKcc20SafePaidMintGross(gross, feeBps))
|
|
193
|
+
return amount;
|
|
194
|
+
const nextGross = smallestSafePaidMintGrossSompi(gross + 1n, feeBps);
|
|
195
|
+
if (nextGross === undefined)
|
|
196
|
+
return undefined;
|
|
197
|
+
let next = roundUpToStep(ceilDiv(nextGross * scale, price), step);
|
|
198
|
+
next = roundUpToStep(ceilDiv(next, scale) * scale, step);
|
|
199
|
+
amount = next > amount ? next : roundUpToStep(amount + scale, step);
|
|
200
|
+
}
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
function smallestSafePaidMintGrossSompi(minimum, feeBps) {
|
|
204
|
+
let low = minimum < KCC20_PAID_MINT_MIN_GROSS_SOMPI
|
|
205
|
+
? KCC20_PAID_MINT_MIN_GROSS_SOMPI
|
|
206
|
+
: minimum;
|
|
207
|
+
if (isKcc20SafePaidMintGross(low, feeBps))
|
|
208
|
+
return low;
|
|
209
|
+
let high = low + 1n;
|
|
210
|
+
for (let index = 0; index < KCC20_PAID_MINT_GROSS_SEARCH_MAX_DOUBLINGS; index += 1) {
|
|
211
|
+
if (isKcc20SafePaidMintGross(high, feeBps)) {
|
|
212
|
+
while (low + 1n < high) {
|
|
213
|
+
const middle = low + (high - low) / 2n;
|
|
214
|
+
if (isKcc20SafePaidMintGross(middle, feeBps))
|
|
215
|
+
high = middle;
|
|
216
|
+
else
|
|
217
|
+
low = middle;
|
|
218
|
+
}
|
|
219
|
+
return high;
|
|
220
|
+
}
|
|
221
|
+
high += high - low + 1n;
|
|
222
|
+
}
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
function normalizeUiFeeBps(value) {
|
|
226
|
+
return Number.isInteger(value) && value !== null && value !== undefined
|
|
227
|
+
? Math.min(10_000, Math.max(0, value))
|
|
228
|
+
: 200;
|
|
229
|
+
}
|
|
230
|
+
function roundUpToStep(value, step) {
|
|
231
|
+
const remainder = value % step;
|
|
232
|
+
return remainder === 0n ? value : value + step - remainder;
|
|
233
|
+
}
|
|
234
|
+
function normalizeFeeBps(value) {
|
|
235
|
+
if (value === null || value === undefined) {
|
|
236
|
+
return 200;
|
|
237
|
+
}
|
|
238
|
+
if (!Number.isInteger(value) || value < 0 || value > 10_000) {
|
|
239
|
+
throw new Error("protocolFeeBps must be 0..10000");
|
|
240
|
+
}
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
function ceilDiv(left, right) {
|
|
244
|
+
return (left + right - 1n) / right;
|
|
245
|
+
}
|
|
246
|
+
function assertPositivePriceScale(priceScale) {
|
|
247
|
+
if (priceScale <= 0n) {
|
|
248
|
+
throw new Error("paid mint priceScale must be greater than zero");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function formatSompiAsKas(value) {
|
|
252
|
+
const whole = value / 100000000n;
|
|
253
|
+
const fractional = value % 100000000n;
|
|
254
|
+
if (fractional === 0n)
|
|
255
|
+
return whole.toString();
|
|
256
|
+
return `${whole}.${fractional.toString().padStart(8, "0").replace(/0+$/, "")}`;
|
|
257
|
+
}
|
|
258
|
+
function gcd(left, right) {
|
|
259
|
+
let a = left < 0n ? -left : left;
|
|
260
|
+
let b = right < 0n ? -right : right;
|
|
261
|
+
while (b !== 0n) {
|
|
262
|
+
const remainder = a % b;
|
|
263
|
+
a = b;
|
|
264
|
+
b = remainder;
|
|
265
|
+
}
|
|
266
|
+
return a;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=paid-mint-amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paid-mint-amount.js","sourceRoot":"","sources":["../src/paid-mint-amount.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,+BAA+B,GAAG,SAAW,CAAC;AAC3D,MAAM,CAAC,MAAM,sCAAsC,GAAG,UAAY,CAAC;AACnE,MAAM,CAAC,MAAM,2CAA2C,GAAG,SAAW,CAAC;AACvE,MAAM,CAAC,MAAM,yCAAyC,GAAG,QAAU,CAAC;AAEpE,MAAM,yBAAyB,GAAG,MAAO,CAAC;AAC1C,MAAM,0CAA0C,GAAG,EAAE,CAAC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CAAC,KAKtD;IACC,wBAAwB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,KAAK,CAAC,cAAc,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC;IACnD,MAAM,iBAAiB,GACrB,KAAK,CAAC,iBAAiB,IAAI,+BAA+B,CAAC;IAC7D,IAAI,iB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K,CAAC,QAAQ,EAAE,CAAC;IAC/C,OAAO,GAAG,KAAK,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,SAAS,GAAG,CAAC,IAAY,EAAE,KAAa;IACtC,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QAChB,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,SAAS,CAAC;IAChB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const SUBNETWORK_ID_NATIVE: "0000000000000000000000000000000000000000";
|
|
2
|
+
export declare const ZERO_HASH: "0000000000000000000000000000000000000000000000000000000000000000";
|
|
3
|
+
export declare const SOMPI_PER_TKAS = 100000000n;
|
|
4
|
+
export declare const DEFAULT_TOKEN_OUTPUT_SOMPI = 50000000n;
|
|
5
|
+
export declare const DEFAULT_COMPUTE_BUDGET = 200;
|
|
6
|
+
export declare const DEFAULT_KCC20_FEE_BPS = 200n;
|
|
7
|
+
export declare const DEFAULT_KCC20_MIN_PROTOCOL_FEE_SOMPI = 50000000n;
|
|
8
|
+
export declare const DEFAULT_KCC20_TOKEN_DECIMALS = 8;
|
|
9
|
+
export declare const KCC20_PUBLIC_MINT_MAX_DISPLAY_TOKENS = 100000n;
|
|
10
|
+
export declare const KCC20_PUBLIC_MINT_MAX_DISPLAY_TOKENS_LABEL = "100,000";
|
|
11
|
+
export declare const KCC20_TICKER_MAX_LENGTH = 12;
|
|
12
|
+
export declare const KCC20_TOKEN_NAME_MAX_LENGTH = 32;
|
|
13
|
+
export declare const KCC20_ORDERBOOK_MAX_SWEEP_BID_LEGS = 3;
|
|
14
|
+
export declare const KCC20_ORDERBOOK_MAX_EXPANDED_SWEEP_BID_LEGS = 10;
|
|
15
|
+
export declare const KCC20_ORDERBOOK_EXPANDED_SWEEP_OUTPUT_SOMPI = 200000000n;
|
|
16
|
+
export declare const DEFAULT_KCC20_PRICE_SCALE: bigint;
|
|
17
|
+
export declare const KCC20_MIN_PROTOCOL_FEE_SOMPI = 50000000n;
|
|
18
|
+
export declare const KCC20_DEFAULT_PROTOCOL_FEE_BPS = 200n;
|
|
19
|
+
export declare const KCC20_DEFAULT_PRICE_SCALE: bigint;
|
|
20
|
+
export declare const KCC20_PLATFORM_PROTOCOL_FEE_RECIPIENT: "ce2100e68197c8e695bd781d07e2bd5de7ed77f5a97668884190531bdc632c01";
|
|
21
|
+
export declare const KCC20_ORDERBOOK_PROTOCOL_FEE_RECIPIENT: "ce2100e68197c8e695bd781d07e2bd5de7ed77f5a97668884190531bdc632c01";
|
|
22
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,EAC/B,0CAAmD,CAAC;AACtD,eAAO,MAAM,SAAS,EACpB,kEAA2E,CAAC;AAC9E,eAAO,MAAM,cAAc,aAAe,CAAC;AAC3C,eAAO,MAAM,0BAA0B,YAAc,CAAC;AACtD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,oCAAoC,YAAc,CAAC;AAChE,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,oCAAoC,UAAW,CAAC;AAC7D,eAAO,MAAM,0CAA0C,YAAY,CAAC;AACpE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,2CAA2C,KAAK,CAAC;AAC9D,eAAO,MAAM,2CAA2C,aAAe,CAAC;AACxE,eAAO,MAAM,yBAAyB,QACO,CAAC;AAC9C,eAAO,MAAM,4BAA4B,YACH,CAAC;AACvC,eAAO,MAAM,8BAA8B,OAAwB,CAAC;AACpE,eAAO,MAAM,yBAAyB,QAA4B,CAAC;AAEnE,eAAO,MAAM,qCAAqC,EAChD,kEAA2E,CAAC;AAC9E,eAAO,MAAM,sCAAsC,oEACZ,CAAC"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const SUBNETWORK_ID_NATIVE = "0000000000000000000000000000000000000000";
|
|
2
|
+
export const ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
3
|
+
export const SOMPI_PER_TKAS = 100000000n;
|
|
4
|
+
export const DEFAULT_TOKEN_OUTPUT_SOMPI = 50000000n;
|
|
5
|
+
export const DEFAULT_COMPUTE_BUDGET = 200;
|
|
6
|
+
export const DEFAULT_KCC20_FEE_BPS = 200n;
|
|
7
|
+
export const DEFAULT_KCC20_MIN_PROTOCOL_FEE_SOMPI = 50000000n;
|
|
8
|
+
export const DEFAULT_KCC20_TOKEN_DECIMALS = 8;
|
|
9
|
+
export const KCC20_PUBLIC_MINT_MAX_DISPLAY_TOKENS = 100000n;
|
|
10
|
+
export const KCC20_PUBLIC_MINT_MAX_DISPLAY_TOKENS_LABEL = "100,000";
|
|
11
|
+
export const KCC20_TICKER_MAX_LENGTH = 12;
|
|
12
|
+
export const KCC20_TOKEN_NAME_MAX_LENGTH = 32;
|
|
13
|
+
export const KCC20_ORDERBOOK_MAX_SWEEP_BID_LEGS = 3;
|
|
14
|
+
export const KCC20_ORDERBOOK_MAX_EXPANDED_SWEEP_BID_LEGS = 10;
|
|
15
|
+
export const KCC20_ORDERBOOK_EXPANDED_SWEEP_OUTPUT_SOMPI = 200000000n;
|
|
16
|
+
export const DEFAULT_KCC20_PRICE_SCALE = 10n ** BigInt(DEFAULT_KCC20_TOKEN_DECIMALS);
|
|
17
|
+
export const KCC20_MIN_PROTOCOL_FEE_SOMPI = DEFAULT_KCC20_MIN_PROTOCOL_FEE_SOMPI;
|
|
18
|
+
export const KCC20_DEFAULT_PROTOCOL_FEE_BPS = DEFAULT_KCC20_FEE_BPS;
|
|
19
|
+
export const KCC20_DEFAULT_PRICE_SCALE = DEFAULT_KCC20_PRICE_SCALE;
|
|
20
|
+
export const KCC20_PLATFORM_PROTOCOL_FEE_RECIPIENT = "ce2100e68197c8e695bd781d07e2bd5de7ed77f5a97668884190531bdc632c01";
|
|
21
|
+
export const KCC20_ORDERBOOK_PROTOCOL_FEE_RECIPIENT = KCC20_PLATFORM_PROTOCOL_FEE_RECIPIENT;
|
|
22
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAC/B,0CAAmD,CAAC;AACtD,MAAM,CAAC,MAAM,SAAS,GACpB,kEAA2E,CAAC;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,UAAY,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAW,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAW,CAAC;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAQ,CAAC;AAC7D,MAAM,CAAC,MAAM,0CAA0C,GAAG,SAAS,CAAC;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,2CAA2C,GAAG,EAAE,CAAC;AAC9D,MAAM,CAAC,MAAM,2CAA2C,GAAG,UAAY,CAAC;AACxE,MAAM,CAAC,MAAM,yBAAyB,GACpC,GAAG,IAAI,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GACvC,oCAAoC,CAAC;AACvC,MAAM,CAAC,MAAM,8BAA8B,GAAG,qBAAqB,CAAC;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAEnE,MAAM,CAAC,MAAM,qCAAqC,GAChD,kEAA2E,CAAC;AAC9E,MAAM,CAAC,MAAM,sCAAsC,GACjD,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared package receives a runtime from its host application.
|
|
3
|
+
*
|
|
4
|
+
* Do not replace this with an import from either Kaspa WASM build. The browser
|
|
5
|
+
* and Node applications initialize different binaries and use different asset
|
|
6
|
+
* loading mechanisms.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A loaded Kaspa module supplied by the host application. The shared package
|
|
10
|
+
* intentionally does not prescribe the exact generated-WASM TypeScript
|
|
11
|
+
* declarations. Operation modules should narrow the capabilities they use.
|
|
12
|
+
*/
|
|
13
|
+
export interface KaspaWasmRuntime {
|
|
14
|
+
readonly [capability: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface CoreKaspaWasmCapabilities extends KaspaWasmRuntime {
|
|
17
|
+
readonly addressFromScriptPublicKey: (...args: any[]) => any;
|
|
18
|
+
readonly payToScriptHashScript: (...args: any[]) => any;
|
|
19
|
+
readonly payToAddressScript: (...args: any[]) => any;
|
|
20
|
+
readonly ScriptBuilder: any;
|
|
21
|
+
readonly Transaction: any;
|
|
22
|
+
readonly TransactionInput: any;
|
|
23
|
+
readonly TransactionOutput: any;
|
|
24
|
+
}
|
|
25
|
+
export interface KaspaWasmProvider {
|
|
26
|
+
getRuntime(): Promise<KaspaWasmRuntime>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE,QAAQ,CAAC,0BAA0B,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAC7D,QAAQ,CAAC,qBAAqB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IACxD,QAAQ,CAAC,kBAAkB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
export { DEFAULT_COMPUTE_BUDGET, DEFAULT_KCC20_FEE_BPS, DEFAULT_KCC20_MIN_PROTOCOL_FEE_SOMPI, DEFAULT_KCC20_PRICE_SCALE, DEFAULT_KCC20_TOKEN_DECIMALS, DEFAULT_TOKEN_OUTPUT_SOMPI, KCC20_ORDERBOOK_EXPANDED_SWEEP_OUTPUT_SOMPI, KCC20_ORDERBOOK_MAX_EXPANDED_SWEEP_BID_LEGS, KCC20_ORDERBOOK_MAX_SWEEP_BID_LEGS, KCC20_ORDERBOOK_PROTOCOL_FEE_RECIPIENT, KCC20_PLATFORM_PROTOCOL_FEE_RECIPIENT, SOMPI_PER_TKAS, SUBNETWORK_ID_NATIVE, ZERO_HASH, } from "./protocol.js";
|
|
2
|
+
export declare const DEFAULT_FEE = 50000n;
|
|
3
|
+
export declare const DEFAULT_KCC20_MIN_GROSS_FILL_SOMPI = 50000000n;
|
|
4
|
+
export declare function kcc20PsktBuilderError(message: any, code: any, details?: {}): Error;
|
|
5
|
+
export declare function parseArgs(argv: any): {
|
|
6
|
+
flags: Set<unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseTokenDecimalsArg(args: any): number | null;
|
|
9
|
+
export declare function resolveKcc20TokenDecimals(args: any, ...values: any[]): number;
|
|
10
|
+
export declare function parseKcc20TokenAmount(value: any, label?: string, decimals?: number): bigint;
|
|
11
|
+
export declare function parseKcc20TokenAmountArg(args: any, key: any, fallback: any, label?: any): bigint;
|
|
12
|
+
export declare function resolveKcc20PriceScale(args: any, fallback?: bigint): bigint;
|
|
13
|
+
export declare function requireHex32(value: any, label: any): string;
|
|
14
|
+
export declare function identifierTypeName(t: any): "p2pk-schnorr/v1" | "p2pkh-schnorr/v1" | "p2pkh-ecdsa/v1" | "p2sh/v1" | "covenant-id/v1" | "unknown";
|
|
15
|
+
export declare function parseMintPolicy(value: any): 2 | 0 | 1;
|
|
16
|
+
export declare function mintPolicyName(mode: any): "fixed" | "controlled" | "public" | "unknown";
|
|
17
|
+
export declare function hexToBytes(hex: any): Uint8Array<ArrayBuffer>;
|
|
18
|
+
export declare function bytesToHex(bytes: any): string;
|
|
19
|
+
export declare function asciiToBytes32(value: any, label: any): Uint8Array<ArrayBuffer>;
|
|
20
|
+
export declare function bytes32ToAscii(bytes: any): string;
|
|
21
|
+
export declare function writeI64LE(value: any): Uint8Array<ArrayBuffer>;
|
|
22
|
+
export declare function readI64LE(bytes: any): bigint;
|
|
23
|
+
export declare function normalizeSignature(bytes: any): any;
|
|
24
|
+
export declare function patchRange(target: any, start: any, end: any, replacement: any): void;
|
|
25
|
+
export declare function buildNativeKcc20ScriptForState(baseScript: any, state: any): Uint8Array<any>;
|
|
26
|
+
export declare function buildKcc20V3ScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
27
|
+
export declare function buildApiPaymentChannelScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
28
|
+
export declare function buildKcc20OrderbookScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
29
|
+
export declare function buildKcc20FeeTicketScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
30
|
+
export declare function buildKcc20VestingScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
31
|
+
export declare function buildKaspaFomoRoundScript(baseScript: any, state: any, recipients?: {}): Uint8Array<ArrayBuffer>;
|
|
32
|
+
export declare function buildKaspaFomoRoundScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
33
|
+
export declare function readKaspaFomoRoundState(script: any): {
|
|
34
|
+
lastBuyer: string;
|
|
35
|
+
endTimeMs: bigint;
|
|
36
|
+
ticketCount: bigint;
|
|
37
|
+
};
|
|
38
|
+
export declare function buildKcc20WrapperScriptForState(baseScript: any, state: any): Uint8Array<ArrayBuffer>;
|
|
39
|
+
export declare function orderbookModeName(mode: any): "ask" | "bid" | "unknown" | "holder" | "root";
|
|
40
|
+
export declare function stateToReceiptFields(state: any): {
|
|
41
|
+
owner: string;
|
|
42
|
+
ownerScheme: number;
|
|
43
|
+
ownerSchemeName: string;
|
|
44
|
+
borrowScheme: number;
|
|
45
|
+
borrowGuard: string;
|
|
46
|
+
extensionCommitment: string;
|
|
47
|
+
tokenAmount: string;
|
|
48
|
+
stateAmount: string;
|
|
49
|
+
balance: string;
|
|
50
|
+
amount: string;
|
|
51
|
+
isMintAuthority: boolean;
|
|
52
|
+
};
|
|
53
|
+
export declare function stateToV3ReceiptFields(state: any): {
|
|
54
|
+
ownerIdentifier: string;
|
|
55
|
+
stateOwner: string;
|
|
56
|
+
ownerScheme: number;
|
|
57
|
+
ownerSchemeName: string;
|
|
58
|
+
tokenAmount: string;
|
|
59
|
+
stateAmount: string;
|
|
60
|
+
amount: string;
|
|
61
|
+
mode: number;
|
|
62
|
+
stateMode: number;
|
|
63
|
+
modeName: string;
|
|
64
|
+
unitPriceSompi: string;
|
|
65
|
+
marketUnitPriceSompi: string;
|
|
66
|
+
priceScale: string;
|
|
67
|
+
tokenDisplayScale: string;
|
|
68
|
+
minGrossFillSompi: string;
|
|
69
|
+
minProtocolFeeSompi: string;
|
|
70
|
+
feeRecipient: "ce2100e68197c8e695bd781d07e2bd5de7ed77f5a97668884190531bdc632c01";
|
|
71
|
+
protocolFeeRecipient: "ce2100e68197c8e695bd781d07e2bd5de7ed77f5a97668884190531bdc632c01";
|
|
72
|
+
feeBps: number;
|
|
73
|
+
protocolFeeBps: number;
|
|
74
|
+
feeTicketId: string;
|
|
75
|
+
};
|
|
76
|
+
export declare function receiptToKcc20OrderbookState(receipt: any, fallbackOwnerHex: any): {
|
|
77
|
+
ownerIdentifier: Uint8Array<ArrayBuffer>;
|
|
78
|
+
ownerScheme: number;
|
|
79
|
+
amount: bigint;
|
|
80
|
+
mode: number;
|
|
81
|
+
unitPriceSompi: bigint;
|
|
82
|
+
priceScale: bigint;
|
|
83
|
+
feeRecipient: Uint8Array<ArrayBuffer>;
|
|
84
|
+
feeBps: number;
|
|
85
|
+
feeTicketId: Uint8Array<ArrayBuffer>;
|
|
86
|
+
};
|
|
87
|
+
export declare function buildKcc20V3IssueSigScript(kw: any, { signature, toOwner, tokenAmount, tokenOutputIndex, rootOutputIndex }: {
|
|
88
|
+
signature: any;
|
|
89
|
+
toOwner: any;
|
|
90
|
+
tokenAmount: any;
|
|
91
|
+
tokenOutputIndex: any;
|
|
92
|
+
rootOutputIndex: any;
|
|
93
|
+
}): any;
|
|
94
|
+
export declare function buildKcc20V3CreateBidSigScript(kw: any, { buyer, bidAmount, unitPriceSompi, bidOutputIndex, rootOutputIndex }: {
|
|
95
|
+
buyer: any;
|
|
96
|
+
bidAmount: any;
|
|
97
|
+
unitPriceSompi: any;
|
|
98
|
+
bidOutputIndex: any;
|
|
99
|
+
rootOutputIndex: any;
|
|
100
|
+
}): any;
|
|
101
|
+
export declare function buildKcc20V3CreateAskSigScript(kw: any, { signature, askAmount, unitPriceSompi, askOutputIndex, changeOutputIndex }: {
|
|
102
|
+
signature: any;
|
|
103
|
+
askAmount: any;
|
|
104
|
+
unitPriceSompi: any;
|
|
105
|
+
askOutputIndex: any;
|
|
106
|
+
changeOutputIndex: any;
|
|
107
|
+
}): any;
|
|
108
|
+
export declare function buildKcc20V3FillAskSigScript(kw: any, { buyerOwner, fillAmount, buyerTokenOutputIndex, askOutputIndex, sellerOutputIndex, }: {
|
|
109
|
+
buyerOwner: any;
|
|
110
|
+
fillAmount: any;
|
|
111
|
+
buyerTokenOutputIndex: any;
|
|
112
|
+
askOutputIndex: any;
|
|
113
|
+
sellerOutputIndex: any;
|
|
114
|
+
}): any;
|
|
115
|
+
export declare function buildKcc20OrderbookFillAskSigScript(kw: any, { buyerOwner, fillAmount, buyerTokenOutputIndex, askOutputIndex, sellerOutputIndex, ticketInputIndex, }: {
|
|
116
|
+
buyerOwner: any;
|
|
117
|
+
fillAmount: any;
|
|
118
|
+
buyerTokenOutputIndex: any;
|
|
119
|
+
askOutputIndex: any;
|
|
120
|
+
sellerOutputIndex: any;
|
|
121
|
+
ticketInputIndex?: number | undefined;
|
|
122
|
+
}): any;
|
|
123
|
+
export declare function buildKcc20V3FillBidSigScript(kw: any, { sellerTokenInputIndex, fillAmount, buyerTokenOutputIndex, bidOutputIndex, sellerOutputIndex, seller, }: {
|
|
124
|
+
sellerTokenInputIndex: any;
|
|
125
|
+
fillAmount: any;
|
|
126
|
+
buyerTokenOutputIndex: any;
|
|
127
|
+
bidOutputIndex: any;
|
|
128
|
+
sellerOutputIndex: any;
|
|
129
|
+
seller: any;
|
|
130
|
+
}): any;
|
|
131
|
+
export declare function buildKcc20OrderbookFillBidSigScript(kw: any, { sellerTokenInputIndex, fillAmount, buyerTokenOutputIndex, bidOutputIndex, sellerOutputIndex, seller, ticketInputIndex, }: {
|
|
132
|
+
sellerTokenInputIndex: any;
|
|
133
|
+
fillAmount: any;
|
|
134
|
+
buyerTokenOutputIndex: any;
|
|
135
|
+
bidOutputIndex: any;
|
|
136
|
+
sellerOutputIndex: any;
|
|
137
|
+
seller: any;
|
|
138
|
+
ticketInputIndex?: number | undefined;
|
|
139
|
+
}): any;
|
|
140
|
+
export declare function buildKcc20V3SellIntoBidSigScript(kw: any, { signature, buyerOwner, fillAmount, buyerTokenOutputIndex, sellerChangeOutputIndex, sellerRefundOutputIndex, sellerOutputsEndIndex, takesRefundOutput, }: {
|
|
141
|
+
signature: any;
|
|
142
|
+
buyerOwner: any;
|
|
143
|
+
fillAmount: any;
|
|
144
|
+
buyerTokenOutputIndex: any;
|
|
145
|
+
sellerChangeOutputIndex: any;
|
|
146
|
+
sellerRefundOutputIndex?: number | undefined;
|
|
147
|
+
sellerOutputsEndIndex?: number | undefined;
|
|
148
|
+
takesRefundOutput?: boolean | undefined;
|
|
149
|
+
}): any;
|
|
150
|
+
export declare function buildKcc20OrderbookCrossAskSigScript(kw: any, { buyerOwner, bidInputIndex, fillAmount, clearingUnitPriceSompi, buyerTokenOutputIndex, askOutputIndex, bidOutputIndex, sellerOutputIndex, feeOutputIndex, refundOutputIndex, ticketInputIndex, }: {
|
|
151
|
+
buyerOwner: any;
|
|
152
|
+
bidInputIndex: any;
|
|
153
|
+
fillAmount: any;
|
|
154
|
+
clearingUnitPriceSompi: any;
|
|
155
|
+
buyerTokenOutputIndex: any;
|
|
156
|
+
askOutputIndex: any;
|
|
157
|
+
bidOutputIndex: any;
|
|
158
|
+
sellerOutputIndex: any;
|
|
159
|
+
feeOutputIndex: any;
|
|
160
|
+
refundOutputIndex: any;
|
|
161
|
+
ticketInputIndex?: number | undefined;
|
|
162
|
+
}): any;
|
|
163
|
+
export declare function buildKcc20OrderbookCrossAskLegacySigScript(kw: any, { buyerOwner, bidInputIndex, fillAmount, clearingUnitPriceSompi, buyerTokenOutputIndex, askOutputIndex, bidOutputIndex, sellerOutputIndex, feeOutputIndex, refundOutputIndex, }: {
|
|
164
|
+
buyerOwner: any;
|
|
165
|
+
bidInputIndex: any;
|
|
166
|
+
fillAmount: any;
|
|
167
|
+
clearingUnitPriceSompi: any;
|
|
168
|
+
buyerTokenOutputIndex: any;
|
|
169
|
+
askOutputIndex: any;
|
|
170
|
+
bidOutputIndex: any;
|
|
171
|
+
sellerOutputIndex: any;
|
|
172
|
+
feeOutputIndex: any;
|
|
173
|
+
refundOutputIndex: any;
|
|
174
|
+
}): any;
|
|
175
|
+
export declare function buildKcc20OrderbookCrossBidSigScript(kw: any, { askInputIndex, fillAmount, clearingUnitPriceSompi, buyerTokenOutputIndex, askOutputIndex, bidOutputIndex, sellerOutputIndex, feeOutputIndex, refundOutputIndex, seller, ticketInputIndex, }: {
|
|
176
|
+
askInputIndex: any;
|
|
177
|
+
fillAmount: any;
|
|
178
|
+
clearingUnitPriceSompi: any;
|
|
179
|
+
buyerTokenOutputIndex: any;
|
|
180
|
+
askOutputIndex: any;
|
|
181
|
+
bidOutputIndex: any;
|
|
182
|
+
sellerOutputIndex: any;
|
|
183
|
+
feeOutputIndex: any;
|
|
184
|
+
refundOutputIndex: any;
|
|
185
|
+
seller: any;
|
|
186
|
+
ticketInputIndex?: number | undefined;
|
|
187
|
+
}): any;
|
|
188
|
+
export declare function buildKcc20OrderbookCrossBidLegacySigScript(kw: any, { askInputIndex, fillAmount, clearingUnitPriceSompi, buyerTokenOutputIndex, askOutputIndex, bidOutputIndex, sellerOutputIndex, feeOutputIndex, refundOutputIndex, seller, }: {
|
|
189
|
+
askInputIndex: any;
|
|
190
|
+
fillAmount: any;
|
|
191
|
+
clearingUnitPriceSompi: any;
|
|
192
|
+
buyerTokenOutputIndex: any;
|
|
193
|
+
askOutputIndex: any;
|
|
194
|
+
bidOutputIndex: any;
|
|
195
|
+
sellerOutputIndex: any;
|
|
196
|
+
feeOutputIndex: any;
|
|
197
|
+
refundOutputIndex: any;
|
|
198
|
+
seller: any;
|
|
199
|
+
}): any;
|
|
200
|
+
export declare function buildKcc20OrderbookCancelAskSigScript(kw: any, { signature, holderOutputIndex }: {
|
|
201
|
+
signature: any;
|
|
202
|
+
holderOutputIndex: any;
|
|
203
|
+
}): any;
|
|
204
|
+
export declare function buildKcc20OrderbookCancelBidSigScript(kw: any, { signature, refundOutputIndex }: {
|
|
205
|
+
signature: any;
|
|
206
|
+
refundOutputIndex: any;
|
|
207
|
+
}): any;
|
|
208
|
+
export declare function buildKcc20OrderbookMergePrimarySigScript(kw: any, { signature }: {
|
|
209
|
+
signature: any;
|
|
210
|
+
}): any;
|
|
211
|
+
export declare function buildKcc20OrderbookMergePeerSigScript(kw: any, { signature, primaryInputIndex, mergedAmount }: {
|
|
212
|
+
signature: any;
|
|
213
|
+
primaryInputIndex: any;
|
|
214
|
+
mergedAmount: any;
|
|
215
|
+
}): any;
|
|
216
|
+
export declare function buildKcc20OrderbookFillBidFromSellerSweepSigScript(kw: any, { sellerTokenInputIndex, sellerAuthOutputOrdinal, fillAmount, buyerTokenOutputIndex, bidOutputIndex, sellerOutputIndex, seller, ticketInputIndex, }: {
|
|
217
|
+
sellerTokenInputIndex: any;
|
|
218
|
+
sellerAuthOutputOrdinal: any;
|
|
219
|
+
fillAmount: any;
|
|
220
|
+
buyerTokenOutputIndex: any;
|
|
221
|
+
bidOutputIndex: any;
|
|
222
|
+
sellerOutputIndex: any;
|
|
223
|
+
seller: any;
|
|
224
|
+
ticketInputIndex?: number | undefined;
|
|
225
|
+
}): any;
|
|
226
|
+
export declare function buildKcc20OrderbookSellIntoBidsSigScript(kw: any, { signature, legs, changeOutputIndex, sellerRefundOutputIndex, sellerOutputsEndIndex, takesRefundOutput, }: {
|
|
227
|
+
signature: any;
|
|
228
|
+
legs: any;
|
|
229
|
+
changeOutputIndex: any;
|
|
230
|
+
sellerRefundOutputIndex?: number | undefined;
|
|
231
|
+
sellerOutputsEndIndex?: number | undefined;
|
|
232
|
+
takesRefundOutput?: boolean | undefined;
|
|
233
|
+
}): any;
|
|
234
|
+
export declare function buildKcc20OrderbookSellIntoBids10SigScript(kw: any, { signature, legs, changeOutputIndex, sellerRefundOutputIndex, sellerOutputsEndIndex, takesRefundOutput, }: {
|
|
235
|
+
signature: any;
|
|
236
|
+
legs: any;
|
|
237
|
+
changeOutputIndex: any;
|
|
238
|
+
sellerRefundOutputIndex?: number | undefined;
|
|
239
|
+
sellerOutputsEndIndex?: number | undefined;
|
|
240
|
+
takesRefundOutput?: boolean | undefined;
|
|
241
|
+
}): any;
|
|
242
|
+
export declare function argByteArray(hex: any): {
|
|
243
|
+
kind: string;
|
|
244
|
+
data: {
|
|
245
|
+
type_ref: {
|
|
246
|
+
base: string;
|
|
247
|
+
array_dims: {
|
|
248
|
+
kind: string;
|
|
249
|
+
value: number;
|
|
250
|
+
}[];
|
|
251
|
+
};
|
|
252
|
+
values: {
|
|
253
|
+
kind: string;
|
|
254
|
+
data: number;
|
|
255
|
+
}[];
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
export declare function argByte(value: any): {
|
|
259
|
+
kind: string;
|
|
260
|
+
data: number;
|
|
261
|
+
};
|
|
262
|
+
export declare function argInt(value: any): {
|
|
263
|
+
kind: string;
|
|
264
|
+
data: number;
|
|
265
|
+
};
|
|
266
|
+
export declare function argBool(value: any): {
|
|
267
|
+
kind: string;
|
|
268
|
+
data: boolean;
|
|
269
|
+
};
|
|
270
|
+
export declare function p2pkScriptPubKey(kw: any, pubkeyHex: any): any;
|
|
271
|
+
export declare function p2shScriptHashHex(kw: any, script: any): string;
|
|
272
|
+
export declare function calculateFeeSplit(grossSompi: any, feeBps?: bigint): {
|
|
273
|
+
fee: bigint;
|
|
274
|
+
net: bigint;
|
|
275
|
+
};
|
|
276
|
+
export declare function exactGrossSompi(rawAmount: any, unitPriceSompi: any, priceScale?: bigint): bigint;
|
|
277
|
+
export declare function calculateFeeSompi(grossSompi: any, feeBps?: bigint): bigint;
|
|
278
|
+
export declare function selectFundingEntry(entries: any, requiredSompi: any, skippedOutpoints?: never[]): any;
|
|
279
|
+
export declare function requiredToccataFeeSompi(kw: any, network: any, transaction: any): bigint;
|
|
280
|
+
export declare function utxoAmountSompi(entry: any): bigint;
|
|
281
|
+
export declare function findOutputIndex(tx: any, address: any, networkId: any, addressFromScriptPublicKey: any): number;
|
|
282
|
+
export declare function setVersionOneInputMassFields(tx: any, computeBudget?: number): void;
|
|
283
|
+
export declare function extractLockedOutput(lockReceipt: any, saleCovenantId: any, tokenAmount: any): {
|
|
284
|
+
txid: any;
|
|
285
|
+
vout: number;
|
|
286
|
+
tokenAmount: bigint;
|
|
287
|
+
};
|
|
288
|
+
//# sourceMappingURL=sale-common.d.ts.map
|