@ember-finance/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/LICENSE +201 -0
- package/README.md +102 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/src/common/types.d.ts +1 -0
- package/dist/src/common/types.js +2 -0
- package/dist/src/vaults/bluefin-vaults.d.ts +15 -0
- package/dist/src/vaults/bluefin-vaults.js +19 -0
- package/dist/src/vaults/interfaces/bcs.d.ts +29 -0
- package/dist/src/vaults/interfaces/bcs.js +18 -0
- package/dist/src/vaults/interfaces/index.d.ts +82 -0
- package/dist/src/vaults/interfaces/index.js +2 -0
- package/dist/src/vaults/on-chain-calls/admin.d.ts +88 -0
- package/dist/src/vaults/on-chain-calls/admin.js +144 -0
- package/dist/src/vaults/on-chain-calls/index.d.ts +6 -0
- package/dist/src/vaults/on-chain-calls/index.js +22 -0
- package/dist/src/vaults/on-chain-calls/onchain-calls.d.ts +34 -0
- package/dist/src/vaults/on-chain-calls/onchain-calls.js +53 -0
- package/dist/src/vaults/on-chain-calls/operator.d.ts +74 -0
- package/dist/src/vaults/on-chain-calls/operator.js +136 -0
- package/dist/src/vaults/on-chain-calls/tx-builder.d.ts +252 -0
- package/dist/src/vaults/on-chain-calls/tx-builder.js +805 -0
- package/dist/src/vaults/on-chain-calls/user.d.ts +47 -0
- package/dist/src/vaults/on-chain-calls/user.js +114 -0
- package/dist/src/vaults/on-chain-calls/vault-admin.d.ts +64 -0
- package/dist/src/vaults/on-chain-calls/vault-admin.js +114 -0
- package/dist/src/vaults/on-chain-calls/vault.d.ts +42 -0
- package/dist/src/vaults/on-chain-calls/vault.js +79 -0
- package/dist/src/vaults/utils/common.d.ts +2 -0
- package/dist/src/vaults/utils/common.js +8 -0
- package/dist/src/vaults/utils/deployment-parser.d.ts +13 -0
- package/dist/src/vaults/utils/deployment-parser.js +49 -0
- package/dist/src/vaults/utils/index.d.ts +2 -0
- package/dist/src/vaults/utils/index.js +18 -0
- package/package.json +79 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminCalls = void 0;
|
|
4
|
+
const onchain_calls_1 = require("./onchain-calls");
|
|
5
|
+
const library_sui_1 = require("@firefly-exchange/library-sui");
|
|
6
|
+
class AdminCalls extends onchain_calls_1.OnChainCalls {
|
|
7
|
+
constructor(_network, _suiClient, _deployment, _signer, _walletAddress) {
|
|
8
|
+
super(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create and executes create vault transaction. Allows admin to create a new vault on
|
|
12
|
+
* the protocol
|
|
13
|
+
* @param depositCoinType The type of the deposit coin
|
|
14
|
+
* @param receiptCoinType The type of the receipt coin
|
|
15
|
+
* @param vaultName Name of the vault
|
|
16
|
+
* @param adminAddress The admin address of the vault
|
|
17
|
+
* @param operatorAddress The operator address of the vault
|
|
18
|
+
* @param maxRateChangePerUpdate The maximum rate change per update
|
|
19
|
+
* @param feePercentage The fee percentage
|
|
20
|
+
* @param minWithdrawalShares The minimum withdrawal shares
|
|
21
|
+
* @param rateUpdateInterval The rate update interval
|
|
22
|
+
* @param maxTVL The maximum TVL of the vault
|
|
23
|
+
* @param subAccounts The sub accounts of the vault
|
|
24
|
+
* @param options Optional tx execution params
|
|
25
|
+
* @returns OnChainCallResponse
|
|
26
|
+
*/
|
|
27
|
+
async createVault(depositCoinType, receiptCoinType, vaultName, adminAddress, operatorAddress, maxRateChangePerUpdate, feePercentage, minWithdrawalShares, rateUpdateInterval, maxTVL, subAccounts, options) {
|
|
28
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
29
|
+
this.txBuilder.createVault(depositCoinType, receiptCoinType, vaultName, adminAddress, operatorAddress, maxRateChangePerUpdate, feePercentage, minWithdrawalShares, rateUpdateInterval, maxTVL, subAccounts, { ...options, txBlock: txb });
|
|
30
|
+
return this.execCall(txb, options);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Update the admin address of a vault
|
|
34
|
+
* @param vaultId The id of the vault
|
|
35
|
+
* @param adminAddress The new admin address
|
|
36
|
+
* @param options Optional tx execution params
|
|
37
|
+
* @returns OnChainCallResponse
|
|
38
|
+
*/
|
|
39
|
+
async updateVaultAdmin(vaultId, adminAddress, options) {
|
|
40
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
41
|
+
this.txBuilder.updateVaultAdmin(vaultId, adminAddress, {
|
|
42
|
+
...options,
|
|
43
|
+
txBlock: txb
|
|
44
|
+
});
|
|
45
|
+
return this.execCall(txb, options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Update the max fee percentage of the protocol
|
|
49
|
+
* @param maxFeePercentage The new max fee percentage
|
|
50
|
+
* @param options Optional tx execution params
|
|
51
|
+
* @returns OnChainCallResponse
|
|
52
|
+
*/
|
|
53
|
+
async updateMaxFeePercentage(maxFeePercentage, options) {
|
|
54
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
55
|
+
this.txBuilder.updateMaxFeePercentage(maxFeePercentage, {
|
|
56
|
+
...options,
|
|
57
|
+
txBlock: txb
|
|
58
|
+
});
|
|
59
|
+
return this.execCall(txb, options);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Update the default rate of the protocol
|
|
63
|
+
* @param defaultRate The new default rate
|
|
64
|
+
* @param options Optional tx execution params
|
|
65
|
+
* @returns OnChainCallResponse
|
|
66
|
+
*/
|
|
67
|
+
async updateDefaultRate(defaultRate, options) {
|
|
68
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
69
|
+
this.txBuilder.updateDefaultRate(defaultRate, { ...options, txBlock: txb });
|
|
70
|
+
return this.execCall(txb, options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Update the max rate of the protocol
|
|
74
|
+
* @param maxRate The new max rate
|
|
75
|
+
* @param options Optional tx execution params
|
|
76
|
+
* @returns OnChainCallResponse
|
|
77
|
+
*/
|
|
78
|
+
async updateMaxRate(maxRate, options) {
|
|
79
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
80
|
+
this.txBuilder.updateMaxRate(maxRate, { ...options, txBlock: txb });
|
|
81
|
+
return this.execCall(txb, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Update the min rate of the protocol
|
|
85
|
+
* @param minRate The new min rate
|
|
86
|
+
* @param options Optional tx execution params
|
|
87
|
+
* @returns OnChainCallResponse
|
|
88
|
+
*/
|
|
89
|
+
async updateMinRate(minRate, options) {
|
|
90
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
91
|
+
this.txBuilder.updateMinRate(minRate, { ...options, txBlock: txb });
|
|
92
|
+
return this.execCall(txb, options);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Update the platform fee recipient of the protocol
|
|
96
|
+
* @param platformFeeRecipient The new platform fee recipient
|
|
97
|
+
* @param options Optional tx execution params
|
|
98
|
+
* @returns OnChainCallResponse
|
|
99
|
+
*/
|
|
100
|
+
async updatePlatformFeeRecipient(platformFeeRecipient, options) {
|
|
101
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
102
|
+
this.txBuilder.updatePlatformFeeRecipient(platformFeeRecipient, {
|
|
103
|
+
...options,
|
|
104
|
+
txBlock: txb
|
|
105
|
+
});
|
|
106
|
+
return this.execCall(txb, options);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Pause non admin operations
|
|
110
|
+
* @param pause Whether to pause non admin operations
|
|
111
|
+
* @param options Optional tx execution params
|
|
112
|
+
* @returns OnChainCallResponse
|
|
113
|
+
*/
|
|
114
|
+
async pauseNonAdminOperations(pause, options) {
|
|
115
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
116
|
+
this.txBuilder.pauseNonAdminOperations(pause, { ...options, txBlock: txb });
|
|
117
|
+
return this.execCall(txb, options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Increase the protocol version
|
|
121
|
+
* @param options Optional tx execution params
|
|
122
|
+
* @returns OnChainCallResponse
|
|
123
|
+
*/
|
|
124
|
+
async increaseProtocolVersion(options) {
|
|
125
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
126
|
+
this.txBuilder.increaseProtocolVersion({ ...options, txBlock: txb });
|
|
127
|
+
return this.execCall(txb, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Update the max rate interval of the protocol
|
|
131
|
+
* @param maxRateInterval The new max rate interval
|
|
132
|
+
* @param options Optional tx execution params
|
|
133
|
+
* @returns OnChainCallResponse
|
|
134
|
+
*/
|
|
135
|
+
async updateMaxRateInterval(maxRateInterval, options) {
|
|
136
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
137
|
+
this.txBuilder.updateMaxRateInterval(maxRateInterval, {
|
|
138
|
+
...options,
|
|
139
|
+
txBlock: txb
|
|
140
|
+
});
|
|
141
|
+
return this.execCall(txb, options);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.AdminCalls = AdminCalls;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
__exportStar(require("./admin"), exports);
|
|
18
|
+
__exportStar(require("./tx-builder"), exports);
|
|
19
|
+
__exportStar(require("./user"), exports);
|
|
20
|
+
__exportStar(require("./vault-admin"), exports);
|
|
21
|
+
__exportStar(require("./operator"), exports);
|
|
22
|
+
__exportStar(require("./vault"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DryRunTransactionBlockResponse, OnChainCallResponse, Signer, SuiClient, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, TransactionBlock } from "@firefly-exchange/library-sui";
|
|
2
|
+
import { Address } from "@firefly-exchange/library-sui";
|
|
3
|
+
import { DeploymentParser } from "../utils/deployment-parser";
|
|
4
|
+
import { IDeployment, IVaultOptionalParams } from "../interfaces";
|
|
5
|
+
import { TxBuilder } from "./tx-builder";
|
|
6
|
+
export declare class OnChainCalls {
|
|
7
|
+
suiClient: SuiClient;
|
|
8
|
+
signer: Signer;
|
|
9
|
+
parser: DeploymentParser;
|
|
10
|
+
walletAddress: string;
|
|
11
|
+
txBuilder: TxBuilder;
|
|
12
|
+
network: string;
|
|
13
|
+
isUIWallet: boolean;
|
|
14
|
+
constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: Address, _isUIWallet?: boolean);
|
|
15
|
+
/**
|
|
16
|
+
* Signs and executes the given transaction block
|
|
17
|
+
* @param txBlock Sui transaction block
|
|
18
|
+
* @returns Sui Transaction Block Response
|
|
19
|
+
*/
|
|
20
|
+
signAndExecuteTxBlock(txBlock: TransactionBlock, options?: SuiTransactionBlockResponseOptions): Promise<SuiTransactionBlockResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Signs and executes the given transaction block
|
|
23
|
+
* @param txBlock Sui transaction block
|
|
24
|
+
* @returns Sui Transaction Block Response
|
|
25
|
+
*/
|
|
26
|
+
dryRunTxBlock(txBlock: TransactionBlock): Promise<DryRunTransactionBlockResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Dry runs or executes the call on chain depending on the params
|
|
29
|
+
* @param dryRun True if dry run is to be performed
|
|
30
|
+
* @param txBlock The transaction block
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
execCall(txBlock: TransactionBlock, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnChainCalls = void 0;
|
|
4
|
+
const library_sui_1 = require("@firefly-exchange/library-sui");
|
|
5
|
+
const deployment_parser_1 = require("../utils/deployment-parser");
|
|
6
|
+
const tx_builder_1 = require("./tx-builder");
|
|
7
|
+
class OnChainCalls {
|
|
8
|
+
constructor(_network, _suiClient, _deployment, _signer, _walletAddress, _isUIWallet) {
|
|
9
|
+
this.network = _network;
|
|
10
|
+
this.suiClient = _suiClient;
|
|
11
|
+
this.parser = new deployment_parser_1.DeploymentParser(_deployment);
|
|
12
|
+
// could be undefined, if initializing the bluefinVaults for only get calls
|
|
13
|
+
this.signer = _signer;
|
|
14
|
+
this.walletAddress = _walletAddress || _signer?.toSuiAddress();
|
|
15
|
+
this.txBuilder = new tx_builder_1.TxBuilder(_deployment);
|
|
16
|
+
this.isUIWallet = _isUIWallet || false;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Signs and executes the given transaction block
|
|
20
|
+
* @param txBlock Sui transaction block
|
|
21
|
+
* @returns Sui Transaction Block Response
|
|
22
|
+
*/
|
|
23
|
+
async signAndExecuteTxBlock(txBlock, options) {
|
|
24
|
+
return library_sui_1.SuiBlocks.signAndExecuteTxBlock(txBlock, this.suiClient, this.signer, this.isUIWallet, options);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Signs and executes the given transaction block
|
|
28
|
+
* @param txBlock Sui transaction block
|
|
29
|
+
* @returns Sui Transaction Block Response
|
|
30
|
+
*/
|
|
31
|
+
async dryRunTxBlock(txBlock) {
|
|
32
|
+
return library_sui_1.SuiBlocks.dryRunTxBlock(txBlock, this.suiClient, this.signer, this.isUIWallet);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dry runs or executes the call on chain depending on the params
|
|
36
|
+
* @param dryRun True if dry run is to be performed
|
|
37
|
+
* @param txBlock The transaction block
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
async execCall(txBlock, options) {
|
|
41
|
+
if (options?.dryRun) {
|
|
42
|
+
return this.dryRunTxBlock(txBlock);
|
|
43
|
+
}
|
|
44
|
+
else if (options?.returnTxb) {
|
|
45
|
+
return txBlock;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const response = await this.signAndExecuteTxBlock(txBlock, options);
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.OnChainCalls = OnChainCalls;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { OnChainCalls } from "./onchain-calls";
|
|
2
|
+
import { IDeployment, IVaultOptionalParams } from "../interfaces";
|
|
3
|
+
import { OnChainCallResponse, Signer, SuiClient, SuiTransactionBlockResponseOptions } from "@firefly-exchange/library-sui";
|
|
4
|
+
import { NumStr } from "@firefly-exchange/library-sui";
|
|
5
|
+
export declare class OperatorCalls extends OnChainCalls {
|
|
6
|
+
constructor(_network: string, _suiClient: SuiClient, _deployment: IDeployment, _signer?: Signer, _walletAddress?: string);
|
|
7
|
+
/**
|
|
8
|
+
* Collect platform fee from a vault
|
|
9
|
+
* @param vaultId The id of the vault to collect platform fee from
|
|
10
|
+
* @param options Optional tx execution params
|
|
11
|
+
* @returns OnChainCallResponse
|
|
12
|
+
*/
|
|
13
|
+
collectPlatformFee(vaultId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Charge platform fee from a vault
|
|
16
|
+
* @param vaultId The id of the vault to charge platform fee from
|
|
17
|
+
* @param options Optional tx execution params
|
|
18
|
+
* @returns OnChainCallResponse
|
|
19
|
+
*/
|
|
20
|
+
chargePlatformFee(vaultId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Process withdrawal requests up to a timestamp
|
|
23
|
+
* @param vaultId The id of the vault to process withdrawal requests for
|
|
24
|
+
* @param timestamp The timestamp to process withdrawal requests up to
|
|
25
|
+
* @param options Optional tx execution params
|
|
26
|
+
* @returns OnChainCallResponse
|
|
27
|
+
*/
|
|
28
|
+
processWithdrawalRequestsUpToTimestamp(vaultId: string, timestamp: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Process withdrawal requests upto max request count
|
|
31
|
+
* @param vaultId The id of the vault to process withdrawal requests for
|
|
32
|
+
* @param maxRequestCount The maximum number of withdrawal requests to process
|
|
33
|
+
* @param options Optional tx execution params
|
|
34
|
+
* @returns OnChainCallResponse
|
|
35
|
+
*/
|
|
36
|
+
processWithdrawalRequests(vaultId: string, maxRequestCount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* Withdraw from vault without redeeming shares
|
|
39
|
+
* @param vaultId The id of the vault to withdraw from
|
|
40
|
+
* @param subAccount The sub account to withdraw to
|
|
41
|
+
* @param amount The amount to withdraw
|
|
42
|
+
* @param options Optional tx execution params
|
|
43
|
+
* @returns OnChainCallResponse
|
|
44
|
+
*/
|
|
45
|
+
withdrawFromVaultWithoutRedeemingShares(vaultId: string, subAccount: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Deposit to vault without minting shares
|
|
48
|
+
* @param vaultId The id of the vault to deposit to
|
|
49
|
+
* @param subAccount The sub account to deposit from
|
|
50
|
+
* @param amount The amount to deposit
|
|
51
|
+
* @param options Optional tx execution params
|
|
52
|
+
* @returns OnChainCallResponse
|
|
53
|
+
*/
|
|
54
|
+
depositToVaultWithoutMintingShares(vaultId: string, subAccount: string, amount: NumStr, options?: IVaultOptionalParams & {
|
|
55
|
+
coinId?: string;
|
|
56
|
+
} & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Update vault rate
|
|
59
|
+
* @param vaultId The id of the vault to update the rate for
|
|
60
|
+
* @param rate The new rate to set for the vault
|
|
61
|
+
* @param options Optional tx execution params
|
|
62
|
+
* @returns OnChainCallResponse
|
|
63
|
+
*/
|
|
64
|
+
updateVaultRate(vaultId: string, rate: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Set blacklisted account
|
|
67
|
+
* @param vaultId The id of the vault to set the blacklisted account for
|
|
68
|
+
* @param account The account to set as blacklisted
|
|
69
|
+
* @param isBlacklisted Whether the account should be blacklisted
|
|
70
|
+
* @param options Optional tx execution params
|
|
71
|
+
* @returns OnChainCallResponse
|
|
72
|
+
*/
|
|
73
|
+
setBlacklistedAccount(vaultId: string, account: string, isBlacklisted: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperatorCalls = void 0;
|
|
4
|
+
const onchain_calls_1 = require("./onchain-calls");
|
|
5
|
+
const library_sui_1 = require("@firefly-exchange/library-sui");
|
|
6
|
+
const library_sui_2 = require("@firefly-exchange/library-sui");
|
|
7
|
+
class OperatorCalls extends onchain_calls_1.OnChainCalls {
|
|
8
|
+
constructor(_network, _suiClient, _deployment, _signer, _walletAddress) {
|
|
9
|
+
super(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Collect platform fee from a vault
|
|
13
|
+
* @param vaultId The id of the vault to collect platform fee from
|
|
14
|
+
* @param options Optional tx execution params
|
|
15
|
+
* @returns OnChainCallResponse
|
|
16
|
+
*/
|
|
17
|
+
async collectPlatformFee(vaultId, options) {
|
|
18
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
19
|
+
this.txBuilder.collectPlatformFee(vaultId, { ...options, txBlock: txb });
|
|
20
|
+
return this.execCall(txb, options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Charge platform fee from a vault
|
|
24
|
+
* @param vaultId The id of the vault to charge platform fee from
|
|
25
|
+
* @param options Optional tx execution params
|
|
26
|
+
* @returns OnChainCallResponse
|
|
27
|
+
*/
|
|
28
|
+
async chargePlatformFee(vaultId, options) {
|
|
29
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
30
|
+
this.txBuilder.chargePlatformFee(vaultId, { ...options, txBlock: txb });
|
|
31
|
+
return this.execCall(txb, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Process withdrawal requests up to a timestamp
|
|
35
|
+
* @param vaultId The id of the vault to process withdrawal requests for
|
|
36
|
+
* @param timestamp The timestamp to process withdrawal requests up to
|
|
37
|
+
* @param options Optional tx execution params
|
|
38
|
+
* @returns OnChainCallResponse
|
|
39
|
+
*/
|
|
40
|
+
async processWithdrawalRequestsUpToTimestamp(vaultId, timestamp, options) {
|
|
41
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
42
|
+
this.txBuilder.processWithdrawalRequestsUpToTimestamp(vaultId, timestamp, {
|
|
43
|
+
...options,
|
|
44
|
+
txBlock: txb
|
|
45
|
+
});
|
|
46
|
+
return this.execCall(txb, options);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Process withdrawal requests upto max request count
|
|
50
|
+
* @param vaultId The id of the vault to process withdrawal requests for
|
|
51
|
+
* @param maxRequestCount The maximum number of withdrawal requests to process
|
|
52
|
+
* @param options Optional tx execution params
|
|
53
|
+
* @returns OnChainCallResponse
|
|
54
|
+
*/
|
|
55
|
+
async processWithdrawalRequests(vaultId, maxRequestCount, options) {
|
|
56
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
57
|
+
this.txBuilder.processWithdrawalRequests(vaultId, maxRequestCount, {
|
|
58
|
+
...options,
|
|
59
|
+
txBlock: txb
|
|
60
|
+
});
|
|
61
|
+
return this.execCall(txb, options);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Withdraw from vault without redeeming shares
|
|
65
|
+
* @param vaultId The id of the vault to withdraw from
|
|
66
|
+
* @param subAccount The sub account to withdraw to
|
|
67
|
+
* @param amount The amount to withdraw
|
|
68
|
+
* @param options Optional tx execution params
|
|
69
|
+
* @returns OnChainCallResponse
|
|
70
|
+
*/
|
|
71
|
+
async withdrawFromVaultWithoutRedeemingShares(vaultId, subAccount, amount, options) {
|
|
72
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
73
|
+
this.txBuilder.withdrawFromVaultWithoutRedeemingShares(vaultId, subAccount, amount, { ...options, txBlock: txb });
|
|
74
|
+
return this.execCall(txb, options);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Deposit to vault without minting shares
|
|
78
|
+
* @param vaultId The id of the vault to deposit to
|
|
79
|
+
* @param subAccount The sub account to deposit from
|
|
80
|
+
* @param amount The amount to deposit
|
|
81
|
+
* @param options Optional tx execution params
|
|
82
|
+
* @returns OnChainCallResponse
|
|
83
|
+
*/
|
|
84
|
+
async depositToVaultWithoutMintingShares(vaultId, subAccount, amount, options) {
|
|
85
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
86
|
+
let coinId = options?.coinId;
|
|
87
|
+
let split;
|
|
88
|
+
let merged;
|
|
89
|
+
if (!coinId) {
|
|
90
|
+
const coinType = this.parser.getDepositCoinType(vaultId);
|
|
91
|
+
[split, merged] = await library_sui_2.CoinUtils.createCoinWithBalance(this.suiClient, txb, amount, coinType, this.walletAddress);
|
|
92
|
+
coinId = split;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
[split, merged] = await library_sui_2.CoinUtils.validateCoinBalance(this.suiClient, txb, amount, coinId);
|
|
96
|
+
coinId = split;
|
|
97
|
+
}
|
|
98
|
+
this.txBuilder.depositToVaultWithoutMintingShares(vaultId, subAccount, coinId, {
|
|
99
|
+
...options,
|
|
100
|
+
txBlock: txb
|
|
101
|
+
});
|
|
102
|
+
if (merged) {
|
|
103
|
+
txb.transferObjects([merged], this.walletAddress);
|
|
104
|
+
}
|
|
105
|
+
return this.execCall(txb, options);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Update vault rate
|
|
109
|
+
* @param vaultId The id of the vault to update the rate for
|
|
110
|
+
* @param rate The new rate to set for the vault
|
|
111
|
+
* @param options Optional tx execution params
|
|
112
|
+
* @returns OnChainCallResponse
|
|
113
|
+
*/
|
|
114
|
+
async updateVaultRate(vaultId, rate, options) {
|
|
115
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
116
|
+
this.txBuilder.updateVaultRate(vaultId, rate, { ...options, txBlock: txb });
|
|
117
|
+
return this.execCall(txb, options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set blacklisted account
|
|
121
|
+
* @param vaultId The id of the vault to set the blacklisted account for
|
|
122
|
+
* @param account The account to set as blacklisted
|
|
123
|
+
* @param isBlacklisted Whether the account should be blacklisted
|
|
124
|
+
* @param options Optional tx execution params
|
|
125
|
+
* @returns OnChainCallResponse
|
|
126
|
+
*/
|
|
127
|
+
async setBlacklistedAccount(vaultId, account, isBlacklisted, options) {
|
|
128
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
129
|
+
this.txBuilder.setBlacklistedAccount(vaultId, account, isBlacklisted, {
|
|
130
|
+
...options,
|
|
131
|
+
txBlock: txb
|
|
132
|
+
});
|
|
133
|
+
return this.execCall(txb, options);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.OperatorCalls = OperatorCalls;
|