@ickb/sdk 1000.0.26 → 1000.0.43
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/cjs/index.d.ts +35 -37
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +139 -172
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +35 -37
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +142 -175
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +204 -276
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { ccc
|
|
2
|
-
import { SmartTransaction, type ScriptDeps, type UdtCell, type CapacityCell } from "@ickb/utils";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { SmartTransaction, type ScriptDeps, type UdtCell, type CapacityCell, type ExchangeRatio } from "@ickb/utils";
|
|
3
|
+
import { IckbUdtManager, LogicManager, OwnedOwnerManager, type IckbDepositCell, type ReceiptCell, type WithdrawalGroup } from "@ickb/core";
|
|
4
|
+
import { DaoManager, type DaoCell } from "@ickb/dao";
|
|
5
|
+
import { OrderManager, type OrderCell, type OrderGroup } from "@ickb/order";
|
|
5
6
|
export declare class IckbController {
|
|
6
|
-
|
|
7
|
-
logicManager: LogicManager;
|
|
8
|
-
ownedOwnerManager: OwnedOwnerManager;
|
|
9
|
-
orderManager: OrderManager;
|
|
10
|
-
|
|
7
|
+
readonly ickbUdtManager: IckbUdtManager;
|
|
8
|
+
readonly logicManager: LogicManager;
|
|
9
|
+
readonly ownedOwnerManager: OwnedOwnerManager;
|
|
10
|
+
readonly orderManager: OrderManager;
|
|
11
|
+
readonly daoManager: DaoManager;
|
|
12
|
+
constructor(ickbUdtManager: IckbUdtManager, logicManager: LogicManager, ownedOwnerManager: OwnedOwnerManager, orderManager: OrderManager, daoManager: DaoManager);
|
|
11
13
|
static fromDeps({ xudt, dao, ickbLogic, ownedOwner, order, }: {
|
|
12
14
|
xudt: ScriptDeps;
|
|
13
15
|
dao: ScriptDeps;
|
|
@@ -15,42 +17,36 @@ export declare class IckbController {
|
|
|
15
17
|
ownedOwner: ScriptDeps;
|
|
16
18
|
order: ScriptDeps;
|
|
17
19
|
}): IckbController;
|
|
18
|
-
previewConversion(
|
|
19
|
-
ratio: Ratio;
|
|
20
|
-
} | {
|
|
21
|
-
tip: ccc.ClientBlockHeader;
|
|
22
|
-
}) & {
|
|
23
|
-
fee?: {
|
|
24
|
-
numerator: ccc.Num;
|
|
25
|
-
denominator: ccc.Num;
|
|
26
|
-
};
|
|
27
|
-
}): ccc.FixedPoint;
|
|
28
|
-
convert(options: {
|
|
29
|
-
signer: ccc.Signer;
|
|
20
|
+
static previewConversion(conversion: {
|
|
30
21
|
isCkb2Udt: boolean;
|
|
31
22
|
amount: ccc.FixedPoint;
|
|
23
|
+
rate: ExchangeRatio | ccc.ClientBlockHeader;
|
|
24
|
+
fee: ccc.Num;
|
|
25
|
+
}): {
|
|
26
|
+
rate: ExchangeRatio;
|
|
27
|
+
convertedAmount: ccc.FixedPoint;
|
|
28
|
+
};
|
|
29
|
+
convert(options: {
|
|
30
|
+
conversion: Parameters<typeof IckbController.previewConversion>[0] & {
|
|
31
|
+
ckbMinMatchLog?: number;
|
|
32
|
+
ckbMinFee?: ccc.Num;
|
|
33
|
+
};
|
|
34
|
+
signer: ccc.Signer;
|
|
32
35
|
userCells: UserCells;
|
|
33
|
-
minCkbChange: ccc.FixedPoint;
|
|
34
36
|
system: SystemState;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
denominator: ccc.Num;
|
|
37
|
+
filters: {
|
|
38
|
+
isReadyOnly: boolean;
|
|
39
|
+
isFulfilledOnly: boolean;
|
|
39
40
|
};
|
|
40
41
|
}): Promise<Conversion | undefined>;
|
|
41
|
-
private
|
|
42
|
-
getL1State(client: ccc.Client, locks: ccc.
|
|
42
|
+
private attempt;
|
|
43
|
+
getL1State(client: ccc.Client, filter: Set<keyof UserCells | "depositPool">, locks: ccc.Script[], options?: {
|
|
43
44
|
minLockUp?: ccc.Epoch;
|
|
44
45
|
maxLockUp?: ccc.Epoch;
|
|
45
46
|
}): Promise<{
|
|
46
47
|
system: SystemState;
|
|
47
48
|
user: UserCells;
|
|
48
49
|
}>;
|
|
49
|
-
static getBalance({ capacities, udts, receipts, withdrawalGroups, orders, }: UserCells): Balance;
|
|
50
|
-
}
|
|
51
|
-
export interface Balance {
|
|
52
|
-
ckb: ccc.FixedPoint;
|
|
53
|
-
udt: ccc.FixedPoint;
|
|
54
50
|
}
|
|
55
51
|
export interface SystemState {
|
|
56
52
|
feeRate: ccc.Num;
|
|
@@ -61,21 +57,23 @@ export interface SystemState {
|
|
|
61
57
|
};
|
|
62
58
|
ckbDepositCap: ccc.FixedPoint;
|
|
63
59
|
udtDepositCap: ccc.FixedPoint;
|
|
64
|
-
|
|
60
|
+
depositPool: (IckbDepositCell & {
|
|
65
61
|
udtCumulative: bigint;
|
|
66
62
|
})[];
|
|
67
|
-
|
|
63
|
+
orderPool: OrderCell[];
|
|
68
64
|
}
|
|
69
65
|
export interface UserCells {
|
|
70
66
|
capacities: CapacityCell[];
|
|
71
67
|
udts: UdtCell[];
|
|
72
68
|
receipts: ReceiptCell[];
|
|
73
|
-
withdrawalGroups:
|
|
69
|
+
withdrawalGroups: WithdrawalGroup[];
|
|
74
70
|
orders: OrderGroup[];
|
|
71
|
+
deposits: DaoCell[];
|
|
72
|
+
withdrawalRequests: DaoCell[];
|
|
75
73
|
}
|
|
76
74
|
export interface Conversion {
|
|
77
75
|
tx: SmartTransaction;
|
|
78
76
|
ckbFee: ccc.FixedPoint;
|
|
79
|
-
maturity: Epoch;
|
|
77
|
+
maturity: ccc.Epoch;
|
|
80
78
|
}
|
|
81
79
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAIL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,YAAY,EAIjB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAEL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAErB,qBAAa,cAAc;aAEP,cAAc,EAAE,cAAc;aAC9B,YAAY,EAAE,YAAY;aAC1B,iBAAiB,EAAE,iBAAiB;aACpC,YAAY,EAAE,YAAY;aAC1B,UAAU,EAAE,UAAU;gBAJtB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU;IAGxC,MAAM,CAAC,QAAQ,CAAC,EACd,IAAI,EACJ,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,GACN,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,GAAG,EAAE,UAAU,CAAC;QAChB,SAAS,EAAE,UAAU,CAAC;QACtB,UAAU,EAAE,UAAU,CAAC;QACvB,KAAK,EAAE,UAAU,CAAC;KACnB,GAAG,cAAc;IAkClB,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE;QAC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,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;QAClB,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;KACnB,CAAC;IACF,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC;IAC9B,WAAW,EAAE,CAAC,eAAe,GAAG;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAC7D,SAAS,EAAE,SAAS,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,kBAAkB,EAAE,OAAO,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,gBAAgB,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC;CACrB"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -7,11 +7,12 @@ const core_2 = require("@ickb/core");
|
|
|
7
7
|
const dao_1 = require("@ickb/dao");
|
|
8
8
|
const order_1 = require("@ickb/order");
|
|
9
9
|
class IckbController {
|
|
10
|
-
constructor(
|
|
11
|
-
this.
|
|
10
|
+
constructor(ickbUdtManager, logicManager, ownedOwnerManager, orderManager, daoManager) {
|
|
11
|
+
this.ickbUdtManager = ickbUdtManager;
|
|
12
12
|
this.logicManager = logicManager;
|
|
13
13
|
this.ownedOwnerManager = ownedOwnerManager;
|
|
14
14
|
this.orderManager = orderManager;
|
|
15
|
+
this.daoManager = daoManager;
|
|
15
16
|
}
|
|
16
17
|
static fromDeps({ xudt, dao, ickbLogic, ownedOwner, order, }) {
|
|
17
18
|
const daoManager = dao_1.DaoManager.fromDeps(dao);
|
|
@@ -20,127 +21,162 @@ class IckbController {
|
|
|
20
21
|
script: new core_1.ccc.Script(codeHash, hashType, [ickbLogic.script.hash(), "00000080"].join("")),
|
|
21
22
|
cellDeps,
|
|
22
23
|
};
|
|
23
|
-
const
|
|
24
|
-
return new IckbController(
|
|
24
|
+
const ickbUdtManager = core_2.IckbUdtManager.fromDeps(ickbXudt, daoManager);
|
|
25
|
+
return new IckbController(ickbUdtManager, core_2.LogicManager.fromDeps(ickbLogic, daoManager, ickbUdtManager), core_2.OwnedOwnerManager.fromDeps(ownedOwner, daoManager, ickbUdtManager), order_1.OrderManager.fromDeps(order, ickbUdtManager), daoManager);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
// fee examples:
|
|
28
|
+
// 100000n => 0.001%
|
|
29
|
+
// 10000n => 0.01%
|
|
30
|
+
// 1000n => 0.1%
|
|
31
|
+
// 100n => 1%
|
|
32
|
+
// 10n => 10%
|
|
33
|
+
// 1n => 100%
|
|
34
|
+
// less than 1n => 0%
|
|
35
|
+
static previewConversion(conversion) {
|
|
36
|
+
const { isCkb2Udt, amount, fee } = conversion;
|
|
37
|
+
let rate = conversion.rate;
|
|
38
|
+
rate = "dao" in rate ? (0, core_2.ickbExchangeRatio)(rate) : rate;
|
|
39
|
+
if (fee > core_1.ccc.Zero) {
|
|
40
|
+
const { ckbScale, udtScale } = rate;
|
|
41
|
+
rate = {
|
|
42
|
+
ckbScale,
|
|
43
|
+
// Worst case scenario where fee applies to the full amount
|
|
44
|
+
udtScale: udtScale + (isCkb2Udt ? 1n : -1n) * (udtScale / fee),
|
|
45
|
+
};
|
|
35
46
|
}
|
|
36
|
-
|
|
47
|
+
const convertedAmount = amount > core_1.ccc.Zero ? (0, core_2.convert)(isCkb2Udt, amount, rate) : core_1.ccc.Zero;
|
|
48
|
+
return { rate, convertedAmount };
|
|
37
49
|
}
|
|
38
|
-
// TODO streamline parameters with previewConversion
|
|
39
50
|
async convert(options) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
51
|
+
// Get user lock
|
|
52
|
+
const { system, signer } = options;
|
|
53
|
+
const lock = (await signer.getRecommendedAddressObj()).script;
|
|
54
|
+
// Normalize rate
|
|
55
|
+
const { rate } = IckbController.previewConversion({
|
|
56
|
+
...options.conversion,
|
|
57
|
+
amount: core_1.ccc.Zero,
|
|
58
|
+
});
|
|
59
|
+
const { isCkb2Udt, amount, ckbMinMatchLog } = options.conversion;
|
|
60
|
+
const info = order_1.Info.create(isCkb2Udt, rate, ckbMinMatchLog);
|
|
61
|
+
// feeRate is a good approximation of the bot tx size matching the order
|
|
62
|
+
const ckbMinFee = options.conversion.ckbMinFee ?? 10n * system.feeRate;
|
|
63
|
+
const conversion = {
|
|
64
|
+
isCkb2Udt,
|
|
65
|
+
amount,
|
|
66
|
+
rate,
|
|
67
|
+
info,
|
|
68
|
+
ckbMinFee,
|
|
69
|
+
lock,
|
|
70
|
+
};
|
|
45
71
|
const N = isCkb2Udt
|
|
46
72
|
? Number(amount / system.ckbDepositCap)
|
|
47
|
-
: system.
|
|
73
|
+
: system.depositPool.slice(0, 30).length;
|
|
48
74
|
const cache = Array(N);
|
|
49
|
-
const
|
|
75
|
+
const cachedAttempt = (n) => {
|
|
50
76
|
n = N - n;
|
|
51
|
-
return (cache[n] =
|
|
52
|
-
cache[n] ?? this.attemptConversion(n, info, address, options));
|
|
77
|
+
return (cache[n] = cache[n] ?? this.attempt(n, conversion, options));
|
|
53
78
|
};
|
|
54
|
-
return
|
|
79
|
+
return cachedAttempt(await (0, utils_1.asyncBinarySearch)(N, async (n) => (await cachedAttempt(n)) !== undefined));
|
|
55
80
|
}
|
|
56
|
-
async
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
async attempt(n, conversion, options) {
|
|
82
|
+
try {
|
|
83
|
+
const { isCkb2Udt, rate, info, ckbMinFee, lock } = conversion;
|
|
84
|
+
const { signer, userCells, system, filters } = options;
|
|
85
|
+
const { feeRate, depositPool, ckbDepositCap, exchangeRatio } = system;
|
|
86
|
+
const tx = utils_1.SmartTransaction.default();
|
|
87
|
+
const maturities = [];
|
|
88
|
+
let ckbFee = core_1.ccc.Zero;
|
|
89
|
+
let amount = conversion.amount;
|
|
90
|
+
// Core protocol
|
|
91
|
+
if (n > 0) {
|
|
92
|
+
if (isCkb2Udt) {
|
|
93
|
+
amount -= ckbDepositCap * BigInt(n);
|
|
94
|
+
if (amount < core_1.ccc.Zero) {
|
|
95
|
+
// Too many Deposits respectfully to the amount
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
this.logicManager.deposit(tx, n, ckbDepositCap, lock);
|
|
66
99
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
else {
|
|
101
|
+
const myDeposits = depositPool.slice(0, n);
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
+
amount -= myDeposits.slice(-1)[0].udtCumulative;
|
|
104
|
+
if (amount < core_1.ccc.Zero) {
|
|
105
|
+
// Too many Withdrawal Requests respectfully to the amount
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
this.ownedOwnerManager.requestWithdrawal(tx, myDeposits, lock);
|
|
109
|
+
maturities.push(...myDeposits.map((d) => d.maturity));
|
|
76
110
|
}
|
|
77
|
-
this.ownedOwnerManager.requestWithdrawal(tx, myDeposits, address.script);
|
|
78
|
-
maturities.push(...myDeposits.map((d) => d.maturity));
|
|
79
111
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
const { receipts, withdrawalGroups, orders, udts, capacities } = userCells;
|
|
98
|
-
this.logicManager.completeDeposit(tx, receipts);
|
|
99
|
-
this.ownedOwnerManager.withdraw(tx, withdrawalGroups); //TODO: ignore not isReady cells in method!!!
|
|
100
|
-
for (const order of orders) {
|
|
101
|
-
this.orderManager.melt(tx, order); //TODO: allow melting multiple groups and give choices!!!
|
|
102
|
-
}
|
|
103
|
-
// const outputLen = tx.inputs.length;??
|
|
104
|
-
// Give choice that let user add this cells the way he prefer!! (Either here or at completeFeeBy)
|
|
105
|
-
this.ickbManager.addUdts(tx, udts);
|
|
106
|
-
utils_1.CapacityManager.addCapacities(tx, capacities);
|
|
107
|
-
const outputLen = tx.outputs.length;
|
|
108
|
-
try {
|
|
109
|
-
await tx.completeFeeBy(signer, feeRate);
|
|
110
|
-
// TODO: check in SmartTransaction for 64 output cells in DAO transactions
|
|
111
|
-
if (tx.outputs.length > 64) {
|
|
112
|
+
// Order protocol
|
|
113
|
+
if (amount > core_1.ccc.Zero) {
|
|
114
|
+
this.orderManager.mint(tx, lock, info, {
|
|
115
|
+
ckbValue: isCkb2Udt ? amount : core_1.ccc.Zero,
|
|
116
|
+
udtValue: isCkb2Udt ? core_1.ccc.Zero : amount,
|
|
117
|
+
});
|
|
118
|
+
const convertedAmount = (0, core_2.convert)(isCkb2Udt, amount, rate);
|
|
119
|
+
ckbFee = isCkb2Udt
|
|
120
|
+
? amount - (0, core_2.convert)(false, convertedAmount, exchangeRatio)
|
|
121
|
+
: (0, core_2.convert)(true, amount, exchangeRatio) - convertedAmount;
|
|
122
|
+
maturities.push(
|
|
123
|
+
// TODO: use real world data from deposits, open orders and bot balances
|
|
124
|
+
orderMaturityEstimate(isCkb2Udt, amount, system.tip));
|
|
125
|
+
}
|
|
126
|
+
// Check that order provides enough fee to the bot for being matched
|
|
127
|
+
if (ckbFee < ckbMinFee) {
|
|
112
128
|
return undefined;
|
|
113
129
|
}
|
|
130
|
+
const { receipts, withdrawalGroups, orders, udts, capacities } = userCells;
|
|
131
|
+
this.logicManager.completeDeposit(tx, receipts);
|
|
132
|
+
this.ownedOwnerManager.withdraw(tx, withdrawalGroups, filters);
|
|
133
|
+
this.orderManager.melt(tx, orders, filters);
|
|
134
|
+
this.ickbUdtManager.addUdts(tx, udts);
|
|
135
|
+
utils_1.CapacityManager.addCapacities(tx, capacities);
|
|
136
|
+
// Throw an error if inputs do not cover for outputs
|
|
137
|
+
await new utils_1.RestrictedTransaction(tx).completeFeeBy(signer, feeRate);
|
|
138
|
+
// Find the maturity most distant in the future
|
|
139
|
+
const maturity = maturities.reduce((a, b) => (0, utils_1.epochCompare)(a, b) === -1 ? b : a);
|
|
140
|
+
return {
|
|
141
|
+
tx,
|
|
142
|
+
ckbFee,
|
|
143
|
+
maturity,
|
|
144
|
+
};
|
|
114
145
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
115
146
|
}
|
|
116
147
|
catch (_) {
|
|
117
148
|
return undefined;
|
|
118
149
|
}
|
|
119
|
-
// Revert any change cells
|
|
120
|
-
tx.outputs = tx.outputs.slice(outputLen);
|
|
121
|
-
tx = utils_1.SmartTransaction.from(tx);
|
|
122
|
-
const maturity = maturities.reduce((a, b) => (0, utils_1.epochCompare)(a, b) === -1 ? b : a);
|
|
123
|
-
return {
|
|
124
|
-
tx,
|
|
125
|
-
ckbFee,
|
|
126
|
-
maturity,
|
|
127
|
-
};
|
|
128
150
|
}
|
|
129
|
-
|
|
130
|
-
async getL1State(client, locks, options) {
|
|
151
|
+
async getL1State(client, filter, locks, options) {
|
|
131
152
|
const tip = await client.getTipHeader();
|
|
132
153
|
const onChain = true;
|
|
133
154
|
const opts = { ...options, tip, onChain };
|
|
134
|
-
const [feeRate, depositPool, capacities, udts, receipts, withdrawalGroups, orders,] = await Promise.all([
|
|
135
|
-
// TODO: fetch user NervosDAO cells
|
|
136
|
-
// TODO: fetch bot cells for estimating timings
|
|
155
|
+
const [feeRate, depositPool, capacities, udts, receipts, withdrawalGroups, orders, deposits, withdrawalRequests,] = await Promise.all([
|
|
137
156
|
client.getFeeRate(),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
filter.has("depositPool")
|
|
158
|
+
? (0, utils_1.collect)(this.logicManager.findDeposits(client, opts))
|
|
159
|
+
: [],
|
|
160
|
+
filter.has("capacities")
|
|
161
|
+
? (0, utils_1.collect)(utils_1.CapacityManager.findCapacities(client, locks, opts))
|
|
162
|
+
: [],
|
|
163
|
+
filter.has("udts")
|
|
164
|
+
? (0, utils_1.collect)(this.ickbUdtManager.findUdts(client, locks, opts))
|
|
165
|
+
: [],
|
|
166
|
+
filter.has("receipts")
|
|
167
|
+
? (0, utils_1.collect)(this.logicManager.findReceipts(client, locks, opts))
|
|
168
|
+
: [],
|
|
169
|
+
filter.has("withdrawalGroups")
|
|
170
|
+
? (0, utils_1.collect)(this.ownedOwnerManager.findWithdrawalGroups(client, locks, opts))
|
|
171
|
+
: [],
|
|
172
|
+
filter.has("orders") ? (0, utils_1.collect)(this.orderManager.findOrders(client)) : [],
|
|
173
|
+
filter.has("deposits")
|
|
174
|
+
? (0, utils_1.collect)(this.daoManager.findDeposits(client, locks, opts))
|
|
175
|
+
: [],
|
|
176
|
+
filter.has("withdrawalRequests")
|
|
177
|
+
? (0, utils_1.collect)(this.daoManager.findWithdrawalRequests(client, locks, opts))
|
|
178
|
+
: [],
|
|
179
|
+
// TODO: fetch bot cells for estimating timings
|
|
144
180
|
]);
|
|
145
181
|
// Sort depositPool by maturity
|
|
146
182
|
depositPool.sort((a, b) => (0, utils_1.epochCompare)(a.maturity, b.maturity));
|
|
@@ -162,7 +198,7 @@ class IckbController {
|
|
|
162
198
|
}
|
|
163
199
|
}
|
|
164
200
|
const exchangeRatio = (0, core_2.ickbExchangeRatio)(tip);
|
|
165
|
-
const ckbDepositCap = (0, core_2.convert)(false, core_2.ICKB_DEPOSIT_CAP, exchangeRatio);
|
|
201
|
+
const ckbDepositCap = (0, core_2.convert)(false, core_2.ICKB_DEPOSIT_CAP, exchangeRatio);
|
|
166
202
|
return {
|
|
167
203
|
system: {
|
|
168
204
|
feeRate,
|
|
@@ -170,8 +206,8 @@ class IckbController {
|
|
|
170
206
|
exchangeRatio,
|
|
171
207
|
ckbDepositCap,
|
|
172
208
|
udtDepositCap: core_2.ICKB_DEPOSIT_CAP,
|
|
173
|
-
|
|
174
|
-
|
|
209
|
+
depositPool: cumulativeDepositPool,
|
|
210
|
+
orderPool: nonUserOrders,
|
|
175
211
|
},
|
|
176
212
|
user: {
|
|
177
213
|
capacities,
|
|
@@ -179,33 +215,11 @@ class IckbController {
|
|
|
179
215
|
receipts,
|
|
180
216
|
withdrawalGroups,
|
|
181
217
|
orders: userOrders,
|
|
218
|
+
deposits,
|
|
219
|
+
withdrawalRequests,
|
|
182
220
|
},
|
|
183
221
|
};
|
|
184
222
|
}
|
|
185
|
-
// TODO: Allow filtering which cells are accounted for
|
|
186
|
-
static getBalance({ capacities, udts, receipts, withdrawalGroups, orders, }) {
|
|
187
|
-
const cells = [
|
|
188
|
-
capacities,
|
|
189
|
-
udts,
|
|
190
|
-
receipts,
|
|
191
|
-
].flat();
|
|
192
|
-
for (const { owner, owned } of withdrawalGroups) {
|
|
193
|
-
cells.push(owned, owner);
|
|
194
|
-
}
|
|
195
|
-
for (const { master, order } of orders) {
|
|
196
|
-
cells.push(master, order);
|
|
197
|
-
}
|
|
198
|
-
let ckb = core_1.ccc.Zero;
|
|
199
|
-
let udt = core_1.ccc.Zero;
|
|
200
|
-
for (const cell of cells) {
|
|
201
|
-
ckb += cell.cell.cellOutput.capacity;
|
|
202
|
-
udt += cell.udtValue ?? core_1.ccc.Zero;
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
ckb,
|
|
206
|
-
udt,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
223
|
}
|
|
210
224
|
exports.IckbController = IckbController;
|
|
211
225
|
// Estimate bot ability to fulfill orders:
|
|
@@ -218,51 +232,4 @@ function orderMaturityEstimate(isCkb2Udt, amount, tip) {
|
|
|
218
232
|
4n * 60n,
|
|
219
233
|
]);
|
|
220
234
|
}
|
|
221
|
-
class OfflineTransaction extends utils_1.SmartTransaction {
|
|
222
|
-
clone() {
|
|
223
|
-
const result = super.clone();
|
|
224
|
-
// Keep inputs metadata when cloning, so it will not refetch that data
|
|
225
|
-
result.inputs = [...this.inputs];
|
|
226
|
-
return new OfflineTransaction(result);
|
|
227
|
-
}
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
229
|
-
async completeInputs(_0, _1, _2, init) {
|
|
230
|
-
// Disable completeInputs, so it will not fetch additional cells
|
|
231
|
-
return {
|
|
232
|
-
addedCount: 0,
|
|
233
|
-
accumulated: init,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
// Reimplement the rest of transformations
|
|
237
|
-
constructor(tx) {
|
|
238
|
-
super(tx.version, tx.cellDeps, tx.headerDeps, tx.inputs, tx.outputs, tx.outputsData, tx.witnesses, tx.udtHandlers, tx.headers);
|
|
239
|
-
}
|
|
240
|
-
static default() {
|
|
241
|
-
return new OfflineTransaction(super.default());
|
|
242
|
-
}
|
|
243
|
-
static fromLumosSkeleton(skeleton) {
|
|
244
|
-
return new OfflineTransaction(super.fromLumosSkeleton(skeleton));
|
|
245
|
-
}
|
|
246
|
-
static from(txLike) {
|
|
247
|
-
return new OfflineTransaction(utils_1.SmartTransaction.from(txLike));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
// TODO: utils.binarySearch is sync, need an async one for await the result!!!!!!!!!!!!
|
|
251
|
-
async function asyncBinarySearch(n, f) {
|
|
252
|
-
// Define f(-1) == false and f(n) == true.
|
|
253
|
-
// Invariant: f(i-1) == false, f(j) == true.
|
|
254
|
-
let [i, j] = [0, n];
|
|
255
|
-
while (i < j) {
|
|
256
|
-
const h = Math.trunc((i + j) / 2);
|
|
257
|
-
// i ≤ h < j
|
|
258
|
-
if (!(await f(h))) {
|
|
259
|
-
i = h + 1; // preserves f(i-1) == false
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
j = h; // preserves f(j) == true
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
// i == j, f(i-1) == false, and f(j) (= f(i)) == true => answer is i.
|
|
266
|
-
return i;
|
|
267
|
-
}
|
|
268
235
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,wCAAoC;AACpC,uCAYqB;AACrB,qCAUoB;AACpB,mCAAqD;AACrD,uCAKqB;AAErB,MAAa,cAAc;IACzB,YACkB,cAA8B,EAC9B,YAA0B,EAC1B,iBAAoC,EACpC,YAA0B,EAC1B,UAAsB;QAJtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAY;IACrC,CAAC;IAEJ,MAAM,CAAC,QAAQ,CAAC,EACd,IAAI,EACJ,GAAG,EACH,SAAS,EACT,UAAU,EACV,KAAK,GAON;QACC,MAAM,UAAU,GAAG,gBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE5C,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EA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