@ember-finance/sdk 1.0.4 → 1.0.6
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.
|
@@ -2,6 +2,9 @@ import { Signer, SuiClient } from "@firefly-exchange/library-sui";
|
|
|
2
2
|
import { IDeployment } from "./interfaces";
|
|
3
3
|
import { TxBuilder } from "./on-chain-calls";
|
|
4
4
|
import { AdminCalls } from "./on-chain-calls/admin";
|
|
5
|
+
import { OperatorCalls } from "./on-chain-calls/operator";
|
|
6
|
+
import { UserCalls } from "./on-chain-calls/user";
|
|
7
|
+
import { VaultAdminCalls } from "./on-chain-calls/vault-admin";
|
|
5
8
|
import { DeploymentParser } from "./utils/deployment-parser";
|
|
6
9
|
import { AccountsApi, VaultsApi } from "./api";
|
|
7
10
|
export type PlatformEnv = "prod" | "staging" | "dev";
|
|
@@ -13,11 +16,15 @@ export declare class EmberVaults {
|
|
|
13
16
|
txBuilder: TxBuilder;
|
|
14
17
|
network: string;
|
|
15
18
|
admin: AdminCalls;
|
|
19
|
+
operator: OperatorCalls;
|
|
20
|
+
vaultAdmin: VaultAdminCalls;
|
|
21
|
+
user: UserCalls;
|
|
16
22
|
apiHost: string;
|
|
17
23
|
api: AccountsApi;
|
|
18
24
|
vaultsApi: VaultsApi;
|
|
19
25
|
private _deployment;
|
|
20
|
-
constructor(_network: string, _suiClient: SuiClient,
|
|
26
|
+
constructor(_network: string, _suiClient: SuiClient, _signer?: Signer, _walletAddress?: string, basePath?: string, _deployment?: IDeployment, environment?: PlatformEnv);
|
|
27
|
+
init(): Promise<void>;
|
|
21
28
|
/**
|
|
22
29
|
* Updates the deployment configuration and reinitializes all deployment-dependent components
|
|
23
30
|
* This allows for updating deployment without creating a new EmberVaults instance
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EmberVaults = void 0;
|
|
4
4
|
const on_chain_calls_1 = require("./on-chain-calls");
|
|
5
5
|
const admin_1 = require("./on-chain-calls/admin");
|
|
6
|
+
const operator_1 = require("./on-chain-calls/operator");
|
|
7
|
+
const user_1 = require("./on-chain-calls/user");
|
|
8
|
+
const vault_admin_1 = require("./on-chain-calls/vault-admin");
|
|
6
9
|
const deployment_parser_1 = require("./utils/deployment-parser");
|
|
7
10
|
const api_1 = require("./api");
|
|
8
11
|
const environmentConfig = {
|
|
@@ -17,10 +20,10 @@ const environmentConfig = {
|
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
class EmberVaults {
|
|
20
|
-
constructor(_network, _suiClient,
|
|
23
|
+
constructor(_network, _suiClient, _signer, _walletAddress, basePath, _deployment, environment = "prod") {
|
|
21
24
|
this.network = _network;
|
|
22
25
|
this.suiClient = _suiClient;
|
|
23
|
-
this._deployment = _deployment;
|
|
26
|
+
this._deployment = _deployment || {};
|
|
24
27
|
this.parser = new deployment_parser_1.DeploymentParser(_deployment);
|
|
25
28
|
// could be undefined, if initializing the EmberVaults for only get calls
|
|
26
29
|
this.signer = _signer;
|
|
@@ -28,9 +31,17 @@ class EmberVaults {
|
|
|
28
31
|
this.txBuilder = new on_chain_calls_1.TxBuilder(_deployment);
|
|
29
32
|
this.apiHost = basePath || environmentConfig[environment].apiHost;
|
|
30
33
|
this.admin = new admin_1.AdminCalls(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
34
|
+
this.operator = new operator_1.OperatorCalls(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
35
|
+
this.vaultAdmin = new vault_admin_1.VaultAdminCalls(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
36
|
+
this.user = new user_1.UserCalls(_network, _suiClient, _deployment, _signer, _walletAddress);
|
|
31
37
|
this.api = new api_1.AccountsApi(new api_1.Configuration({ basePath: this.apiHost }));
|
|
32
38
|
this.vaultsApi = new api_1.VaultsApi(new api_1.Configuration({ basePath: this.apiHost }));
|
|
33
39
|
}
|
|
40
|
+
async init() {
|
|
41
|
+
const deployment = await this.vaultsApi.getVaultsProtocolInfo();
|
|
42
|
+
const deploymentData = deployment.data;
|
|
43
|
+
this.updateDeployment(deploymentData);
|
|
44
|
+
}
|
|
34
45
|
/**
|
|
35
46
|
* Updates the deployment configuration and reinitializes all deployment-dependent components
|
|
36
47
|
* This allows for updating deployment without creating a new EmberVaults instance
|
|
@@ -80,3 +80,28 @@ export interface ISignedNumber {
|
|
|
80
80
|
value: NumStr;
|
|
81
81
|
sign: boolean;
|
|
82
82
|
}
|
|
83
|
+
export interface IVault {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
admin: Address;
|
|
87
|
+
operator: Address;
|
|
88
|
+
balance: NumStr;
|
|
89
|
+
fee_percentage: NumStr;
|
|
90
|
+
max_tvl: NumStr;
|
|
91
|
+
min_withdrawal_shares: NumStr;
|
|
92
|
+
paused: boolean;
|
|
93
|
+
pending_shares_to_burn: NumStr;
|
|
94
|
+
sequence_number: NumStr;
|
|
95
|
+
sub_accounts: Address[];
|
|
96
|
+
blacklisted: Address[];
|
|
97
|
+
fee: {
|
|
98
|
+
accrued: NumStr;
|
|
99
|
+
last_charged_at: NumStr;
|
|
100
|
+
};
|
|
101
|
+
rate: {
|
|
102
|
+
last_updated_at: NumStr;
|
|
103
|
+
max_rate_change_per_update: NumStr;
|
|
104
|
+
rate_update_interval: NumStr;
|
|
105
|
+
value: NumStr;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer, SuiClient } from "@firefly-exchange/library-sui";
|
|
2
|
-
import { IVaultAccount } from "../interfaces";
|
|
2
|
+
import { IVault, IVaultAccount } from "../interfaces";
|
|
3
3
|
export declare class Vault {
|
|
4
4
|
/**
|
|
5
5
|
* Fetches the vault rate from on-chain
|
|
@@ -8,6 +8,7 @@ export declare class Vault {
|
|
|
8
8
|
* @returns The vault rate
|
|
9
9
|
*/
|
|
10
10
|
static getVaultRate(suiClient: SuiClient, vaultId: string): Promise<number>;
|
|
11
|
+
static getVault(suiClient: SuiClient, vaultId: string): Promise<IVault>;
|
|
11
12
|
static getPendingWithdrawalRequests(suiClient: SuiClient, vaultId: string, walletAddress: string): Promise<IVaultAccount>;
|
|
12
13
|
static signUpdateVaultStrategyRequest(payload: {
|
|
13
14
|
vaultId: string;
|
|
@@ -18,6 +18,42 @@ class Vault {
|
|
|
18
18
|
});
|
|
19
19
|
return (response.data?.content).fields?.["rate"]?.fields?.["value"];
|
|
20
20
|
}
|
|
21
|
+
static async getVault(suiClient, vaultId) {
|
|
22
|
+
const response = await suiClient.getObject({
|
|
23
|
+
id: vaultId,
|
|
24
|
+
options: { showContent: true }
|
|
25
|
+
});
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const fields = response.data?.content?.fields;
|
|
28
|
+
if (!fields) {
|
|
29
|
+
throw new Error("Vault not found or invalid response");
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
id: fields.id?.id || vaultId,
|
|
33
|
+
name: fields.name || "",
|
|
34
|
+
admin: fields.admin,
|
|
35
|
+
operator: fields.operator,
|
|
36
|
+
balance: fields.balance,
|
|
37
|
+
fee_percentage: fields.fee_percentage,
|
|
38
|
+
max_tvl: fields.max_tvl,
|
|
39
|
+
min_withdrawal_shares: fields.min_withdrawal_shares,
|
|
40
|
+
paused: fields.paused,
|
|
41
|
+
pending_shares_to_burn: fields.pending_shares_to_burn,
|
|
42
|
+
sequence_number: fields.sequence_number,
|
|
43
|
+
sub_accounts: fields.sub_accounts || [],
|
|
44
|
+
blacklisted: fields.blacklisted || [],
|
|
45
|
+
fee: {
|
|
46
|
+
accrued: fields.fee?.fields?.accrued || "0",
|
|
47
|
+
last_charged_at: fields.fee?.fields?.last_charged_at || "0"
|
|
48
|
+
},
|
|
49
|
+
rate: {
|
|
50
|
+
last_updated_at: fields.rate?.fields?.last_updated_at || "0",
|
|
51
|
+
max_rate_change_per_update: fields.rate?.fields?.max_rate_change_per_update || "0",
|
|
52
|
+
rate_update_interval: fields.rate?.fields?.rate_update_interval || "0",
|
|
53
|
+
value: fields.rate?.fields?.value || "0"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
21
57
|
static async getPendingWithdrawalRequests(suiClient, vaultId, walletAddress) {
|
|
22
58
|
const objDetails = await suiClient.getObject({
|
|
23
59
|
id: vaultId,
|