@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,216 @@
|
|
|
1
|
+
import { Address, Builder, Cell, Contract, ContractProvider, Sender, Slice } from "@ton/core";
|
|
2
|
+
export type RFQActionConfig = {
|
|
3
|
+
requesterAddress: Address;
|
|
4
|
+
index: number;
|
|
5
|
+
};
|
|
6
|
+
export type RFQAuctionInitializeConfig = {
|
|
7
|
+
sellAssetAddress: Address;
|
|
8
|
+
buyAssetAddress: Address;
|
|
9
|
+
sellAssetAmount: bigint;
|
|
10
|
+
config: {
|
|
11
|
+
auctionMode: number;
|
|
12
|
+
bidCloseTimestamp: number;
|
|
13
|
+
minBuyAssetValue: bigint;
|
|
14
|
+
maxBuyAssetValue: bigint;
|
|
15
|
+
allowSellerCancel: boolean;
|
|
16
|
+
allowBidderCancel: boolean;
|
|
17
|
+
priceDeviationTolerance: number;
|
|
18
|
+
};
|
|
19
|
+
sellAssetWalletAddress: Address;
|
|
20
|
+
buyAssetWalletAddress: Address;
|
|
21
|
+
rfqEventEmitterAddress: Address;
|
|
22
|
+
dataAggregatorCode: Cell;
|
|
23
|
+
oracleConfig?: Cell | null;
|
|
24
|
+
responseAddress: Address;
|
|
25
|
+
jettonForwardTonAmount?: bigint;
|
|
26
|
+
jettonForwardPayload?: Cell | null;
|
|
27
|
+
rfqNotiForwardTonAmount?: bigint;
|
|
28
|
+
rfqNotiForwardPayload?: Cell | null;
|
|
29
|
+
};
|
|
30
|
+
export declare class RFQAuction implements Contract {
|
|
31
|
+
readonly address: Address;
|
|
32
|
+
readonly init?: {
|
|
33
|
+
code: Cell;
|
|
34
|
+
data: Cell;
|
|
35
|
+
} | undefined;
|
|
36
|
+
constructor(address: Address, init?: {
|
|
37
|
+
code: Cell;
|
|
38
|
+
data: Cell;
|
|
39
|
+
} | undefined);
|
|
40
|
+
static State: {
|
|
41
|
+
Active: number;
|
|
42
|
+
Closed: number;
|
|
43
|
+
VerifiedAllAssetWallet: number;
|
|
44
|
+
VerifiedOnlySellAssetWallet: number;
|
|
45
|
+
VerifiedOnlyBuyAssetWallet: number;
|
|
46
|
+
Bidable: number;
|
|
47
|
+
Open: number;
|
|
48
|
+
Success: number;
|
|
49
|
+
Failure: number;
|
|
50
|
+
};
|
|
51
|
+
static AuctionMode: {
|
|
52
|
+
AmountBid: number;
|
|
53
|
+
SlippageBid: number;
|
|
54
|
+
};
|
|
55
|
+
static Constants: {
|
|
56
|
+
MIN_STORAGE_FEE: bigint;
|
|
57
|
+
BID_FEE: bigint;
|
|
58
|
+
SETTLE_FEE: bigint;
|
|
59
|
+
JETTON_TRANSFER_FEE: bigint;
|
|
60
|
+
RFQ_EVENT_EMITTER_FEE: bigint;
|
|
61
|
+
};
|
|
62
|
+
static Op: {
|
|
63
|
+
Initialize: number;
|
|
64
|
+
Settle: number;
|
|
65
|
+
Deposit: number;
|
|
66
|
+
Bid: number;
|
|
67
|
+
RFQNotification: number;
|
|
68
|
+
CancelRFQ: number;
|
|
69
|
+
CancelBid: number;
|
|
70
|
+
ClearBids: number;
|
|
71
|
+
VerifiedWallet: number;
|
|
72
|
+
};
|
|
73
|
+
static Error: {
|
|
74
|
+
UnknownOp: number;
|
|
75
|
+
CellUnderflow: number;
|
|
76
|
+
Unauthorized: number;
|
|
77
|
+
InvalidAsset: number;
|
|
78
|
+
InvalidBalance: number;
|
|
79
|
+
InvalidState: number;
|
|
80
|
+
AlreadyDeposited: number;
|
|
81
|
+
AlreadyBid: number;
|
|
82
|
+
BidClosed: number;
|
|
83
|
+
InvalidMinBuyAssetValue: number;
|
|
84
|
+
InvalidImmediateExecutionBuyAssetValue: number;
|
|
85
|
+
PeriodNotOverYet: number;
|
|
86
|
+
InvalidAssetAmount: number;
|
|
87
|
+
NotDepositable: number;
|
|
88
|
+
InvalidAssetWallet: number;
|
|
89
|
+
NotBidable: number;
|
|
90
|
+
NotSettleableState: number;
|
|
91
|
+
NoBids: number;
|
|
92
|
+
BidNotClosed: number;
|
|
93
|
+
BidValueTooLow: number;
|
|
94
|
+
BidValueTooHigh: number;
|
|
95
|
+
InvalidStorage: number;
|
|
96
|
+
InvalidInitState: number;
|
|
97
|
+
InvalidInitVerifiedSellWallet: number;
|
|
98
|
+
InvalidInitVerifiedBuyWallet: number;
|
|
99
|
+
InvalidInitDepositedSellAsset: number;
|
|
100
|
+
InvalidInitBids: number;
|
|
101
|
+
NotEnoughTon: number;
|
|
102
|
+
UnverifiedBuyAssetWallet: number;
|
|
103
|
+
UnverifiedSellAssetWallet: number;
|
|
104
|
+
NotDepositedSellAsset: number;
|
|
105
|
+
NotOpenState: number;
|
|
106
|
+
ExistBids: number;
|
|
107
|
+
NotAllowBidderCancel: number;
|
|
108
|
+
NotFoundBid: number;
|
|
109
|
+
CountTooLarge: number;
|
|
110
|
+
OpenedAuction: number;
|
|
111
|
+
NotFoundAssetPrice: number;
|
|
112
|
+
NotFoundPrice: number;
|
|
113
|
+
};
|
|
114
|
+
static computeBidReserveFee(forwardTonAmount: bigint, isFirstBid: boolean): bigint;
|
|
115
|
+
static computeSellReserveFee(forwardTonAmount: bigint, rfqNotiForwardTonAmount: bigint): bigint;
|
|
116
|
+
static createFromAddress(address: Address): RFQAuction;
|
|
117
|
+
static createFromConfig(config: RFQActionConfig, code: Cell, workchain?: number): RFQAuction;
|
|
118
|
+
sendDeploy(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
119
|
+
static createInitializeMsg(config: RFQAuctionInitializeConfig): Cell;
|
|
120
|
+
sendInitialize(provider: ContractProvider, via: Sender, value: bigint, config: RFQAuctionInitializeConfig): Promise<void>;
|
|
121
|
+
static createDepositMsg(): Cell;
|
|
122
|
+
static createBidMsg(bidValue: bigint, responseAddress: Address, jettonForwardTonAmount?: bigint, jettonForwardPayload?: Cell | null): Cell;
|
|
123
|
+
sendDeposit(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
124
|
+
sendSetEventEmitterForTesting(provider: ContractProvider, via: Sender, value: bigint, eventEmitterAddress: Address): Promise<void>;
|
|
125
|
+
sendMsgBody(provider: ContractProvider, via: Sender, value: bigint, body: Cell): Promise<void>;
|
|
126
|
+
sendSettle(provider: ContractProvider, via: Sender, value: bigint, { oracleParams, }: {
|
|
127
|
+
oracleParams: Cell;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
sendCancelRFQ(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
130
|
+
sendCancelBid(provider: ContractProvider, via: Sender, value: bigint): Promise<void>;
|
|
131
|
+
sendClearBids(provider: ContractProvider, via: Sender, value: bigint, count: number): Promise<void>;
|
|
132
|
+
static Dictionary: {
|
|
133
|
+
Values: {
|
|
134
|
+
Bid: () => {
|
|
135
|
+
serialize: (src: Bid, builder: Builder) => void;
|
|
136
|
+
parse: (src: Slice) => Bid;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
static parseRFQStorage(dataCell: Cell): {
|
|
141
|
+
initialized: boolean;
|
|
142
|
+
index: bigint;
|
|
143
|
+
state: number;
|
|
144
|
+
sellerAddress: Address;
|
|
145
|
+
verifiedSellWallet: boolean;
|
|
146
|
+
verifiedBuyWallet: boolean;
|
|
147
|
+
depositedSellAsset: boolean;
|
|
148
|
+
bids: Record<string, Bid>;
|
|
149
|
+
sellAssetAddress: Address;
|
|
150
|
+
buyAssetAddress: Address;
|
|
151
|
+
sellAssetAmount: bigint;
|
|
152
|
+
config: {
|
|
153
|
+
auctionMode: number;
|
|
154
|
+
bidCloseTimestamp: number;
|
|
155
|
+
minBuyAssetValue: bigint;
|
|
156
|
+
maxBuyAssetValue: bigint;
|
|
157
|
+
allowSellerCancel: boolean;
|
|
158
|
+
allowBidderCancel: boolean;
|
|
159
|
+
priceDeviationTolerance: bigint;
|
|
160
|
+
};
|
|
161
|
+
sellAssetWalletAddress: Address | null;
|
|
162
|
+
buyAssetWalletAddress: Address | null;
|
|
163
|
+
rfqEventEmitterAddress: Address | null;
|
|
164
|
+
dataAggregatorCodeHash: string | null;
|
|
165
|
+
dataAggregatorIndex: bigint;
|
|
166
|
+
oracleConfig: Cell | import("../../oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
167
|
+
jettonForwardTonAmount: bigint;
|
|
168
|
+
jettonForwardPayloadHash: string | null;
|
|
169
|
+
responseAddress: Address;
|
|
170
|
+
rfqNotiForwardTonAmount: bigint;
|
|
171
|
+
rfqNotiForwardPayloadHash: string | null;
|
|
172
|
+
};
|
|
173
|
+
getRFQData(provider: ContractProvider): Promise<{
|
|
174
|
+
initialized: boolean;
|
|
175
|
+
index: bigint;
|
|
176
|
+
state: number;
|
|
177
|
+
sellerAddress: Address;
|
|
178
|
+
verifiedSellWallet: boolean;
|
|
179
|
+
verifiedBuyWallet: boolean;
|
|
180
|
+
depositedSellAsset: boolean;
|
|
181
|
+
bids: Record<string, Bid>;
|
|
182
|
+
sellAssetAddress: Address;
|
|
183
|
+
buyAssetAddress: Address;
|
|
184
|
+
sellAssetAmount: bigint;
|
|
185
|
+
config: {
|
|
186
|
+
auctionMode: number;
|
|
187
|
+
bidCloseTimestamp: number;
|
|
188
|
+
minBuyAssetValue: bigint;
|
|
189
|
+
maxBuyAssetValue: bigint;
|
|
190
|
+
allowSellerCancel: boolean;
|
|
191
|
+
allowBidderCancel: boolean;
|
|
192
|
+
priceDeviationTolerance: bigint;
|
|
193
|
+
};
|
|
194
|
+
sellAssetWalletAddress: Address | null;
|
|
195
|
+
buyAssetWalletAddress: Address | null;
|
|
196
|
+
rfqEventEmitterAddress: Address | null;
|
|
197
|
+
dataAggregatorCodeHash: string | null;
|
|
198
|
+
dataAggregatorIndex: bigint;
|
|
199
|
+
oracleConfig: Cell | import("../../oracle/redstone-onchain-oracle/type").RedstoneOnchainOracleConfig | import("../../oracle/redstone-oracle/type").RedstonOracleConfig | null;
|
|
200
|
+
jettonForwardTonAmount: bigint;
|
|
201
|
+
jettonForwardPayloadHash: string | null;
|
|
202
|
+
responseAddress: Address;
|
|
203
|
+
rfqNotiForwardTonAmount: bigint;
|
|
204
|
+
rfqNotiForwardPayloadHash: string | null;
|
|
205
|
+
}>;
|
|
206
|
+
getState(provider: ContractProvider): Promise<import("@ton/core").ContractState>;
|
|
207
|
+
}
|
|
208
|
+
type Bid = {
|
|
209
|
+
bidValue: bigint;
|
|
210
|
+
escrowAmount: bigint;
|
|
211
|
+
lt: bigint;
|
|
212
|
+
responseAddress: Address;
|
|
213
|
+
forwardTonAmount: bigint;
|
|
214
|
+
forwardPayload: string | null;
|
|
215
|
+
};
|
|
216
|
+
export {};
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RFQAuction = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
const parser_1 = require("../../oracle/parser");
|
|
6
|
+
class RFQAuction {
|
|
7
|
+
address;
|
|
8
|
+
init;
|
|
9
|
+
constructor(address, init) {
|
|
10
|
+
this.address = address;
|
|
11
|
+
this.init = init;
|
|
12
|
+
}
|
|
13
|
+
static State = {
|
|
14
|
+
Active: 0,
|
|
15
|
+
Closed: 1,
|
|
16
|
+
VerifiedAllAssetWallet: 3,
|
|
17
|
+
VerifiedOnlySellAssetWallet: 1,
|
|
18
|
+
VerifiedOnlyBuyAssetWallet: 2,
|
|
19
|
+
Bidable: 7,
|
|
20
|
+
Open: 0,
|
|
21
|
+
Success: 1,
|
|
22
|
+
Failure: 2,
|
|
23
|
+
};
|
|
24
|
+
static AuctionMode = {
|
|
25
|
+
AmountBid: 0,
|
|
26
|
+
SlippageBid: 1,
|
|
27
|
+
};
|
|
28
|
+
static Constants = {
|
|
29
|
+
MIN_STORAGE_FEE: (0, core_1.toNano)("0.01"),
|
|
30
|
+
BID_FEE: (0, core_1.toNano)("0.04"),
|
|
31
|
+
SETTLE_FEE: (0, core_1.toNano)("0.01"),
|
|
32
|
+
JETTON_TRANSFER_FEE: (0, core_1.toNano)("0.06"),
|
|
33
|
+
RFQ_EVENT_EMITTER_FEE: (0, core_1.toNano)("0.02"),
|
|
34
|
+
};
|
|
35
|
+
static Op = {
|
|
36
|
+
Initialize: 0xbe5a7595,
|
|
37
|
+
Settle: 0xb48a809e,
|
|
38
|
+
Deposit: 0xf9471134,
|
|
39
|
+
Bid: 0x2a043cb0,
|
|
40
|
+
RFQNotification: 0xeb27e847,
|
|
41
|
+
CancelRFQ: 0x5f6f17e0,
|
|
42
|
+
CancelBid: 0xa90c4cb4,
|
|
43
|
+
ClearBids: 0x528d62fe,
|
|
44
|
+
VerifiedWallet: 0xb97c1901,
|
|
45
|
+
};
|
|
46
|
+
static Error = {
|
|
47
|
+
UnknownOp: 0xffff,
|
|
48
|
+
CellUnderflow: 9,
|
|
49
|
+
Unauthorized: 1000,
|
|
50
|
+
InvalidAsset: 1001,
|
|
51
|
+
InvalidBalance: 1002,
|
|
52
|
+
InvalidState: 1003,
|
|
53
|
+
AlreadyDeposited: 1004,
|
|
54
|
+
AlreadyBid: 1005,
|
|
55
|
+
BidClosed: 1006,
|
|
56
|
+
InvalidMinBuyAssetValue: 1007,
|
|
57
|
+
InvalidImmediateExecutionBuyAssetValue: 1008,
|
|
58
|
+
PeriodNotOverYet: 1009,
|
|
59
|
+
InvalidAssetAmount: 1010,
|
|
60
|
+
NotDepositable: 1011,
|
|
61
|
+
InvalidAssetWallet: 1012,
|
|
62
|
+
NotBidable: 1013,
|
|
63
|
+
NotSettleableState: 1015,
|
|
64
|
+
NoBids: 1016,
|
|
65
|
+
BidNotClosed: 1017,
|
|
66
|
+
BidValueTooLow: 1019,
|
|
67
|
+
BidValueTooHigh: 1020,
|
|
68
|
+
InvalidStorage: 0x2000,
|
|
69
|
+
InvalidInitState: 1021,
|
|
70
|
+
InvalidInitVerifiedSellWallet: 1022,
|
|
71
|
+
InvalidInitVerifiedBuyWallet: 1023,
|
|
72
|
+
InvalidInitDepositedSellAsset: 1024,
|
|
73
|
+
InvalidInitBids: 1025,
|
|
74
|
+
NotEnoughTon: 1026,
|
|
75
|
+
UnverifiedBuyAssetWallet: 1027,
|
|
76
|
+
UnverifiedSellAssetWallet: 1028,
|
|
77
|
+
NotDepositedSellAsset: 1029,
|
|
78
|
+
NotOpenState: 1030,
|
|
79
|
+
ExistBids: 1031,
|
|
80
|
+
NotAllowBidderCancel: 1032,
|
|
81
|
+
NotFoundBid: 1033,
|
|
82
|
+
CountTooLarge: 1034,
|
|
83
|
+
OpenedAuction: 1035,
|
|
84
|
+
NotFoundAssetPrice: 9999,
|
|
85
|
+
NotFoundPrice: 7300,
|
|
86
|
+
};
|
|
87
|
+
static computeBidReserveFee(forwardTonAmount, isFirstBid) {
|
|
88
|
+
let reserveFee = forwardTonAmount * 2n;
|
|
89
|
+
if (isFirstBid) {
|
|
90
|
+
reserveFee += RFQAuction.Constants.SETTLE_FEE + RFQAuction.Constants.JETTON_TRANSFER_FEE * 2n;
|
|
91
|
+
}
|
|
92
|
+
return reserveFee;
|
|
93
|
+
}
|
|
94
|
+
static computeSellReserveFee(forwardTonAmount, rfqNotiForwardTonAmount) {
|
|
95
|
+
return (forwardTonAmount +
|
|
96
|
+
RFQAuction.Constants.JETTON_TRANSFER_FEE +
|
|
97
|
+
RFQAuction.Constants.MIN_STORAGE_FEE +
|
|
98
|
+
rfqNotiForwardTonAmount);
|
|
99
|
+
}
|
|
100
|
+
static createFromAddress(address) {
|
|
101
|
+
return new RFQAuction(address);
|
|
102
|
+
}
|
|
103
|
+
static createFromConfig(config, code, workchain = 0) {
|
|
104
|
+
const data = (0, core_1.beginCell)()
|
|
105
|
+
.storeUint(0, 1) // initialized
|
|
106
|
+
.storeAddress(config.requesterAddress)
|
|
107
|
+
.storeCoins(config.index)
|
|
108
|
+
.endCell();
|
|
109
|
+
const init = { code, data };
|
|
110
|
+
return new RFQAuction((0, core_1.contractAddress)(workchain, init), init);
|
|
111
|
+
}
|
|
112
|
+
async sendDeploy(provider, via, value) {
|
|
113
|
+
await provider.internal(via, {
|
|
114
|
+
value,
|
|
115
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
116
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.Initialize, 32).endCell(),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
static createInitializeMsg(config) {
|
|
120
|
+
return (0, core_1.beginCell)()
|
|
121
|
+
.storeUint(RFQAuction.Op.Initialize, 32) // [op]
|
|
122
|
+
.storeUint(0, 64) // [query_id]
|
|
123
|
+
.storeUint(0, 4) // 3: state
|
|
124
|
+
.storeUint(0, 1) // 4: verified_sell_wallet
|
|
125
|
+
.storeUint(0, 1) // 5: verified_buy_wallet
|
|
126
|
+
.storeUint(0, 1) // 6: deposited_sell_asset
|
|
127
|
+
.storeMaybeRef(null) // 7: bids
|
|
128
|
+
.storeAddress(config.sellAssetAddress) // 8: sell_asset_address
|
|
129
|
+
.storeAddress(config.buyAssetAddress) // 9: buy_asset_address
|
|
130
|
+
.storeCoins(config.sellAssetAmount) // 10: sell_asset_amount
|
|
131
|
+
.storeRef((0, core_1.beginCell)()
|
|
132
|
+
.storeUint(config.config.auctionMode, 4) // 11: auction_mode
|
|
133
|
+
.storeUint(config.config.bidCloseTimestamp, 40) // 12: bid_close_timestamp
|
|
134
|
+
.storeCoins(config.config.minBuyAssetValue) // 13: min_buy_asset_value
|
|
135
|
+
.storeCoins(config.config.maxBuyAssetValue) // 14: max_buy_asset_value
|
|
136
|
+
.storeBit(config.config.allowSellerCancel) // 15: allow_seller_cancel
|
|
137
|
+
.storeBit(config.config.allowBidderCancel) // 16: allow_bidder_cancel
|
|
138
|
+
.storeCoins(config.config.priceDeviationTolerance) // 17: price_deviation_tolerance
|
|
139
|
+
.endCell())
|
|
140
|
+
.storeRef((0, core_1.beginCell)()
|
|
141
|
+
.storeAddress(config.sellAssetWalletAddress) // 18: sell_asset_wallet_address
|
|
142
|
+
.storeAddress(config.buyAssetWalletAddress) // 19: buy_asset_wallet_address
|
|
143
|
+
.storeAddress(config.rfqEventEmitterAddress) // 20: rfq_event_emiter_address
|
|
144
|
+
.storeRef(config.dataAggregatorCode) // 21: data_aggregator_code
|
|
145
|
+
.storeCoins(0) // 22: data_aggregator_index
|
|
146
|
+
.storeMaybeRef(config.oracleConfig) // 23: oracle_config
|
|
147
|
+
.endCell())
|
|
148
|
+
.storeRef((0, core_1.beginCell)()
|
|
149
|
+
.storeAddress(config.responseAddress)
|
|
150
|
+
.storeCoins(config.jettonForwardTonAmount ?? 0n)
|
|
151
|
+
.storeMaybeRef(config.jettonForwardPayload)
|
|
152
|
+
.storeCoins(config.rfqNotiForwardTonAmount ?? 0n)
|
|
153
|
+
.storeMaybeRef(config.rfqNotiForwardPayload))
|
|
154
|
+
.endCell();
|
|
155
|
+
}
|
|
156
|
+
async sendInitialize(provider, via, value, config) {
|
|
157
|
+
await provider.internal(via, {
|
|
158
|
+
value,
|
|
159
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
160
|
+
body: RFQAuction.createInitializeMsg(config),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
static createDepositMsg() {
|
|
164
|
+
return (0, core_1.beginCell)().storeUint(RFQAuction.Op.Deposit, 32).endCell();
|
|
165
|
+
}
|
|
166
|
+
static createBidMsg(bidValue, responseAddress, jettonForwardTonAmount = 0n, jettonForwardPayload = null) {
|
|
167
|
+
return (0, core_1.beginCell)()
|
|
168
|
+
.storeUint(RFQAuction.Op.Bid, 32)
|
|
169
|
+
.storeCoins(bidValue)
|
|
170
|
+
.storeAddress(responseAddress)
|
|
171
|
+
.storeCoins(jettonForwardTonAmount)
|
|
172
|
+
.storeMaybeRef(jettonForwardPayload)
|
|
173
|
+
.endCell();
|
|
174
|
+
}
|
|
175
|
+
async sendDeposit(provider, via, value) {
|
|
176
|
+
await provider.internal(via, {
|
|
177
|
+
value,
|
|
178
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
179
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.Deposit, 32).storeUint(0, 64).endCell(),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async sendSetEventEmitterForTesting(provider, via, value, eventEmitterAddress) {
|
|
183
|
+
await provider.internal(via, {
|
|
184
|
+
value,
|
|
185
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
186
|
+
body: (0, core_1.beginCell)().storeUint(0x123123, 32).storeUint(0, 64).storeAddress(eventEmitterAddress).endCell(),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async sendMsgBody(provider, via, value, body) {
|
|
190
|
+
await provider.internal(via, {
|
|
191
|
+
value,
|
|
192
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
193
|
+
body: body,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async sendSettle(provider, via, value, { oracleParams, }) {
|
|
197
|
+
await provider.internal(via, {
|
|
198
|
+
value,
|
|
199
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
200
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.Settle, 32).storeUint(0, 64).storeMaybeRef(oracleParams).endCell(),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async sendCancelRFQ(provider, via, value) {
|
|
204
|
+
await provider.internal(via, {
|
|
205
|
+
value,
|
|
206
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
207
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.CancelRFQ, 32).storeUint(0, 64).endCell(),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
async sendCancelBid(provider, via, value) {
|
|
211
|
+
await provider.internal(via, {
|
|
212
|
+
value,
|
|
213
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
214
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.CancelBid, 32).storeUint(0, 64).endCell(),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
async sendClearBids(provider, via, value, count) {
|
|
218
|
+
await provider.internal(via, {
|
|
219
|
+
value,
|
|
220
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
221
|
+
body: (0, core_1.beginCell)().storeUint(RFQAuction.Op.ClearBids, 32).storeUint(0, 64).storeCoins(count).endCell(),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
static Dictionary = {
|
|
225
|
+
Values: {
|
|
226
|
+
Bid: () => ({
|
|
227
|
+
serialize: (src, builder) => { },
|
|
228
|
+
parse: (src) => {
|
|
229
|
+
const bidValue = src.loadCoins();
|
|
230
|
+
const escrowAmount = src.loadCoins();
|
|
231
|
+
const lt = src.loadUintBig(256);
|
|
232
|
+
const responseAddress = src.loadAddress();
|
|
233
|
+
const forwardTonAmount = src.loadCoins();
|
|
234
|
+
const forwardPayload = src.loadMaybeRef();
|
|
235
|
+
return {
|
|
236
|
+
bidValue,
|
|
237
|
+
escrowAmount,
|
|
238
|
+
lt,
|
|
239
|
+
responseAddress,
|
|
240
|
+
forwardTonAmount,
|
|
241
|
+
forwardPayload: forwardPayload ? forwardPayload.hash().toString("hex") : null,
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
static parseRFQStorage(dataCell) {
|
|
248
|
+
const data = dataCell.beginParse();
|
|
249
|
+
const initialized = data.loadBoolean();
|
|
250
|
+
const sellerAddress = data.loadAddress();
|
|
251
|
+
const index = data.loadCoins();
|
|
252
|
+
const state = data.loadUint(4);
|
|
253
|
+
const verifiedSellWallet = data.loadBoolean();
|
|
254
|
+
const verifiedBuyWallet = data.loadBoolean();
|
|
255
|
+
const depositedSellAsset = data.loadBoolean();
|
|
256
|
+
const _bids = data.loadMaybeRef();
|
|
257
|
+
let bids = {};
|
|
258
|
+
if (_bids) {
|
|
259
|
+
const __bids = _bids.beginParse().loadDictDirect(core_1.Dictionary.Keys.Address(), RFQAuction.Dictionary.Values.Bid());
|
|
260
|
+
__bids.keys().forEach((key) => {
|
|
261
|
+
const bid = __bids.get(key);
|
|
262
|
+
if (bid) {
|
|
263
|
+
bids[key.toString()] = bid;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const sellAssetAddress = data.loadAddress();
|
|
268
|
+
const buyAssetAddress = data.loadAddress();
|
|
269
|
+
const sellAssetAmount = data.loadCoins();
|
|
270
|
+
const _config = data.loadRef().beginParse();
|
|
271
|
+
const config = {
|
|
272
|
+
auctionMode: _config.loadUint(4),
|
|
273
|
+
bidCloseTimestamp: _config.loadUint(40),
|
|
274
|
+
minBuyAssetValue: _config.loadCoins(),
|
|
275
|
+
maxBuyAssetValue: _config.loadCoins(),
|
|
276
|
+
allowSellerCancel: _config.loadBit(),
|
|
277
|
+
allowBidderCancel: _config.loadBit(),
|
|
278
|
+
priceDeviationTolerance: _config.loadCoins(),
|
|
279
|
+
};
|
|
280
|
+
const additional1CS = data.loadRef().beginParse();
|
|
281
|
+
const sellAssetWalletAddress = additional1CS.loadMaybeAddress();
|
|
282
|
+
const buyAssetWalletAddress = additional1CS.loadMaybeAddress();
|
|
283
|
+
const rfqEventEmitterAddress = additional1CS.loadMaybeAddress();
|
|
284
|
+
const dataAggregatorCode = additional1CS.loadRef();
|
|
285
|
+
const dataAggregatorIndex = additional1CS.loadCoins();
|
|
286
|
+
const oracleConfigRaw = additional1CS.loadMaybeRef();
|
|
287
|
+
const oracleConfig = oracleConfigRaw ? (0, parser_1.parseOracleConfig)(oracleConfigRaw) : null;
|
|
288
|
+
const forwardPayloadCS = data.loadRef().beginParse();
|
|
289
|
+
const responseAddress = forwardPayloadCS.loadAddress();
|
|
290
|
+
const jettonForwardTonAmount = forwardPayloadCS.loadCoins();
|
|
291
|
+
const jettonForwardPayload = forwardPayloadCS.loadMaybeRef();
|
|
292
|
+
const rfqNotiForwardTonAmount = forwardPayloadCS.loadCoins();
|
|
293
|
+
const rfqNotiForwardPayload = forwardPayloadCS.loadMaybeRef();
|
|
294
|
+
return {
|
|
295
|
+
initialized,
|
|
296
|
+
index,
|
|
297
|
+
state,
|
|
298
|
+
sellerAddress,
|
|
299
|
+
verifiedSellWallet,
|
|
300
|
+
verifiedBuyWallet,
|
|
301
|
+
depositedSellAsset,
|
|
302
|
+
bids,
|
|
303
|
+
sellAssetAddress,
|
|
304
|
+
buyAssetAddress,
|
|
305
|
+
sellAssetAmount,
|
|
306
|
+
config,
|
|
307
|
+
sellAssetWalletAddress,
|
|
308
|
+
buyAssetWalletAddress,
|
|
309
|
+
rfqEventEmitterAddress,
|
|
310
|
+
dataAggregatorCodeHash: dataAggregatorCode ? dataAggregatorCode.hash().toString("hex") : null,
|
|
311
|
+
dataAggregatorIndex,
|
|
312
|
+
oracleConfig: oracleConfig,
|
|
313
|
+
jettonForwardTonAmount,
|
|
314
|
+
jettonForwardPayloadHash: jettonForwardPayload ? jettonForwardPayload.hash().toString("hex") : null,
|
|
315
|
+
responseAddress,
|
|
316
|
+
rfqNotiForwardTonAmount,
|
|
317
|
+
rfqNotiForwardPayloadHash: rfqNotiForwardPayload ? rfqNotiForwardPayload.hash().toString("hex") : null,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
async getRFQData(provider) {
|
|
321
|
+
const _state = await provider.getState();
|
|
322
|
+
if (_state.state.type !== "active")
|
|
323
|
+
throw "not active";
|
|
324
|
+
if (!_state.state.data)
|
|
325
|
+
throw "not active";
|
|
326
|
+
const data = core_1.Cell.fromBoc(_state.state.data)[0];
|
|
327
|
+
return RFQAuction.parseRFQStorage(data);
|
|
328
|
+
}
|
|
329
|
+
async getState(provider) {
|
|
330
|
+
const _state = await provider.getState();
|
|
331
|
+
return _state;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
exports.RFQAuction = RFQAuction;
|