@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,44 @@
|
|
|
1
|
+
import { AddressInput, AddressLike } from "../../../contracts/common/type";
|
|
2
|
+
export type SupplyParams = {
|
|
3
|
+
poolAddress: AddressInput;
|
|
4
|
+
assetAddress: AddressLike;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
recipientAddress?: AddressLike;
|
|
7
|
+
queryId?: bigint;
|
|
8
|
+
value?: bigint;
|
|
9
|
+
};
|
|
10
|
+
export type WithdrawParams = {
|
|
11
|
+
poolAddress: AddressInput;
|
|
12
|
+
assetAddress: AddressLike;
|
|
13
|
+
amount: bigint;
|
|
14
|
+
isShare?: boolean;
|
|
15
|
+
recipientAddress?: AddressLike;
|
|
16
|
+
queryId?: bigint;
|
|
17
|
+
value?: bigint;
|
|
18
|
+
};
|
|
19
|
+
export type BorrowParams = {
|
|
20
|
+
poolAddress: AddressInput;
|
|
21
|
+
assetAddress: AddressLike;
|
|
22
|
+
amount: bigint;
|
|
23
|
+
isShare?: boolean;
|
|
24
|
+
recipientAddress?: AddressLike;
|
|
25
|
+
queryId?: bigint;
|
|
26
|
+
value?: bigint;
|
|
27
|
+
};
|
|
28
|
+
export type RepayParams = {
|
|
29
|
+
poolAddress: AddressInput;
|
|
30
|
+
assetAddress: AddressLike;
|
|
31
|
+
amount: bigint;
|
|
32
|
+
recipientAddress?: AddressLike;
|
|
33
|
+
queryId?: bigint;
|
|
34
|
+
value?: bigint;
|
|
35
|
+
};
|
|
36
|
+
export type LiquidateParams = {
|
|
37
|
+
poolAddress: AddressInput;
|
|
38
|
+
repayAssetAddress: AddressLike;
|
|
39
|
+
seizeAssetAddress: AddressLike;
|
|
40
|
+
borrowerAddress: AddressLike;
|
|
41
|
+
amount: bigint;
|
|
42
|
+
queryId?: bigint;
|
|
43
|
+
value?: bigint;
|
|
44
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { StrategyVaultState } from "../../contracts/vault/strategy-vault";
|
|
5
|
+
import { AddressSender } from "../../types/sender";
|
|
6
|
+
import * as query from "./query";
|
|
7
|
+
import * as oracle from "./oracle";
|
|
8
|
+
import * as user from "./user";
|
|
9
|
+
export { sendMsg } from "../../lib/send-msg";
|
|
10
|
+
export * from "./user/types";
|
|
11
|
+
export { query, oracle, user };
|
|
12
|
+
export declare class RFQAuctionServiceV1 {
|
|
13
|
+
private ctx;
|
|
14
|
+
constructor(ctx?: AffluentContext);
|
|
15
|
+
getRFQAuction(rfqAuctionAddress: AddressInput): import("@ton/core").OpenedContract<import("../..").RFQAuction>;
|
|
16
|
+
getRFQData(rfqAuctionAddress: AddressInput): Promise<{
|
|
17
|
+
initialized: boolean;
|
|
18
|
+
index: bigint;
|
|
19
|
+
state: number;
|
|
20
|
+
sellerAddress: import("@ton/core").Address;
|
|
21
|
+
verifiedSellWallet: boolean;
|
|
22
|
+
verifiedBuyWallet: boolean;
|
|
23
|
+
depositedSellAsset: boolean;
|
|
24
|
+
bids: Record<string, {
|
|
25
|
+
bidValue: bigint;
|
|
26
|
+
escrowAmount: bigint;
|
|
27
|
+
lt: bigint;
|
|
28
|
+
responseAddress: import("@ton/core").Address;
|
|
29
|
+
forwardTonAmount: bigint;
|
|
30
|
+
forwardPayload: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
sellAssetAddress: import("@ton/core").Address;
|
|
33
|
+
buyAssetAddress: import("@ton/core").Address;
|
|
34
|
+
sellAssetAmount: bigint;
|
|
35
|
+
config: {
|
|
36
|
+
auctionMode: number;
|
|
37
|
+
bidCloseTimestamp: number;
|
|
38
|
+
minBuyAssetValue: bigint;
|
|
39
|
+
maxBuyAssetValue: bigint;
|
|
40
|
+
allowSellerCancel: boolean;
|
|
41
|
+
allowBidderCancel: boolean;
|
|
42
|
+
priceDeviationTolerance: bigint;
|
|
43
|
+
};
|
|
44
|
+
sellAssetWalletAddress: import("@ton/core").Address | null;
|
|
45
|
+
buyAssetWalletAddress: import("@ton/core").Address | null;
|
|
46
|
+
rfqEventEmitterAddress: import("@ton/core").Address | null;
|
|
47
|
+
dataAggregatorCodeHash: string | null;
|
|
48
|
+
dataAggregatorIndex: bigint;
|
|
49
|
+
oracleConfig: Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
50
|
+
jettonForwardTonAmount: bigint;
|
|
51
|
+
jettonForwardPayloadHash: string | null;
|
|
52
|
+
responseAddress: import("@ton/core").Address;
|
|
53
|
+
rfqNotiForwardTonAmount: bigint;
|
|
54
|
+
rfqNotiForwardPayloadHash: string | null;
|
|
55
|
+
}>;
|
|
56
|
+
getOracleParams(rfqAuctionAddress: AddressInput): Promise<Cell>;
|
|
57
|
+
getOracleParamsForVault(vaultAddress: AddressLike, additionalAssets?: AddressLike[], vaultData?: StrategyVaultState): Promise<Cell>;
|
|
58
|
+
sendAmountBid(sender: AddressSender, params: user.AmountBidParams, value?: bigint): Promise<{
|
|
59
|
+
recipient: import("@ton/core").Address;
|
|
60
|
+
response: import("@ton/core").Address;
|
|
61
|
+
amount: bigint;
|
|
62
|
+
forwardTonAmount: bigint;
|
|
63
|
+
forwardPayload: Cell;
|
|
64
|
+
queryId: bigint | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
sendSlippageBid(sender: AddressSender, params: user.SlippageBidParams, value?: bigint): Promise<{
|
|
67
|
+
recipient: import("@ton/core").Address;
|
|
68
|
+
response: import("@ton/core").Address;
|
|
69
|
+
amount: bigint;
|
|
70
|
+
forwardTonAmount: bigint;
|
|
71
|
+
forwardPayload: Cell;
|
|
72
|
+
queryId: bigint | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
sendCancelBid(sender: AddressSender, params: user.CancelBidParams, value?: bigint): Promise<{}>;
|
|
75
|
+
sendSettle(sender: AddressSender, params: user.SettleParams, value?: bigint): Promise<{
|
|
76
|
+
oracleParams: Cell;
|
|
77
|
+
}>;
|
|
78
|
+
sendClearBids(sender: AddressSender, params: user.ClearBidsParams, value?: bigint): Promise<{
|
|
79
|
+
clearCount: number;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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.RFQAuctionServiceV1 = exports.user = exports.oracle = exports.query = exports.sendMsg = void 0;
|
|
40
|
+
const context_1 = require("../../context");
|
|
41
|
+
const send_msg_1 = require("../../lib/send-msg");
|
|
42
|
+
const query = __importStar(require("./query"));
|
|
43
|
+
exports.query = query;
|
|
44
|
+
const oracle = __importStar(require("./oracle"));
|
|
45
|
+
exports.oracle = oracle;
|
|
46
|
+
const user = __importStar(require("./user"));
|
|
47
|
+
exports.user = user;
|
|
48
|
+
var send_msg_2 = require("../../lib/send-msg");
|
|
49
|
+
Object.defineProperty(exports, "sendMsg", { enumerable: true, get: function () { return send_msg_2.sendMsg; } });
|
|
50
|
+
__exportStar(require("./user/types"), exports);
|
|
51
|
+
class RFQAuctionServiceV1 {
|
|
52
|
+
ctx;
|
|
53
|
+
constructor(ctx = context_1.AffluentContext.getInstance()) {
|
|
54
|
+
this.ctx = ctx;
|
|
55
|
+
}
|
|
56
|
+
// ============================================================
|
|
57
|
+
// Query
|
|
58
|
+
// ============================================================
|
|
59
|
+
getRFQAuction(rfqAuctionAddress) {
|
|
60
|
+
return query.getRFQAuction(this.ctx, rfqAuctionAddress);
|
|
61
|
+
}
|
|
62
|
+
async getRFQData(rfqAuctionAddress) {
|
|
63
|
+
return query.getRFQData(this.ctx, rfqAuctionAddress);
|
|
64
|
+
}
|
|
65
|
+
// ============================================================
|
|
66
|
+
// Oracle
|
|
67
|
+
// ============================================================
|
|
68
|
+
async getOracleParams(rfqAuctionAddress) {
|
|
69
|
+
return oracle.getOracleParamsForAuction(this.ctx, rfqAuctionAddress);
|
|
70
|
+
}
|
|
71
|
+
async getOracleParamsForVault(vaultAddress, additionalAssets, vaultData) {
|
|
72
|
+
return oracle.getOracleParamsForVault(this.ctx, vaultAddress, additionalAssets, vaultData);
|
|
73
|
+
}
|
|
74
|
+
// ============================================================
|
|
75
|
+
// User Operations
|
|
76
|
+
// ============================================================
|
|
77
|
+
async sendAmountBid(sender, params, value) {
|
|
78
|
+
return (0, send_msg_1.sendMsg)(sender, user.createAmountBidMsg(this.ctx, sender, params, value));
|
|
79
|
+
}
|
|
80
|
+
async sendSlippageBid(sender, params, value) {
|
|
81
|
+
return (0, send_msg_1.sendMsg)(sender, user.createSlippageBidMsg(this.ctx, sender, params, value));
|
|
82
|
+
}
|
|
83
|
+
async sendCancelBid(sender, params, value) {
|
|
84
|
+
return (0, send_msg_1.sendMsg)(sender, user.createCancelBidMsg(this.ctx, params, value));
|
|
85
|
+
}
|
|
86
|
+
async sendSettle(sender, params, value) {
|
|
87
|
+
return (0, send_msg_1.sendMsg)(sender, user.createSettleMsg(this.ctx, params, value));
|
|
88
|
+
}
|
|
89
|
+
async sendClearBids(sender, params, value) {
|
|
90
|
+
return (0, send_msg_1.sendMsg)(sender, user.createClearBidsMsg(this.ctx, params, value));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.RFQAuctionServiceV1 = RFQAuctionServiceV1;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../context";
|
|
3
|
+
import { AddressInput, AddressLike } from "../../contracts/common/type";
|
|
4
|
+
import { StrategyVaultState } from "../../contracts/vault/strategy-vault";
|
|
5
|
+
import { VaultPositions } from "../composite-oracle/types";
|
|
6
|
+
export { OracleExposures, createOracleExposures } from "../composite-oracle/computation";
|
|
7
|
+
/**
|
|
8
|
+
* Build oracle params Cell from pre-fetched data
|
|
9
|
+
* Pure computation - no network calls
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildOracleParamsCellFromData(assets: string[], oracleConfig: any, vaultPositions: VaultPositions): Promise<Cell>;
|
|
12
|
+
/**
|
|
13
|
+
* Get oracle params for RFQ auction settlement
|
|
14
|
+
*/
|
|
15
|
+
export declare function getOracleParamsForAuction(ctx: AffluentContext, rfqAuctionAddress: AddressInput): Promise<Cell>;
|
|
16
|
+
/**
|
|
17
|
+
* Get oracle params for strategy vault (used in RFQ auction context)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getOracleParamsForVault(ctx: AffluentContext, vaultAddress: AddressLike, additionalAssets?: AddressLike[], vaultData?: StrategyVaultState): Promise<Cell>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOracleExposures = void 0;
|
|
4
|
+
exports.buildOracleParamsCellFromData = buildOracleParamsCellFromData;
|
|
5
|
+
exports.getOracleParamsForAuction = getOracleParamsForAuction;
|
|
6
|
+
exports.getOracleParamsForVault = getOracleParamsForVault;
|
|
7
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
8
|
+
const rfq_auction_1 = require("../../contracts/rfq/rfq_auction");
|
|
9
|
+
const strategy_vault_1 = require("../../contracts/vault/strategy-vault");
|
|
10
|
+
const query_1 = require("../composite-oracle/query");
|
|
11
|
+
const computation_1 = require("../composite-oracle/computation");
|
|
12
|
+
const computation_2 = require("../composite-oracle/computation");
|
|
13
|
+
// Re-export for backward compatibility
|
|
14
|
+
var computation_3 = require("../composite-oracle/computation");
|
|
15
|
+
Object.defineProperty(exports, "createOracleExposures", { enumerable: true, get: function () { return computation_3.createOracleExposures; } });
|
|
16
|
+
// ============================================================
|
|
17
|
+
// Pure Computation (no I/O)
|
|
18
|
+
// ============================================================
|
|
19
|
+
/**
|
|
20
|
+
* Build oracle params Cell from pre-fetched data
|
|
21
|
+
* Pure computation - no network calls
|
|
22
|
+
*/
|
|
23
|
+
function buildOracleParamsCellFromData(assets, oracleConfig, vaultPositions) {
|
|
24
|
+
const { assets: pureAssets, vaultAssets } = (0, computation_1.separateAssets)(assets, oracleConfig);
|
|
25
|
+
const exposures = (0, computation_1.getExposures)(vaultPositions);
|
|
26
|
+
const allAssets = [...new Set([...pureAssets, ...exposures.assets])];
|
|
27
|
+
return (0, computation_2.buildOracleParamsCell)(allAssets, oracleConfig, exposures.pools, vaultAssets);
|
|
28
|
+
}
|
|
29
|
+
// ============================================================
|
|
30
|
+
// Orchestration (fetch + compute)
|
|
31
|
+
// ============================================================
|
|
32
|
+
/**
|
|
33
|
+
* Get oracle params for RFQ auction settlement
|
|
34
|
+
*/
|
|
35
|
+
async function getOracleParamsForAuction(ctx, rfqAuctionAddress) {
|
|
36
|
+
const rfqAuction = ctx.getByContract(rfq_auction_1.RFQAuction, (0, utils_1.toAddress)(rfqAuctionAddress));
|
|
37
|
+
const rfqAuctionData = await rfqAuction.getRFQData();
|
|
38
|
+
const oracleConfig = rfqAuctionData.oracleConfig;
|
|
39
|
+
const allAssets = [rfqAuctionData.sellAssetAddress.toString(), rfqAuctionData.buyAssetAddress.toString()];
|
|
40
|
+
const { vaultAssets } = (0, computation_1.separateAssets)(allAssets, oracleConfig);
|
|
41
|
+
// Fetch
|
|
42
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
43
|
+
const vaultPositions = await fetcher.fetchVaultPositions(vaultAssets);
|
|
44
|
+
// Compute
|
|
45
|
+
return buildOracleParamsCellFromData(allAssets, oracleConfig, vaultPositions);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get oracle params for strategy vault (used in RFQ auction context)
|
|
49
|
+
*/
|
|
50
|
+
async function getOracleParamsForVault(ctx, vaultAddress, additionalAssets = [], vaultData) {
|
|
51
|
+
const fetcher = new query_1.CompositeOracleFetcher(ctx);
|
|
52
|
+
const vault = ctx.getByContract(strategy_vault_1.StrategyVault, (0, utils_1.toAddress)(vaultAddress));
|
|
53
|
+
vaultData = vaultData ?? (await vault.getVaultData());
|
|
54
|
+
const extraAssets = additionalAssets.map((a) => (0, utils_1.toAddress)(a).toString());
|
|
55
|
+
const oracleCtx = await fetcher.getOracleContext(vaultAddress, vaultData, {
|
|
56
|
+
assets: extraAssets,
|
|
57
|
+
vaultAssets: [],
|
|
58
|
+
});
|
|
59
|
+
return (0, computation_2.buildOracleParamsCell)(oracleCtx.allRequiredAssets, oracleCtx.oracleConfig, oracleCtx.exposures.pools, oracleCtx.vaultAssets);
|
|
60
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AffluentContext } from "../../context";
|
|
2
|
+
import { AddressInput } from "../../contracts/common/type";
|
|
3
|
+
import { RFQAuction } from "../../contracts/rfq/rfq_auction";
|
|
4
|
+
/**
|
|
5
|
+
* Get RFQAuction contract instance
|
|
6
|
+
*/
|
|
7
|
+
export declare function getRFQAuction(ctx: AffluentContext, rfqAuctionAddress: AddressInput): import("@ton/core").OpenedContract<RFQAuction>;
|
|
8
|
+
/**
|
|
9
|
+
* Get RFQ auction data
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRFQData(ctx: AffluentContext, rfqAuctionAddress: AddressInput): Promise<{
|
|
12
|
+
initialized: boolean;
|
|
13
|
+
index: bigint;
|
|
14
|
+
state: number;
|
|
15
|
+
sellerAddress: import("@ton/core").Address;
|
|
16
|
+
verifiedSellWallet: boolean;
|
|
17
|
+
verifiedBuyWallet: boolean;
|
|
18
|
+
depositedSellAsset: boolean;
|
|
19
|
+
bids: Record<string, {
|
|
20
|
+
bidValue: bigint;
|
|
21
|
+
escrowAmount: bigint;
|
|
22
|
+
lt: bigint;
|
|
23
|
+
responseAddress: import("@ton/core").Address;
|
|
24
|
+
forwardTonAmount: bigint;
|
|
25
|
+
forwardPayload: string | null;
|
|
26
|
+
}>;
|
|
27
|
+
sellAssetAddress: import("@ton/core").Address;
|
|
28
|
+
buyAssetAddress: import("@ton/core").Address;
|
|
29
|
+
sellAssetAmount: bigint;
|
|
30
|
+
config: {
|
|
31
|
+
auctionMode: number;
|
|
32
|
+
bidCloseTimestamp: number;
|
|
33
|
+
minBuyAssetValue: bigint;
|
|
34
|
+
maxBuyAssetValue: bigint;
|
|
35
|
+
allowSellerCancel: boolean;
|
|
36
|
+
allowBidderCancel: boolean;
|
|
37
|
+
priceDeviationTolerance: bigint;
|
|
38
|
+
};
|
|
39
|
+
sellAssetWalletAddress: import("@ton/core").Address | null;
|
|
40
|
+
buyAssetWalletAddress: import("@ton/core").Address | null;
|
|
41
|
+
rfqEventEmitterAddress: import("@ton/core").Address | null;
|
|
42
|
+
dataAggregatorCodeHash: string | null;
|
|
43
|
+
dataAggregatorIndex: bigint;
|
|
44
|
+
oracleConfig: import("@ton/core").Cell | import("../../contracts/oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../contracts/oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
45
|
+
jettonForwardTonAmount: bigint;
|
|
46
|
+
jettonForwardPayloadHash: string | null;
|
|
47
|
+
responseAddress: import("@ton/core").Address;
|
|
48
|
+
rfqNotiForwardTonAmount: bigint;
|
|
49
|
+
rfqNotiForwardPayloadHash: string | null;
|
|
50
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRFQAuction = getRFQAuction;
|
|
4
|
+
exports.getRFQData = getRFQData;
|
|
5
|
+
const utils_1 = require("../../contracts/common/utils");
|
|
6
|
+
const rfq_auction_1 = require("../../contracts/rfq/rfq_auction");
|
|
7
|
+
/**
|
|
8
|
+
* Get RFQAuction contract instance
|
|
9
|
+
*/
|
|
10
|
+
function getRFQAuction(ctx, rfqAuctionAddress) {
|
|
11
|
+
return ctx.getByContract(rfq_auction_1.RFQAuction, (0, utils_1.toAddress)(rfqAuctionAddress));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get RFQ auction data
|
|
15
|
+
*/
|
|
16
|
+
async function getRFQData(ctx, rfqAuctionAddress) {
|
|
17
|
+
const rfqAuction = getRFQAuction(ctx, rfqAuctionAddress);
|
|
18
|
+
return rfqAuction.getRFQData();
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Cell } from "@ton/core";
|
|
2
|
+
import { AffluentContext } from "../../../context";
|
|
3
|
+
import { AddressSender } from "../../../types/sender";
|
|
4
|
+
import { AmountBidParams, SlippageBidParams, CancelBidParams, SettleParams, ClearBidsParams } from "./types";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export declare function createAmountBidMsg(ctx: AffluentContext, sender: AddressSender, params: AmountBidParams, value?: bigint): Promise<{
|
|
7
|
+
opts: {
|
|
8
|
+
recipient: import("@ton/core").Address;
|
|
9
|
+
response: import("@ton/core").Address;
|
|
10
|
+
amount: bigint;
|
|
11
|
+
forwardTonAmount: bigint;
|
|
12
|
+
forwardPayload: Cell;
|
|
13
|
+
queryId: bigint | undefined;
|
|
14
|
+
};
|
|
15
|
+
input: {
|
|
16
|
+
to: import("@ton/core").Address;
|
|
17
|
+
value: bigint;
|
|
18
|
+
body: Cell;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare function createSlippageBidMsg(ctx: AffluentContext, sender: AddressSender, params: SlippageBidParams, value?: bigint): Promise<{
|
|
22
|
+
opts: {
|
|
23
|
+
recipient: import("@ton/core").Address;
|
|
24
|
+
response: import("@ton/core").Address;
|
|
25
|
+
amount: bigint;
|
|
26
|
+
forwardTonAmount: bigint;
|
|
27
|
+
forwardPayload: Cell;
|
|
28
|
+
queryId: bigint | undefined;
|
|
29
|
+
};
|
|
30
|
+
input: {
|
|
31
|
+
to: import("@ton/core").Address;
|
|
32
|
+
value: bigint;
|
|
33
|
+
body: Cell;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
export declare function createCancelBidMsg(ctx: AffluentContext, params: CancelBidParams, value?: bigint): Promise<{
|
|
37
|
+
opts: {};
|
|
38
|
+
input: {
|
|
39
|
+
to: import("@ton/core").Address;
|
|
40
|
+
value: bigint;
|
|
41
|
+
body: Cell;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
export declare function createSettleMsg(ctx: AffluentContext, params: SettleParams, value?: bigint): Promise<{
|
|
45
|
+
opts: {
|
|
46
|
+
oracleParams: Cell;
|
|
47
|
+
};
|
|
48
|
+
input: {
|
|
49
|
+
to: import("@ton/core").Address;
|
|
50
|
+
value: bigint;
|
|
51
|
+
body: Cell;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export declare function createClearBidsMsg(ctx: AffluentContext, params: ClearBidsParams, value?: bigint): Promise<{
|
|
55
|
+
opts: {
|
|
56
|
+
clearCount: number;
|
|
57
|
+
};
|
|
58
|
+
input: {
|
|
59
|
+
to: import("@ton/core").Address;
|
|
60
|
+
value: bigint;
|
|
61
|
+
body: Cell;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
@@ -0,0 +1,218 @@
|
|
|
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.createAmountBidMsg = createAmountBidMsg;
|
|
18
|
+
exports.createSlippageBidMsg = createSlippageBidMsg;
|
|
19
|
+
exports.createCancelBidMsg = createCancelBidMsg;
|
|
20
|
+
exports.createSettleMsg = createSettleMsg;
|
|
21
|
+
exports.createClearBidsMsg = createClearBidsMsg;
|
|
22
|
+
const core_1 = require("@ton/core");
|
|
23
|
+
const utils_1 = require("../../../contracts/common/utils");
|
|
24
|
+
const jetton_minter_1 = require("../../../contracts/jetton/jetton-minter");
|
|
25
|
+
const jetton_wallet_1 = require("../../../contracts/jetton/jetton-wallet");
|
|
26
|
+
const jetton_wallet_2 = require("../../../contracts/wton/jetton-wallet");
|
|
27
|
+
const jetton_minter_2 = require("../../../contracts/wton/jetton-minter");
|
|
28
|
+
const rfq_auction_1 = require("../../../contracts/rfq/rfq_auction");
|
|
29
|
+
const _compiled_1 = require("../../../_compiled");
|
|
30
|
+
const oracle_1 = require("../oracle");
|
|
31
|
+
const query_1 = require("../query");
|
|
32
|
+
__exportStar(require("./types"), exports);
|
|
33
|
+
// ============================================================
|
|
34
|
+
// Amount Bid
|
|
35
|
+
// ============================================================
|
|
36
|
+
async function createAmountBidMsg(ctx, sender, params, value) {
|
|
37
|
+
const rfqAuctionAddress = (0, utils_1.toAddress)(params.rfqAuctionAddress);
|
|
38
|
+
const bidAssetAddress = (0, utils_1.toAddress)(params.bidAsset);
|
|
39
|
+
const rfqData = await (0, query_1.getRFQData)(ctx, rfqAuctionAddress);
|
|
40
|
+
if (rfqData.config.auctionMode !== rfq_auction_1.RFQAuction.AuctionMode.AmountBid) {
|
|
41
|
+
throw new Error("Auction mode must be AmountBid.");
|
|
42
|
+
}
|
|
43
|
+
const existingBid = rfqData.bids[sender.address.toString()];
|
|
44
|
+
const maxEscrow = rfqData.config.maxBuyAssetValue;
|
|
45
|
+
const existingEscrow = existingBid?.escrowAmount ?? 0n;
|
|
46
|
+
const intendedBidAmount = params.intendedBidAmount > maxEscrow ? maxEscrow : params.intendedBidAmount;
|
|
47
|
+
const transferBidAmount = intendedBidAmount > existingEscrow ? intendedBidAmount - existingEscrow : 0n;
|
|
48
|
+
const sellAsset = (0, utils_1.toAddress)(rfqData.sellAssetAddress);
|
|
49
|
+
const isWTON = ctx.isWTON(sellAsset) || ctx.isWTON(bidAssetAddress);
|
|
50
|
+
const jettonForwardTonAmount = isWTON ? (0, core_1.toNano)(0.02) : 0n;
|
|
51
|
+
const jettonForwardPayload = isWTON ? jetton_minter_2.WTON_UNWRAP_CELL : null;
|
|
52
|
+
const forwardPayload = rfq_auction_1.RFQAuction.createBidMsg(intendedBidAmount, sender.address, jettonForwardTonAmount, jettonForwardPayload);
|
|
53
|
+
const forwardTonAmount = params.forwardTonAmount ?? (0, core_1.toNano)(0.2) + jettonForwardTonAmount;
|
|
54
|
+
const opts = {
|
|
55
|
+
recipient: rfqAuctionAddress,
|
|
56
|
+
response: sender.address,
|
|
57
|
+
amount: transferBidAmount,
|
|
58
|
+
forwardTonAmount,
|
|
59
|
+
forwardPayload,
|
|
60
|
+
queryId: params.queryId,
|
|
61
|
+
};
|
|
62
|
+
if (ctx.isWTON(bidAssetAddress)) {
|
|
63
|
+
const wtonMaster = ctx.getByContract(jetton_minter_2.WTONMinter, bidAssetAddress);
|
|
64
|
+
const wtonWallet = ctx.client.open(jetton_wallet_2.WTONWallet.createFromConfig({
|
|
65
|
+
jettonMinter: wtonMaster.address,
|
|
66
|
+
owner: rfqAuctionAddress,
|
|
67
|
+
walletCode: core_1.Cell.fromHex(_compiled_1.WTONWalletCompiled.hex),
|
|
68
|
+
}, core_1.Cell.fromHex(_compiled_1.WTONWalletCompiled.hex)));
|
|
69
|
+
let gas = jetton_wallet_2.WTONWallet.Gas.ExternalTransfer + (0, core_1.toNano)(0.1);
|
|
70
|
+
if (await ctx.client.isContractDeployed(wtonWallet.address)) {
|
|
71
|
+
gas += (0, core_1.toNano)(0.05);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
opts,
|
|
75
|
+
input: {
|
|
76
|
+
to: wtonWallet.address,
|
|
77
|
+
value: value ?? gas,
|
|
78
|
+
body: wtonWallet.createExternalTransferBody(opts),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const senderWalletAddress = await ctx
|
|
84
|
+
.getByContract(jetton_minter_1.JettonMinter, bidAssetAddress)
|
|
85
|
+
.getWalletAddress(sender.address);
|
|
86
|
+
const senderWallet = ctx.getByContract(jetton_wallet_1.JettonWallet, senderWalletAddress);
|
|
87
|
+
return {
|
|
88
|
+
opts,
|
|
89
|
+
input: {
|
|
90
|
+
to: senderWallet.address,
|
|
91
|
+
value: value ?? (0, core_1.toNano)(0.3),
|
|
92
|
+
body: senderWallet.createTransferBody(opts),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// ============================================================
|
|
98
|
+
// Slippage Bid
|
|
99
|
+
// ============================================================
|
|
100
|
+
async function createSlippageBidMsg(ctx, sender, params, value) {
|
|
101
|
+
const rfqAuctionAddress = (0, utils_1.toAddress)(params.rfqAuctionAddress);
|
|
102
|
+
const bidAssetAddress = (0, utils_1.toAddress)(params.bidAsset);
|
|
103
|
+
const rfqData = await (0, query_1.getRFQData)(ctx, rfqAuctionAddress);
|
|
104
|
+
if (rfqData.config.auctionMode !== rfq_auction_1.RFQAuction.AuctionMode.SlippageBid) {
|
|
105
|
+
throw new Error("Auction mode must be SlippageBid.");
|
|
106
|
+
}
|
|
107
|
+
if (params.slippage < 0) {
|
|
108
|
+
throw new Error("Slippage must not be negative in SlippageBid mode.");
|
|
109
|
+
}
|
|
110
|
+
const existingBid = rfqData.bids[sender.address.toString()];
|
|
111
|
+
const existingEscrow = existingBid?.escrowAmount ?? 0n;
|
|
112
|
+
const intendedBidAmount = params.intendedBidAmount > existingEscrow ? params.intendedBidAmount - existingEscrow : 0n;
|
|
113
|
+
const slippage = (0, core_1.toNano)(params.slippage);
|
|
114
|
+
const sellAsset = (0, utils_1.toAddress)(rfqData.sellAssetAddress);
|
|
115
|
+
const isWTON = ctx.isWTON(sellAsset) || ctx.isWTON(bidAssetAddress);
|
|
116
|
+
const jettonForwardTonAmount = isWTON ? (0, core_1.toNano)(0.02) : 0n;
|
|
117
|
+
const jettonForwardPayload = isWTON ? jetton_minter_2.WTON_UNWRAP_CELL : null;
|
|
118
|
+
const forwardPayload = rfq_auction_1.RFQAuction.createBidMsg(slippage, sender.address, jettonForwardTonAmount, jettonForwardPayload);
|
|
119
|
+
const forwardTonAmount = params.forwardTonAmount ?? (0, core_1.toNano)(0.2) + jettonForwardTonAmount;
|
|
120
|
+
const opts = {
|
|
121
|
+
recipient: rfqAuctionAddress,
|
|
122
|
+
response: sender.address,
|
|
123
|
+
amount: intendedBidAmount,
|
|
124
|
+
forwardTonAmount,
|
|
125
|
+
forwardPayload,
|
|
126
|
+
queryId: params.queryId,
|
|
127
|
+
};
|
|
128
|
+
if (ctx.isWTON(bidAssetAddress)) {
|
|
129
|
+
const wtonMaster = ctx.getByContract(jetton_minter_2.WTONMinter, bidAssetAddress);
|
|
130
|
+
const wtonWallet = ctx.client.open(jetton_wallet_2.WTONWallet.createFromConfig({
|
|
131
|
+
jettonMinter: wtonMaster.address,
|
|
132
|
+
owner: rfqAuctionAddress,
|
|
133
|
+
walletCode: core_1.Cell.fromHex(_compiled_1.WTONWalletCompiled.hex),
|
|
134
|
+
}, core_1.Cell.fromHex(_compiled_1.WTONWalletCompiled.hex)));
|
|
135
|
+
let gas = jetton_wallet_2.WTONWallet.Gas.ExternalTransfer + (0, core_1.toNano)(0.1);
|
|
136
|
+
if (await ctx.client.isContractDeployed(wtonWallet.address)) {
|
|
137
|
+
gas += (0, core_1.toNano)(0.05);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
opts,
|
|
141
|
+
input: {
|
|
142
|
+
to: wtonWallet.address,
|
|
143
|
+
value: value ?? gas,
|
|
144
|
+
body: wtonWallet.createExternalTransferBody(opts),
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const senderWalletAddress = await ctx
|
|
150
|
+
.getByContract(jetton_minter_1.JettonMinter, bidAssetAddress)
|
|
151
|
+
.getWalletAddress(sender.address);
|
|
152
|
+
const senderWallet = ctx.getByContract(jetton_wallet_1.JettonWallet, senderWalletAddress);
|
|
153
|
+
return {
|
|
154
|
+
opts,
|
|
155
|
+
input: {
|
|
156
|
+
to: senderWallet.address,
|
|
157
|
+
value: value ?? (0, core_1.toNano)(0.3),
|
|
158
|
+
body: senderWallet.createTransferBody(opts),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// ============================================================
|
|
164
|
+
// Cancel Bid
|
|
165
|
+
// ============================================================
|
|
166
|
+
async function createCancelBidMsg(ctx, params, value) {
|
|
167
|
+
const rfqAuction = ctx.getByContract(rfq_auction_1.RFQAuction, (0, utils_1.toAddress)(params.rfqAuctionAddress));
|
|
168
|
+
return {
|
|
169
|
+
opts: {},
|
|
170
|
+
input: {
|
|
171
|
+
to: rfqAuction.address,
|
|
172
|
+
value: value ?? (0, core_1.toNano)(0.1),
|
|
173
|
+
body: (0, core_1.beginCell)()
|
|
174
|
+
.storeUint(rfq_auction_1.RFQAuction.Op.CancelBid, 32)
|
|
175
|
+
.storeUint(params.queryId ?? 0, 64)
|
|
176
|
+
.endCell(),
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// ============================================================
|
|
181
|
+
// Settle
|
|
182
|
+
// ============================================================
|
|
183
|
+
async function createSettleMsg(ctx, params, value) {
|
|
184
|
+
const rfqAuctionAddress = (0, utils_1.toAddress)(params.rfqAuctionAddress);
|
|
185
|
+
const oracleParams = await (0, oracle_1.getOracleParamsForAuction)(ctx, rfqAuctionAddress);
|
|
186
|
+
const rfqAuction = ctx.getByContract(rfq_auction_1.RFQAuction, rfqAuctionAddress);
|
|
187
|
+
return {
|
|
188
|
+
opts: { oracleParams },
|
|
189
|
+
input: {
|
|
190
|
+
to: rfqAuction.address,
|
|
191
|
+
value: value ?? (0, core_1.toNano)(1),
|
|
192
|
+
body: (0, core_1.beginCell)()
|
|
193
|
+
.storeUint(rfq_auction_1.RFQAuction.Op.Settle, 32)
|
|
194
|
+
.storeUint(params.queryId ?? 0, 64)
|
|
195
|
+
.storeRef(oracleParams)
|
|
196
|
+
.endCell(),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// ============================================================
|
|
201
|
+
// Clear Bids
|
|
202
|
+
// ============================================================
|
|
203
|
+
async function createClearBidsMsg(ctx, params, value) {
|
|
204
|
+
const rfqAuction = ctx.getByContract(rfq_auction_1.RFQAuction, (0, utils_1.toAddress)(params.rfqAuctionAddress));
|
|
205
|
+
const fee = value ?? (0, core_1.toNano)(0.005 * params.clearCount) + (0, core_1.toNano)(0.1);
|
|
206
|
+
return {
|
|
207
|
+
opts: { clearCount: params.clearCount },
|
|
208
|
+
input: {
|
|
209
|
+
to: rfqAuction.address,
|
|
210
|
+
value: fee,
|
|
211
|
+
body: (0, core_1.beginCell)()
|
|
212
|
+
.storeUint(rfq_auction_1.RFQAuction.Op.ClearBids, 32)
|
|
213
|
+
.storeUint(params.queryId ?? 0, 64)
|
|
214
|
+
.storeUint(params.clearCount, 8)
|
|
215
|
+
.endCell(),
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|