@affluent-org/sdk 0.0.1
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/.prettierrc +11 -0
- package/Refactoring.md +548 -0
- package/dist/_compiled/Account.compiled.json +1 -0
- package/dist/_compiled/Receipt.compiled.json +1 -0
- package/dist/_compiled/WTONWallet.compiled.json +1 -0
- package/dist/_compiled/index.d.ts +4 -0
- package/dist/_compiled/index.js +12 -0
- package/dist/affluent.d.ts +14 -0
- package/dist/affluent.js +20 -0
- package/dist/constants/constants.d.ts +2 -0
- package/dist/constants/constants.js +5 -0
- package/dist/constants/contracts.d.ts +9 -0
- package/dist/constants/contracts.js +18 -0
- package/dist/context.d.ts +43 -0
- package/dist/context.js +90 -0
- package/dist/contracts/common/type.d.ts +16 -0
- package/dist/contracts/common/type.js +2 -0
- package/dist/contracts/common/utils.d.ts +3 -0
- package/dist/contracts/common/utils.js +16 -0
- package/dist/contracts/core/account/index.d.ts +38 -0
- package/dist/contracts/core/account/index.js +128 -0
- package/dist/contracts/core/account/type.d.ts +18 -0
- package/dist/contracts/core/account/type.js +2 -0
- package/dist/contracts/core/pool/index.d.ts +149 -0
- package/dist/contracts/core/pool/index.js +379 -0
- package/dist/contracts/core/pool/serializer.d.ts +15 -0
- package/dist/contracts/core/pool/serializer.js +307 -0
- package/dist/contracts/core/pool/type.d.ts +136 -0
- package/dist/contracts/core/pool/type.js +2 -0
- package/dist/contracts/dedust-farm/MockDedustFarm.d.ts +41 -0
- package/dist/contracts/dedust-farm/MockDedustFarm.js +79 -0
- package/dist/contracts/external/tonstaker.d.ts +18 -0
- package/dist/contracts/external/tonstaker.js +26 -0
- package/dist/contracts/factory/factory.d.ts +24 -0
- package/dist/contracts/factory/factory.js +58 -0
- package/dist/contracts/factory/type.d.ts +11 -0
- package/dist/contracts/factory/type.js +2 -0
- package/dist/contracts/farm/distributor.d.ts +43 -0
- package/dist/contracts/farm/distributor.js +83 -0
- package/dist/contracts/farm/receipt.d.ts +40 -0
- package/dist/contracts/farm/receipt.js +68 -0
- package/dist/contracts/irm/jump-irm/serializer.d.ts +4 -0
- package/dist/contracts/irm/jump-irm/serializer.js +26 -0
- package/dist/contracts/irm/jump-irm/type.d.ts +8 -0
- package/dist/contracts/irm/jump-irm/type.js +2 -0
- package/dist/contracts/jetton/jetton-minter.d.ts +23 -0
- package/dist/contracts/jetton/jetton-minter.js +46 -0
- package/dist/contracts/jetton/jetton-wallet.d.ts +67 -0
- package/dist/contracts/jetton/jetton-wallet.js +119 -0
- package/dist/contracts/jetton/type.d.ts +7 -0
- package/dist/contracts/jetton/type.js +2 -0
- package/dist/contracts/liquid_token/dedust/minter.d.ts +56 -0
- package/dist/contracts/liquid_token/dedust/minter.js +112 -0
- package/dist/contracts/liquid_token/dedust/wallet.d.ts +127 -0
- package/dist/contracts/liquid_token/dedust/wallet.js +213 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonMinter.d.ts +53 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonMinter.js +110 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonWallet.d.ts +169 -0
- package/dist/contracts/liquid_token/stonfi/LFStonfiJettonWallet.js +288 -0
- package/dist/contracts/oracle/composite-onchain-oracle/index.d.ts +108 -0
- package/dist/contracts/oracle/composite-onchain-oracle/index.js +185 -0
- package/dist/contracts/oracle/parser.d.ts +7 -0
- package/dist/contracts/oracle/parser.js +77 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/index.d.ts +56 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/index.js +159 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/serializer.d.ts +4 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/serializer.js +137 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/type.d.ts +57 -0
- package/dist/contracts/oracle/redstone-onchain-oracle/type.js +18 -0
- package/dist/contracts/oracle/redstone-oracle/serializer.d.ts +3 -0
- package/dist/contracts/oracle/redstone-oracle/serializer.js +30 -0
- package/dist/contracts/oracle/redstone-oracle/type.d.ts +9 -0
- package/dist/contracts/oracle/redstone-oracle/type.js +2 -0
- package/dist/contracts/oracle/redstone-parser.d.ts +9 -0
- package/dist/contracts/oracle/redstone-parser.js +58 -0
- package/dist/contracts/rfq/rfq_auction/index.d.ts +216 -0
- package/dist/contracts/rfq/rfq_auction/index.js +334 -0
- package/dist/contracts/rfq/rfq_batch/index.d.ts +346 -0
- package/dist/contracts/rfq/rfq_batch/index.js +448 -0
- package/dist/contracts/rfq/rfq_event_emitter/index.d.ts +132 -0
- package/dist/contracts/rfq/rfq_event_emitter/index.js +143 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmItem.d.ts +41 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmItem.js +83 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmMinter.d.ts +45 -0
- package/dist/contracts/stonfi-farm/MockStonfiFarmMinter.js +92 -0
- package/dist/contracts/unknown-contract/index.d.ts +14 -0
- package/dist/contracts/unknown-contract/index.js +18 -0
- package/dist/contracts/vault/share-vault/index.d.ts +206 -0
- package/dist/contracts/vault/share-vault/index.js +373 -0
- package/dist/contracts/vault/strategy-vault/codec.d.ts +710 -0
- package/dist/contracts/vault/strategy-vault/codec.js +1256 -0
- package/dist/contracts/vault/strategy-vault/computation.d.ts +11 -0
- package/dist/contracts/vault/strategy-vault/computation.js +56 -0
- package/dist/contracts/vault/strategy-vault/constants.d.ts +163 -0
- package/dist/contracts/vault/strategy-vault/constants.js +170 -0
- package/dist/contracts/vault/strategy-vault/index.d.ts +587 -0
- package/dist/contracts/vault/strategy-vault/index.js +406 -0
- package/dist/contracts/vault/strategy-vault/type.d.ts +115 -0
- package/dist/contracts/vault/strategy-vault/type.js +2 -0
- package/dist/contracts/wton/jetton-minter.d.ts +35 -0
- package/dist/contracts/wton/jetton-minter.js +71 -0
- package/dist/contracts/wton/jetton-wallet.d.ts +90 -0
- package/dist/contracts/wton/jetton-wallet.js +153 -0
- package/dist/contracts/wton/type.d.ts +7 -0
- package/dist/contracts/wton/type.js +2 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +65 -0
- package/dist/lib/assert.d.ts +1 -0
- package/dist/lib/assert.js +9 -0
- package/dist/lib/query-cache.d.ts +5 -0
- package/dist/lib/query-cache.js +57 -0
- package/dist/lib/send-msg.d.ts +11 -0
- package/dist/lib/send-msg.js +9 -0
- package/dist/services/composite-oracle/computation.d.ts +55 -0
- package/dist/services/composite-oracle/computation.js +295 -0
- package/dist/services/composite-oracle/index.d.ts +45 -0
- package/dist/services/composite-oracle/index.js +110 -0
- package/dist/services/composite-oracle/query.d.ts +36 -0
- package/dist/services/composite-oracle/query.js +251 -0
- package/dist/services/composite-oracle/types.d.ts +82 -0
- package/dist/services/composite-oracle/types.js +11 -0
- package/dist/services/pool/computation.d.ts +75 -0
- package/dist/services/pool/computation.js +219 -0
- package/dist/services/pool/index.d.ts +94 -0
- package/dist/services/pool/index.js +139 -0
- package/dist/services/pool/oracle.d.ts +20 -0
- package/dist/services/pool/oracle.js +61 -0
- package/dist/services/pool/owner/index.d.ts +37 -0
- package/dist/services/pool/owner/index.js +76 -0
- package/dist/services/pool/owner/types.d.ts +18 -0
- package/dist/services/pool/owner/types.js +2 -0
- package/dist/services/pool/query.d.ts +64 -0
- package/dist/services/pool/query.js +282 -0
- package/dist/services/pool/user/index.d.ts +86 -0
- package/dist/services/pool/user/index.js +285 -0
- package/dist/services/pool/user/types.d.ts +44 -0
- package/dist/services/pool/user/types.js +2 -0
- package/dist/services/rfq-auction/index.d.ts +81 -0
- package/dist/services/rfq-auction/index.js +93 -0
- package/dist/services/rfq-auction/oracle.d.ts +19 -0
- package/dist/services/rfq-auction/oracle.js +60 -0
- package/dist/services/rfq-auction/query.d.ts +50 -0
- package/dist/services/rfq-auction/query.js +19 -0
- package/dist/services/rfq-auction/user/index.d.ts +63 -0
- package/dist/services/rfq-auction/user/index.js +218 -0
- package/dist/services/rfq-auction/user/types.d.ts +29 -0
- package/dist/services/rfq-auction/user/types.js +2 -0
- package/dist/services/rfq-batch/index.d.ts +78 -0
- package/dist/services/rfq-batch/index.js +132 -0
- package/dist/services/rfq-batch/oracle.d.ts +22 -0
- package/dist/services/rfq-batch/oracle.js +54 -0
- package/dist/services/rfq-batch/query.d.ts +46 -0
- package/dist/services/rfq-batch/query.js +34 -0
- package/dist/services/rfq-batch/user/index.d.ts +79 -0
- package/dist/services/rfq-batch/user/index.js +171 -0
- package/dist/services/rfq-batch/user/types.d.ts +37 -0
- package/dist/services/rfq-batch/user/types.js +2 -0
- package/dist/services/share-vault/computation.d.ts +24 -0
- package/dist/services/share-vault/computation.js +42 -0
- package/dist/services/share-vault/index.d.ts +90 -0
- package/dist/services/share-vault/index.js +128 -0
- package/dist/services/share-vault/manager/index.d.ts +40 -0
- package/dist/services/share-vault/manager/index.js +111 -0
- package/dist/services/share-vault/manager/types.d.ts +23 -0
- package/dist/services/share-vault/manager/types.js +2 -0
- package/dist/services/share-vault/owner/index.d.ts +64 -0
- package/dist/services/share-vault/owner/index.js +122 -0
- package/dist/services/share-vault/owner/types.d.ts +33 -0
- package/dist/services/share-vault/owner/types.js +2 -0
- package/dist/services/share-vault/query.d.ts +34 -0
- package/dist/services/share-vault/query.js +138 -0
- package/dist/services/share-vault/user/index.d.ts +33 -0
- package/dist/services/share-vault/user/index.js +106 -0
- package/dist/services/share-vault/user/types.d.ts +13 -0
- package/dist/services/share-vault/user/types.js +2 -0
- package/dist/services/strategy-vault/index.d.ts +2124 -0
- package/dist/services/strategy-vault/index.js +268 -0
- package/dist/services/strategy-vault/manager/index.d.ts +1968 -0
- package/dist/services/strategy-vault/manager/index.js +475 -0
- package/dist/services/strategy-vault/manager/types.d.ts +144 -0
- package/dist/services/strategy-vault/manager/types.js +2 -0
- package/dist/services/strategy-vault/oracle.d.ts +66 -0
- package/dist/services/strategy-vault/oracle.js +162 -0
- package/dist/services/strategy-vault/owner/index.d.ts +277 -0
- package/dist/services/strategy-vault/owner/index.js +333 -0
- package/dist/services/strategy-vault/owner/types.d.ts +146 -0
- package/dist/services/strategy-vault/owner/types.js +2 -0
- package/dist/services/strategy-vault/query.d.ts +138 -0
- package/dist/services/strategy-vault/query.js +59 -0
- package/dist/services/strategy-vault/user/index.d.ts +89 -0
- package/dist/services/strategy-vault/user/index.js +219 -0
- package/dist/services/strategy-vault/user/types.d.ts +46 -0
- package/dist/services/strategy-vault/user/types.js +2 -0
- package/dist/types/sender.d.ts +7 -0
- package/dist/types/sender.js +2 -0
- package/dist/utils/action-parser.d.ts +7 -0
- package/dist/utils/action-parser.js +20 -0
- package/dist/utils/external-message-hash.d.ts +45 -0
- package/dist/utils/external-message-hash.js +65 -0
- package/dist/utils/oracle/redstone/readonlyCachedRedstone.d.ts +3 -0
- package/dist/utils/oracle/redstone/readonlyCachedRedstone.js +25 -0
- package/dist/utils/oracle/redstone/redstoneHelper.d.ts +21 -0
- package/dist/utils/oracle/redstone/redstoneHelper.js +228 -0
- package/dist/utils/parser.d.ts +40 -0
- package/dist/utils/parser.js +580 -0
- package/dist/utils/pending-tracker/index.d.ts +14 -0
- package/dist/utils/pending-tracker/index.js +34 -0
- package/dist/utils/pending-tracker/trackable-sender.d.ts +16 -0
- package/dist/utils/pending-tracker/trackable-sender.js +87 -0
- package/dist/utils/pending-tracker/type.d.ts +78 -0
- package/dist/utils/pending-tracker/type.js +2 -0
- package/dist/utils/pending-tracker/v3-client.d.ts +31 -0
- package/dist/utils/pending-tracker/v3-client.js +104 -0
- package/dist/utils/risk_calculator/risk_calculator.d.ts +45 -0
- package/dist/utils/risk_calculator/risk_calculator.js +332 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +12 -0
- package/package.json +46 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AddressInput, AddressLike } from "../../../contracts/common/type";
|
|
2
|
+
export type AmountBidParams = {
|
|
3
|
+
rfqAuctionAddress: AddressInput;
|
|
4
|
+
bidAsset: AddressLike;
|
|
5
|
+
intendedBidAmount: bigint;
|
|
6
|
+
forwardTonAmount?: bigint;
|
|
7
|
+
queryId?: bigint;
|
|
8
|
+
};
|
|
9
|
+
export type SlippageBidParams = {
|
|
10
|
+
rfqAuctionAddress: AddressInput;
|
|
11
|
+
bidAsset: AddressLike;
|
|
12
|
+
slippage: number;
|
|
13
|
+
intendedBidAmount: bigint;
|
|
14
|
+
forwardTonAmount?: bigint;
|
|
15
|
+
queryId?: bigint;
|
|
16
|
+
};
|
|
17
|
+
export type CancelBidParams = {
|
|
18
|
+
rfqAuctionAddress: AddressInput;
|
|
19
|
+
queryId?: number;
|
|
20
|
+
};
|
|
21
|
+
export type SettleParams = {
|
|
22
|
+
rfqAuctionAddress: AddressInput;
|
|
23
|
+
queryId?: number;
|
|
24
|
+
};
|
|
25
|
+
export type ClearBidsParams = {
|
|
26
|
+
rfqAuctionAddress: AddressInput;
|
|
27
|
+
clearCount: number;
|
|
28
|
+
queryId?: number;
|
|
29
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AffluentContext } from "../../context";
|
|
2
|
+
import { AddressInput } from "../../contracts/common/type";
|
|
3
|
+
import { AddressSender, MultiSender } from "../../types/sender";
|
|
4
|
+
import * as query from "./query";
|
|
5
|
+
import * as oracle from "./oracle";
|
|
6
|
+
import * as user from "./user";
|
|
7
|
+
export { sendMsg } from "../../lib/send-msg";
|
|
8
|
+
export * from "./user/types";
|
|
9
|
+
export { query, oracle, user };
|
|
10
|
+
export declare class RFQBatchServiceV1 {
|
|
11
|
+
private ctx;
|
|
12
|
+
constructor(ctx?: AffluentContext);
|
|
13
|
+
getRFQBatch(rfqBatchAddress: AddressInput): import("@ton/core").OpenedContract<import("../..").RFQBatch>;
|
|
14
|
+
getRFQBatchData(rfqBatchAddress: AddressInput): Promise<{
|
|
15
|
+
index: bigint;
|
|
16
|
+
asset0Address: import("@ton/core").Address;
|
|
17
|
+
asset1Address: import("@ton/core").Address;
|
|
18
|
+
asset0TotalAmount: bigint;
|
|
19
|
+
asset1TotalAmount: bigint;
|
|
20
|
+
asset0Orders: Record<string, import("../../contracts/rfq/rfq_batch").Order>;
|
|
21
|
+
asset1Orders: Record<string, import("../../contracts/rfq/rfq_batch").Order>;
|
|
22
|
+
status: number;
|
|
23
|
+
lockedTimestamp: number;
|
|
24
|
+
lockOwner: import("@ton/core").Address | null;
|
|
25
|
+
asset0WalletAddress: import("@ton/core").Address | null;
|
|
26
|
+
asset1WalletAddress: import("@ton/core").Address | null;
|
|
27
|
+
aggregatorIndex: bigint;
|
|
28
|
+
feeRate: bigint;
|
|
29
|
+
feeManager: import("@ton/core").Address | null;
|
|
30
|
+
whitelistedSettlers: Record<string, boolean>;
|
|
31
|
+
lockPeriod: number;
|
|
32
|
+
lockCooldown: number;
|
|
33
|
+
asset0CollectedFee: bigint;
|
|
34
|
+
asset1CollectedFee: bigint;
|
|
35
|
+
orderCount: bigint;
|
|
36
|
+
orderLimit: bigint;
|
|
37
|
+
asset0MinAmount: bigint;
|
|
38
|
+
asset1MinAmount: bigint;
|
|
39
|
+
asset0MaxAmount: bigint;
|
|
40
|
+
asset1MaxAmount: bigint;
|
|
41
|
+
guardianAddress: import("@ton/core").Address | null;
|
|
42
|
+
asset0Price: bigint;
|
|
43
|
+
asset1Price: bigint;
|
|
44
|
+
oracleConfig: import("@ton/core").Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
45
|
+
}>;
|
|
46
|
+
getAssetIndex(rfqBatchAddress: AddressInput, assetAddress: AddressInput): Promise<0 | 1>;
|
|
47
|
+
getOracleParams(rfqBatchAddress: AddressInput): Promise<{
|
|
48
|
+
oracleParams: import("@ton/core").Cell;
|
|
49
|
+
bucket: oracle.OracleExposures;
|
|
50
|
+
}>;
|
|
51
|
+
sendAddOrder(sender: AddressSender, params: user.AddOrderParams, value?: bigint): Promise<{
|
|
52
|
+
recipient: import("@ton/core").Address;
|
|
53
|
+
response: import("@ton/core").Address;
|
|
54
|
+
amount: bigint;
|
|
55
|
+
forwardTonAmount: bigint;
|
|
56
|
+
forwardPayload: import("@ton/core").Cell;
|
|
57
|
+
queryId: bigint | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
sendSettle(sender: AddressSender, params: user.SettleParams, value?: bigint): Promise<{
|
|
60
|
+
recipient: import("@ton/core").Address;
|
|
61
|
+
response: import("@ton/core").Address;
|
|
62
|
+
amount: bigint;
|
|
63
|
+
forwardTonAmount: bigint;
|
|
64
|
+
forwardPayload: import("@ton/core").Cell;
|
|
65
|
+
queryId: bigint | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
sendLock(sender: AddressSender, params: user.LockParams, value?: bigint): Promise<{}>;
|
|
68
|
+
sendCancelOrder(sender: AddressSender, params: user.CancelOrderParams, value?: bigint): Promise<{
|
|
69
|
+
assetIdx: 0 | 1;
|
|
70
|
+
}>;
|
|
71
|
+
sendPayout(sender: AddressSender, params: user.PayoutParams, value?: bigint): Promise<{
|
|
72
|
+
assetIdx: 0 | 1;
|
|
73
|
+
count: number;
|
|
74
|
+
}>;
|
|
75
|
+
sendReopen(sender: AddressSender, params: user.ReopenParams, value?: bigint): Promise<{}>;
|
|
76
|
+
sendCollectFee(sender: AddressSender, params: user.CollectFeeParams, value?: bigint): Promise<{}>;
|
|
77
|
+
sendBatchPayout(sender: MultiSender, params: user.BatchPayoutParams, value?: bigint): Promise<void>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.RFQBatchServiceV1 = exports.user = exports.oracle = exports.query = exports.sendMsg = void 0;
|
|
40
|
+
const core_1 = require("@ton/core");
|
|
41
|
+
const context_1 = require("../../context");
|
|
42
|
+
const send_msg_1 = require("../../lib/send-msg");
|
|
43
|
+
const query = __importStar(require("./query"));
|
|
44
|
+
exports.query = query;
|
|
45
|
+
const oracle = __importStar(require("./oracle"));
|
|
46
|
+
exports.oracle = oracle;
|
|
47
|
+
const user = __importStar(require("./user"));
|
|
48
|
+
exports.user = user;
|
|
49
|
+
var send_msg_2 = require("../../lib/send-msg");
|
|
50
|
+
Object.defineProperty(exports, "sendMsg", { enumerable: true, get: function () { return send_msg_2.sendMsg; } });
|
|
51
|
+
__exportStar(require("./user/types"), exports);
|
|
52
|
+
class RFQBatchServiceV1 {
|
|
53
|
+
ctx;
|
|
54
|
+
constructor(ctx = context_1.AffluentContext.getInstance()) {
|
|
55
|
+
this.ctx = ctx;
|
|
56
|
+
}
|
|
57
|
+
// ============================================================
|
|
58
|
+
// Query
|
|
59
|
+
// ============================================================
|
|
60
|
+
getRFQBatch(rfqBatchAddress) {
|
|
61
|
+
return query.getRFQBatch(this.ctx, rfqBatchAddress);
|
|
62
|
+
}
|
|
63
|
+
async getRFQBatchData(rfqBatchAddress) {
|
|
64
|
+
return query.getRFQBatchData(this.ctx, rfqBatchAddress);
|
|
65
|
+
}
|
|
66
|
+
async getAssetIndex(rfqBatchAddress, assetAddress) {
|
|
67
|
+
return query.getAssetIndex(this.ctx, rfqBatchAddress, assetAddress);
|
|
68
|
+
}
|
|
69
|
+
// ============================================================
|
|
70
|
+
// Oracle
|
|
71
|
+
// ============================================================
|
|
72
|
+
async getOracleParams(rfqBatchAddress) {
|
|
73
|
+
return oracle.getOracleParams(this.ctx, rfqBatchAddress);
|
|
74
|
+
}
|
|
75
|
+
// ============================================================
|
|
76
|
+
// User Operations
|
|
77
|
+
// ============================================================
|
|
78
|
+
async sendAddOrder(sender, params, value) {
|
|
79
|
+
return (0, send_msg_1.sendMsg)(sender, user.createAddOrderMsg(this.ctx, sender, params, value));
|
|
80
|
+
}
|
|
81
|
+
async sendSettle(sender, params, value) {
|
|
82
|
+
return (0, send_msg_1.sendMsg)(sender, user.createSettleMsg(this.ctx, sender, params, value));
|
|
83
|
+
}
|
|
84
|
+
async sendLock(sender, params, value) {
|
|
85
|
+
return (0, send_msg_1.sendMsg)(sender, user.createLockMsg(this.ctx, params, value));
|
|
86
|
+
}
|
|
87
|
+
async sendCancelOrder(sender, params, value) {
|
|
88
|
+
return (0, send_msg_1.sendMsg)(sender, user.createCancelOrderMsg(this.ctx, params, value));
|
|
89
|
+
}
|
|
90
|
+
async sendPayout(sender, params, value) {
|
|
91
|
+
return (0, send_msg_1.sendMsg)(sender, user.createPayoutMsg(this.ctx, params, value));
|
|
92
|
+
}
|
|
93
|
+
async sendReopen(sender, params, value) {
|
|
94
|
+
return (0, send_msg_1.sendMsg)(sender, user.createReopenMsg(this.ctx, params, value));
|
|
95
|
+
}
|
|
96
|
+
async sendCollectFee(sender, params, value) {
|
|
97
|
+
return (0, send_msg_1.sendMsg)(sender, user.createCollectFeeMsg(this.ctx, params, value));
|
|
98
|
+
}
|
|
99
|
+
async sendBatchPayout(sender, params, value) {
|
|
100
|
+
const rfqBatchData = await this.getRFQBatchData(params.rfqBatchAddress);
|
|
101
|
+
const msgs = [];
|
|
102
|
+
const maxCount = 99n;
|
|
103
|
+
// Asset0
|
|
104
|
+
const order0Count = BigInt(Object.values(rfqBatchData.asset0Orders).length);
|
|
105
|
+
if (order0Count > 0n) {
|
|
106
|
+
const batchCount = (order0Count + maxCount - 1n) / maxCount;
|
|
107
|
+
for (let i = 0; i < batchCount; i++) {
|
|
108
|
+
const { input } = await user.createPayoutMsg(this.ctx, {
|
|
109
|
+
rfqBatchAddress: params.rfqBatchAddress,
|
|
110
|
+
assetAddress: rfqBatchData.asset0Address,
|
|
111
|
+
count: Number(maxCount),
|
|
112
|
+
});
|
|
113
|
+
msgs.push({ ...input, sendMode: core_1.SendMode.PAY_GAS_SEPARATELY });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Asset1
|
|
117
|
+
const order1Count = BigInt(Object.values(rfqBatchData.asset1Orders).length);
|
|
118
|
+
if (order1Count > 0n) {
|
|
119
|
+
const batchCount = (order1Count + maxCount - 1n) / maxCount;
|
|
120
|
+
for (let i = 0; i < batchCount; i++) {
|
|
121
|
+
const { input } = await user.createPayoutMsg(this.ctx, {
|
|
122
|
+
rfqBatchAddress: params.rfqBatchAddress,
|
|
123
|
+
assetAddress: rfqBatchData.asset1Address,
|
|
124
|
+
count: Number(maxCount),
|
|
125
|
+
});
|
|
126
|
+
msgs.push({ ...input, sendMode: core_1.SendMode.PAY_GAS_SEPARATELY });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
await sender.multiSend(msgs);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.RFQBatchServiceV1 = RFQBatchServiceV1;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput } from "../../contracts/common/type";
|
|
4
|
+
import { OracleExposures } from "../composite-oracle/computation";
|
|
5
|
+
import { VaultPositions } from "../composite-oracle/types";
|
|
6
|
+
export { OracleExposures, createOracleExposures } from "../composite-oracle/computation";
|
|
7
|
+
/**
|
|
8
|
+
* Build oracle params Cell from pre-fetched vault positions
|
|
9
|
+
* Pure computation - no network calls
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildOracleParamsCellFromData(assetAddresses: string[], oracleConfig: any, vaultPositions: VaultPositions): Promise<{
|
|
12
|
+
oracleParams: Cell;
|
|
13
|
+
bucket: OracleExposures;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Get oracle params for RFQ batch settlement
|
|
17
|
+
* Orchestrates fetching and computation
|
|
18
|
+
*/
|
|
19
|
+
export declare function getOracleParams(ctx: AffluentContext, rfqBatchAddress: AddressInput): Promise<{
|
|
20
|
+
oracleParams: Cell;
|
|
21
|
+
bucket: OracleExposures;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOracleExposures = void 0;
|
|
4
|
+
exports.buildOracleParamsCellFromData = buildOracleParamsCellFromData;
|
|
5
|
+
exports.getOracleParams = getOracleParams;
|
|
6
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
7
|
+
const rfq_batch_1 = require("../../contracts/rfq/rfq_batch");
|
|
8
|
+
const query_1 = require("../composite-oracle/query");
|
|
9
|
+
const computation_1 = require("../composite-oracle/computation");
|
|
10
|
+
const computation_2 = require("../composite-oracle/computation");
|
|
11
|
+
var computation_3 = require("../composite-oracle/computation");
|
|
12
|
+
Object.defineProperty(exports, "createOracleExposures", { enumerable: true, get: function () { return computation_3.createOracleExposures; } });
|
|
13
|
+
// ============================================================
|
|
14
|
+
// Pure Computation (no I/O - works with pre-fetched data)
|
|
15
|
+
// ============================================================
|
|
16
|
+
/**
|
|
17
|
+
* Build oracle params Cell from pre-fetched vault positions
|
|
18
|
+
* Pure computation - no network calls
|
|
19
|
+
*/
|
|
20
|
+
async function buildOracleParamsCellFromData(assetAddresses, oracleConfig, vaultPositions) {
|
|
21
|
+
const bucket = (0, computation_2.createOracleExposures)();
|
|
22
|
+
// Separate vault assets from underlying assets
|
|
23
|
+
const { assets, vaultAssets } = (0, computation_1.separateAssets)(assetAddresses, oracleConfig);
|
|
24
|
+
// Add underlying assets to bucket
|
|
25
|
+
assets.forEach((a) => bucket.assets.add(a));
|
|
26
|
+
// Get exposures from pre-fetched vault positions
|
|
27
|
+
const exposures = (0, computation_1.getExposures)(vaultPositions);
|
|
28
|
+
// Add exposures to bucket
|
|
29
|
+
exposures.assets.forEach((a) => bucket.assets.add(a));
|
|
30
|
+
exposures.pools.forEach((p) => bucket.pools.add(p));
|
|
31
|
+
vaultAssets.forEach((v) => bucket.vaults.add(v));
|
|
32
|
+
const oracleParams = await (0, computation_2.buildOracleParamsCell)([...bucket.assets], oracleConfig, [...bucket.pools], [...bucket.vaults]);
|
|
33
|
+
return { oracleParams, bucket };
|
|
34
|
+
}
|
|
35
|
+
// ============================================================
|
|
36
|
+
// Orchestration (fetch + compute)
|
|
37
|
+
// ============================================================
|
|
38
|
+
/**
|
|
39
|
+
* Get oracle params for RFQ batch settlement
|
|
40
|
+
* Orchestrates fetching and computation
|
|
41
|
+
*/
|
|
42
|
+
async function getOracleParams(ctx, rfqBatchAddress) {
|
|
43
|
+
const rfqBatch = ctx.getByContract(rfq_batch_1.RFQBatch, (0, utils_1.toAddress)(rfqBatchAddress));
|
|
44
|
+
const rfqBatchData = await rfqBatch.getRFQData();
|
|
45
|
+
const oracleConfig = rfqBatchData.oracleConfig;
|
|
46
|
+
const assetAddresses = [rfqBatchData.asset0Address.toString(), rfqBatchData.asset1Address.toString()];
|
|
47
|
+
// Separate vault assets for fetching
|
|
48
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(assetAddresses, oracleConfig);
|
|
49
|
+
// Fetch vault positions
|
|
50
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
51
|
+
const vaultPositions = await fetcher.fetchVaultPositions(vaultAssets);
|
|
52
|
+
// Pure computation
|
|
53
|
+
return buildOracleParamsCellFromData(assetAddresses, oracleConfig, vaultPositions);
|
|
54
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AffluentContext } from "../../context";
|
|
2
|
+
import { AddressInput } from "../../contracts/common/type";
|
|
3
|
+
import { RFQBatch } from "../../contracts/rfq/rfq_batch";
|
|
4
|
+
/**
|
|
5
|
+
* Get RFQBatch contract instance
|
|
6
|
+
*/
|
|
7
|
+
export declare function getRFQBatch(ctx: AffluentContext, rfqBatchAddress: AddressInput): import("@ton/core").OpenedContract<RFQBatch>;
|
|
8
|
+
/**
|
|
9
|
+
* Get RFQ batch data
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRFQBatchData(ctx: AffluentContext, rfqBatchAddress: AddressInput): Promise<{
|
|
12
|
+
index: bigint;
|
|
13
|
+
asset0Address: import("@ton/core").Address;
|
|
14
|
+
asset1Address: import("@ton/core").Address;
|
|
15
|
+
asset0TotalAmount: bigint;
|
|
16
|
+
asset1TotalAmount: bigint;
|
|
17
|
+
asset0Orders: Record<string, import("../../contracts/rfq/rfq_batch").Order>;
|
|
18
|
+
asset1Orders: Record<string, import("../../contracts/rfq/rfq_batch").Order>;
|
|
19
|
+
status: number;
|
|
20
|
+
lockedTimestamp: number;
|
|
21
|
+
lockOwner: import("@ton/core").Address | null;
|
|
22
|
+
asset0WalletAddress: import("@ton/core").Address | null;
|
|
23
|
+
asset1WalletAddress: import("@ton/core").Address | null;
|
|
24
|
+
aggregatorIndex: bigint;
|
|
25
|
+
feeRate: bigint;
|
|
26
|
+
feeManager: import("@ton/core").Address | null;
|
|
27
|
+
whitelistedSettlers: Record<string, boolean>;
|
|
28
|
+
lockPeriod: number;
|
|
29
|
+
lockCooldown: number;
|
|
30
|
+
asset0CollectedFee: bigint;
|
|
31
|
+
asset1CollectedFee: bigint;
|
|
32
|
+
orderCount: bigint;
|
|
33
|
+
orderLimit: bigint;
|
|
34
|
+
asset0MinAmount: bigint;
|
|
35
|
+
asset1MinAmount: bigint;
|
|
36
|
+
asset0MaxAmount: bigint;
|
|
37
|
+
asset1MaxAmount: bigint;
|
|
38
|
+
guardianAddress: import("@ton/core").Address | null;
|
|
39
|
+
asset0Price: bigint;
|
|
40
|
+
asset1Price: bigint;
|
|
41
|
+
oracleConfig: import("@ton/core").Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Get asset index (0 or 1) for a given asset address
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAssetIndex(ctx: AffluentContext, rfqBatchAddress: AddressInput, assetAddress: AddressInput): Promise<0 | 1>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRFQBatch = getRFQBatch;
|
|
4
|
+
exports.getRFQBatchData = getRFQBatchData;
|
|
5
|
+
exports.getAssetIndex = getAssetIndex;
|
|
6
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
7
|
+
const rfq_batch_1 = require("../../contracts/rfq/rfq_batch");
|
|
8
|
+
/**
|
|
9
|
+
* Get RFQBatch contract instance
|
|
10
|
+
*/
|
|
11
|
+
function getRFQBatch(ctx, rfqBatchAddress) {
|
|
12
|
+
return ctx.getByContract(rfq_batch_1.RFQBatch, (0, utils_1.toAddress)(rfqBatchAddress));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get RFQ batch data
|
|
16
|
+
*/
|
|
17
|
+
async function getRFQBatchData(ctx, rfqBatchAddress) {
|
|
18
|
+
const rfqBatch = getRFQBatch(ctx, rfqBatchAddress);
|
|
19
|
+
return rfqBatch.getRFQData();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get asset index (0 or 1) for a given asset address
|
|
23
|
+
*/
|
|
24
|
+
async function getAssetIndex(ctx, rfqBatchAddress, assetAddress) {
|
|
25
|
+
const rfqBatchData = await getRFQBatchData(ctx, rfqBatchAddress);
|
|
26
|
+
const assetAddr = (0, utils_1.toAddress)(assetAddress).toString();
|
|
27
|
+
if (rfqBatchData.asset0Address.toString() === assetAddr) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
else if (rfqBatchData.asset1Address.toString() === assetAddr) {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Asset not found in RFQ batch");
|
|
34
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AffluentContext } from "../../../context";
|
|
2
|
+
import { AddressSender } from "../../../types/sender";
|
|
3
|
+
import { AddOrderParams, SettleParams, LockParams, CancelOrderParams, PayoutParams, ReopenParams, CollectFeeParams } from "./types";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export declare function createAddOrderMsg(ctx: AffluentContext, sender: AddressSender, params: AddOrderParams, value?: bigint): Promise<{
|
|
6
|
+
opts: {
|
|
7
|
+
recipient: import("@ton/core").Address;
|
|
8
|
+
response: import("@ton/core").Address;
|
|
9
|
+
amount: bigint;
|
|
10
|
+
forwardTonAmount: bigint;
|
|
11
|
+
forwardPayload: import("@ton/core").Cell;
|
|
12
|
+
queryId: bigint | undefined;
|
|
13
|
+
};
|
|
14
|
+
input: {
|
|
15
|
+
to: import("@ton/core").Address;
|
|
16
|
+
value: bigint;
|
|
17
|
+
body: import("@ton/core").Cell;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createSettleMsg(ctx: AffluentContext, sender: AddressSender, params: SettleParams, value?: bigint): Promise<{
|
|
21
|
+
opts: {
|
|
22
|
+
recipient: import("@ton/core").Address;
|
|
23
|
+
response: import("@ton/core").Address;
|
|
24
|
+
amount: bigint;
|
|
25
|
+
forwardTonAmount: bigint;
|
|
26
|
+
forwardPayload: import("@ton/core").Cell;
|
|
27
|
+
queryId: bigint | undefined;
|
|
28
|
+
};
|
|
29
|
+
input: {
|
|
30
|
+
to: import("@ton/core").Address;
|
|
31
|
+
value: bigint;
|
|
32
|
+
body: import("@ton/core").Cell;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export declare function createLockMsg(ctx: AffluentContext, params: LockParams, value?: bigint): Promise<{
|
|
36
|
+
opts: {};
|
|
37
|
+
input: {
|
|
38
|
+
to: import("@ton/core").Address;
|
|
39
|
+
value: bigint;
|
|
40
|
+
body: import("@ton/core").Cell;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
export declare function createCancelOrderMsg(ctx: AffluentContext, params: CancelOrderParams, value?: bigint): Promise<{
|
|
44
|
+
opts: {
|
|
45
|
+
assetIdx: 0 | 1;
|
|
46
|
+
};
|
|
47
|
+
input: {
|
|
48
|
+
to: import("@ton/core").Address;
|
|
49
|
+
value: bigint;
|
|
50
|
+
body: import("@ton/core").Cell;
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
export declare function createPayoutMsg(ctx: AffluentContext, params: PayoutParams, value?: bigint): Promise<{
|
|
54
|
+
opts: {
|
|
55
|
+
assetIdx: 0 | 1;
|
|
56
|
+
count: number;
|
|
57
|
+
};
|
|
58
|
+
input: {
|
|
59
|
+
to: import("@ton/core").Address;
|
|
60
|
+
value: bigint;
|
|
61
|
+
body: import("@ton/core").Cell;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
export declare function createReopenMsg(ctx: AffluentContext, params: ReopenParams, value?: bigint): Promise<{
|
|
65
|
+
opts: {};
|
|
66
|
+
input: {
|
|
67
|
+
to: import("@ton/core").Address;
|
|
68
|
+
value: bigint;
|
|
69
|
+
body: import("@ton/core").Cell;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
export declare function createCollectFeeMsg(ctx: AffluentContext, params: CollectFeeParams, value?: bigint): Promise<{
|
|
73
|
+
opts: {};
|
|
74
|
+
input: {
|
|
75
|
+
to: import("@ton/core").Address;
|
|
76
|
+
value: bigint;
|
|
77
|
+
body: import("@ton/core").Cell;
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createAddOrderMsg = createAddOrderMsg;
|
|
18
|
+
exports.createSettleMsg = createSettleMsg;
|
|
19
|
+
exports.createLockMsg = createLockMsg;
|
|
20
|
+
exports.createCancelOrderMsg = createCancelOrderMsg;
|
|
21
|
+
exports.createPayoutMsg = createPayoutMsg;
|
|
22
|
+
exports.createReopenMsg = createReopenMsg;
|
|
23
|
+
exports.createCollectFeeMsg = createCollectFeeMsg;
|
|
24
|
+
const core_1 = require("@ton/core");
|
|
25
|
+
const utils_1 = require("../../../contracts/common/utils");
|
|
26
|
+
const jetton_minter_1 = require("../../../contracts/jetton/jetton-minter");
|
|
27
|
+
const jetton_wallet_1 = require("../../../contracts/jetton/jetton-wallet");
|
|
28
|
+
const rfq_batch_1 = require("../../../contracts/rfq/rfq_batch");
|
|
29
|
+
const oracle_1 = require("../oracle");
|
|
30
|
+
const query_1 = require("../query");
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
|
+
// ============================================================
|
|
33
|
+
// Add Order
|
|
34
|
+
// ============================================================
|
|
35
|
+
async function createAddOrderMsg(ctx, sender, params, value) {
|
|
36
|
+
const rfqBatchAddress = (0, utils_1.toAddress)(params.rfqBatchAddress);
|
|
37
|
+
const assetAddress = (0, utils_1.toAddress)(params.assetAddress);
|
|
38
|
+
const forwardPayload = rfq_batch_1.RFQBatch.createOrderMsg(sender.address, params.forwardTonAmount, params.forwardPayload);
|
|
39
|
+
const senderWalletAddress = await ctx
|
|
40
|
+
.getByContract(jetton_minter_1.JettonMinter, assetAddress)
|
|
41
|
+
.getWalletAddress(sender.address);
|
|
42
|
+
const senderWallet = ctx.getByContract(jetton_wallet_1.JettonWallet, senderWalletAddress);
|
|
43
|
+
const opts = {
|
|
44
|
+
recipient: rfqBatchAddress,
|
|
45
|
+
response: sender.address,
|
|
46
|
+
amount: params.amount,
|
|
47
|
+
forwardTonAmount: (0, core_1.toNano)(0.1),
|
|
48
|
+
forwardPayload,
|
|
49
|
+
queryId: params.queryId,
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
opts,
|
|
53
|
+
input: {
|
|
54
|
+
to: senderWallet.address,
|
|
55
|
+
value: value ?? (0, core_1.toNano)(0.2),
|
|
56
|
+
body: senderWallet.createTransferBody(opts),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// ============================================================
|
|
61
|
+
// Settle
|
|
62
|
+
// ============================================================
|
|
63
|
+
async function createSettleMsg(ctx, sender, params, value) {
|
|
64
|
+
const rfqBatchAddress = (0, utils_1.toAddress)(params.rfqBatchAddress);
|
|
65
|
+
const assetAddress = (0, utils_1.toAddress)(params.assetAddress);
|
|
66
|
+
const { oracleParams, bucket } = await (0, oracle_1.getOracleParams)(ctx, rfqBatchAddress);
|
|
67
|
+
const forwardPayload = rfq_batch_1.RFQBatch.createSettleMsg(oracleParams);
|
|
68
|
+
const senderWalletAddress = await ctx
|
|
69
|
+
.getByContract(jetton_minter_1.JettonMinter, assetAddress)
|
|
70
|
+
.getWalletAddress(sender.address);
|
|
71
|
+
const senderWallet = ctx.getByContract(jetton_wallet_1.JettonWallet, senderWalletAddress);
|
|
72
|
+
const oracleCalculateGas = BigInt(bucket.assets.size + bucket.pools.size + bucket.vaults.size) * (0, core_1.toNano)(0.06);
|
|
73
|
+
const forwardTonAmount = oracleCalculateGas + (0, core_1.toNano)(0.4);
|
|
74
|
+
const opts = {
|
|
75
|
+
recipient: rfqBatchAddress,
|
|
76
|
+
response: sender.address,
|
|
77
|
+
amount: params.amount,
|
|
78
|
+
forwardTonAmount,
|
|
79
|
+
forwardPayload,
|
|
80
|
+
queryId: params.queryId,
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
opts,
|
|
84
|
+
input: {
|
|
85
|
+
to: senderWallet.address,
|
|
86
|
+
value: value ?? forwardTonAmount + (0, core_1.toNano)(0.1),
|
|
87
|
+
body: senderWallet.createTransferBody(opts),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// ============================================================
|
|
92
|
+
// Lock
|
|
93
|
+
// ============================================================
|
|
94
|
+
async function createLockMsg(ctx, params, value) {
|
|
95
|
+
const rfqBatch = ctx.getByContract(rfq_batch_1.RFQBatch, (0, utils_1.toAddress)(params.rfqBatchAddress));
|
|
96
|
+
return {
|
|
97
|
+
opts: {},
|
|
98
|
+
input: {
|
|
99
|
+
to: rfqBatch.address,
|
|
100
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
101
|
+
body: (0, core_1.beginCell)().storeUint(rfq_batch_1.RFQBatch.Op.Lock, 32).storeUint(0, 64).endCell(),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// ============================================================
|
|
106
|
+
// Cancel Order
|
|
107
|
+
// ============================================================
|
|
108
|
+
async function createCancelOrderMsg(ctx, params, value) {
|
|
109
|
+
const rfqBatchAddress = (0, utils_1.toAddress)(params.rfqBatchAddress);
|
|
110
|
+
const assetIdx = await (0, query_1.getAssetIndex)(ctx, rfqBatchAddress, params.assetAddress);
|
|
111
|
+
return {
|
|
112
|
+
opts: { assetIdx },
|
|
113
|
+
input: {
|
|
114
|
+
to: rfqBatchAddress,
|
|
115
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
116
|
+
body: (0, core_1.beginCell)()
|
|
117
|
+
.storeUint(rfq_batch_1.RFQBatch.Op.CancelOrder, 32)
|
|
118
|
+
.storeUint(0, 64)
|
|
119
|
+
.storeUint(assetIdx, 1)
|
|
120
|
+
.endCell(),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// ============================================================
|
|
125
|
+
// Payout
|
|
126
|
+
// ============================================================
|
|
127
|
+
async function createPayoutMsg(ctx, params, value) {
|
|
128
|
+
const rfqBatchAddress = (0, utils_1.toAddress)(params.rfqBatchAddress);
|
|
129
|
+
const assetIdx = await (0, query_1.getAssetIndex)(ctx, rfqBatchAddress, params.assetAddress);
|
|
130
|
+
return {
|
|
131
|
+
opts: { assetIdx, count: params.count },
|
|
132
|
+
input: {
|
|
133
|
+
to: rfqBatchAddress,
|
|
134
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
135
|
+
body: (0, core_1.beginCell)()
|
|
136
|
+
.storeUint(rfq_batch_1.RFQBatch.Op.Payout, 32)
|
|
137
|
+
.storeUint(0, 64)
|
|
138
|
+
.storeUint(assetIdx, 1)
|
|
139
|
+
.storeCoins(params.count)
|
|
140
|
+
.endCell(),
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ============================================================
|
|
145
|
+
// Reopen
|
|
146
|
+
// ============================================================
|
|
147
|
+
async function createReopenMsg(ctx, params, value) {
|
|
148
|
+
const rfqBatch = ctx.getByContract(rfq_batch_1.RFQBatch, (0, utils_1.toAddress)(params.rfqBatchAddress));
|
|
149
|
+
return {
|
|
150
|
+
opts: {},
|
|
151
|
+
input: {
|
|
152
|
+
to: rfqBatch.address,
|
|
153
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
154
|
+
body: (0, core_1.beginCell)().storeUint(rfq_batch_1.RFQBatch.Op.Reopen, 32).storeUint(0, 64).endCell(),
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// ============================================================
|
|
159
|
+
// Collect Fee
|
|
160
|
+
// ============================================================
|
|
161
|
+
async function createCollectFeeMsg(ctx, params, value) {
|
|
162
|
+
const rfqBatch = ctx.getByContract(rfq_batch_1.RFQBatch, (0, utils_1.toAddress)(params.rfqBatchAddress));
|
|
163
|
+
return {
|
|
164
|
+
opts: {},
|
|
165
|
+
input: {
|
|
166
|
+
to: rfqBatch.address,
|
|
167
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
168
|
+
body: (0, core_1.beginCell)().storeUint(rfq_batch_1.RFQBatch.Op.CollectFee, 32).storeUint(0, 64).endCell(),
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|