aftermath-ts-sdk 1.2.51 → 1.2.52-perps.3
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/README.md +62 -28
- package/dist/general/apiHelpers/eventsApiHelpers.d.ts +1 -1
- package/dist/general/apiHelpers/eventsApiHelpers.d.ts.map +1 -1
- package/dist/general/apiHelpers/eventsApiHelpers.js +4 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +6 -0
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.js +46 -0
- package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
- package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
- package/dist/general/dynamicGas/dynamicGas.js +34 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
- package/dist/general/prices/coinGeckoTypes.d.ts +2 -0
- package/dist/general/prices/coinGeckoTypes.d.ts.map +1 -1
- package/dist/general/prices/prices.d.ts +73 -0
- package/dist/general/prices/prices.d.ts.map +1 -1
- package/dist/general/prices/prices.js +73 -0
- package/dist/general/providers/aftermath.d.ts +107 -27
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +110 -30
- package/dist/general/providers/aftermathApi.d.ts +128 -10
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +133 -14
- package/dist/general/types/castingTypes.d.ts +15 -7
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/castingTypes.js +6 -0
- package/dist/general/types/configTypes.d.ts +14 -8
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +229 -7
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts.map +1 -1
- package/dist/general/types/suiTypes.d.ts +0 -16
- package/dist/general/types/suiTypes.d.ts.map +1 -1
- package/dist/general/types/suiTypes.js +3 -25
- package/dist/general/utils/caller.d.ts +6 -3
- package/dist/general/utils/caller.d.ts.map +1 -1
- package/dist/general/utils/caller.js +22 -4
- package/dist/general/utils/casting.d.ts +156 -5
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +159 -18
- package/dist/general/utils/fixedUtils.d.ts +89 -2
- package/dist/general/utils/fixedUtils.d.ts.map +1 -1
- package/dist/general/utils/fixedUtils.js +81 -4
- package/dist/general/utils/helpers.d.ts +327 -10
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +409 -91
- package/dist/general/utils/iFixedUtils.d.ts +64 -0
- package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
- package/dist/general/utils/iFixedUtils.js +64 -0
- package/dist/general/wallet/wallet.d.ts +76 -1
- package/dist/general/wallet/wallet.d.ts.map +1 -1
- package/dist/general/wallet/wallet.js +75 -5
- package/dist/packages/auth/auth.d.ts +113 -4
- package/dist/packages/auth/auth.d.ts.map +1 -1
- package/dist/packages/auth/auth.js +190 -59
- package/dist/packages/auth/authTypes.d.ts +66 -0
- package/dist/packages/auth/authTypes.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.js +29 -20
- package/dist/packages/coin/coin.d.ts +256 -1
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +246 -15
- package/dist/packages/coin/coinTypes.d.ts +95 -0
- package/dist/packages/coin/coinTypes.d.ts.map +1 -1
- package/dist/packages/dca/api/dcaApi.d.ts +2 -0
- package/dist/packages/dca/api/dcaApi.d.ts.map +1 -1
- package/dist/packages/dca/api/dcaApi.js +6 -3
- package/dist/packages/dca/dca.d.ts +125 -35
- package/dist/packages/dca/dca.d.ts.map +1 -1
- package/dist/packages/dca/dca.js +135 -43
- package/dist/packages/dca/dcaTypes.d.ts +217 -42
- package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApi.d.ts +725 -58
- package/dist/packages/farms/api/farmsApi.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApi.js +1149 -153
- package/dist/packages/farms/api/farmsApiCasting.d.ts +34 -18
- package/dist/packages/farms/api/farmsApiCasting.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApiCasting.js +218 -17
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +117 -21
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/farms/farms.d.ts +200 -12
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farms.js +204 -50
- package/dist/packages/farms/farmsStakedPosition.d.ts +143 -8
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakedPosition.js +243 -137
- package/dist/packages/farms/farmsStakingPool.d.ts +171 -3
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakingPool.js +233 -73
- package/dist/packages/farms/farmsTypes.d.ts +310 -2
- package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
- package/dist/packages/farms/farmsTypes.js +47 -0
- package/dist/packages/faucet/api/faucetApi.d.ts +9 -17
- package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.js +44 -49
- package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApiCasting.js +8 -5
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +1 -4
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.d.ts +1 -1
- package/dist/packages/faucet/faucet.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.js +1 -1
- package/dist/packages/faucet/faucetTypes.d.ts +2 -3
- package/dist/packages/faucet/faucetTypes.d.ts.map +1 -1
- package/dist/packages/limitOrders/api/limitOrdersApi.d.ts +12 -0
- package/dist/packages/limitOrders/api/limitOrdersApi.d.ts.map +1 -0
- package/dist/packages/limitOrders/api/limitOrdersApi.js +25 -0
- package/dist/packages/limitOrders/index.d.ts +2 -0
- package/dist/packages/limitOrders/index.d.ts.map +1 -0
- package/dist/packages/limitOrders/index.js +17 -0
- package/dist/packages/limitOrders/limitOrders.d.ts +143 -0
- package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -0
- package/dist/packages/limitOrders/limitOrders.js +190 -0
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts +211 -0
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -0
- package/dist/packages/multisig/multisig.d.ts +34 -5
- package/dist/packages/multisig/multisig.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.js +33 -4
- package/dist/packages/multisig/multisigTypes.d.ts +17 -0
- package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +38 -23
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +740 -299
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +10 -6
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApiCasting.js +112 -42
- package/dist/packages/perpetuals/perpetuals.d.ts +33 -4
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +105 -18
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +107 -33
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +569 -68
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +104 -25
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +31 -9
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +85 -77
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +348 -380
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsTypes.js +43 -113
- package/dist/packages/pools/api/poolsApiCasting.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApiCasting.js +0 -1
- package/dist/packages/pools/pool.d.ts +333 -106
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pool.js +347 -119
- package/dist/packages/pools/pools.d.ts +307 -39
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/pools/pools.js +323 -54
- package/dist/packages/pools/poolsTypes.d.ts +267 -2
- package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.d.ts +38 -1
- package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.js +37 -0
- package/dist/packages/router/api/routerApi.d.ts +2 -2
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +19 -11
- package/dist/packages/router/router.d.ts +214 -18
- package/dist/packages/router/router.d.ts.map +1 -1
- package/dist/packages/router/router.js +216 -20
- package/dist/packages/router/routerTypes.d.ts +202 -17
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/staking/staking.d.ts +306 -45
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/staking/staking.js +313 -51
- package/dist/packages/staking/stakingTypes.d.ts +431 -6
- package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
- package/dist/packages/staking/stakingTypes.js +19 -0
- package/dist/packages/sui/sui.d.ts +40 -1
- package/dist/packages/sui/sui.d.ts.map +1 -1
- package/dist/packages/sui/sui.js +39 -0
- package/dist/packages/suiFrens/stakedSuiFren.d.ts +1 -1
- package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -1
- package/dist/packages/userData/api/userDataApi.d.ts +6 -0
- package/dist/packages/userData/api/userDataApi.d.ts.map +1 -0
- package/dist/packages/userData/api/userDataApi.js +12 -0
- package/dist/packages/userData/index.d.ts +2 -0
- package/dist/packages/userData/index.d.ts.map +1 -0
- package/dist/packages/userData/index.js +17 -0
- package/dist/packages/userData/userData.d.ts +89 -0
- package/dist/packages/userData/userData.d.ts.map +1 -0
- package/dist/packages/userData/userData.js +119 -0
- package/dist/packages/userData/userDataTypes.d.ts +29 -0
- package/dist/packages/userData/userDataTypes.d.ts.map +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +1 -1
- package/dist/general/historicalData/historicalData.d.ts +0 -15
- package/dist/general/historicalData/historicalData.d.ts.map +0 -1
- package/dist/general/historicalData/historicalData.js +0 -45
- package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
- package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
- package/dist/packages/dca/api/dcaApiCasting.d.ts +0 -11
- package/dist/packages/dca/api/dcaApiCasting.d.ts.map +0 -1
- package/dist/packages/dca/api/dcaApiCasting.js +0 -186
- package/dist/packages/dca/api/dcaApiCastingTypes.d.ts +0 -142
- package/dist/packages/dca/api/dcaApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/oracle/api/oracleApi.d.ts +0 -13
- package/dist/packages/oracle/api/oracleApi.d.ts.map +0 -1
- package/dist/packages/oracle/api/oracleApi.js +0 -35
- package/dist/packages/oracle/oracle.d.ts +0 -15
- package/dist/packages/oracle/oracle.d.ts.map +0 -1
- package/dist/packages/oracle/oracle.js +0 -46
- package/dist/packages/oracle/oracleTypes.d.ts +0 -2
- package/dist/packages/oracle/oracleTypes.d.ts.map +0 -1
- package/dist/packages/oracle/oracleTypes.js +0 -2
- /package/dist/{general/historicalData/historicalDataTypes.js → packages/limitOrders/limitOrdersTypes.js} +0 -0
- /package/dist/packages/{dca/api/dcaApiCastingTypes.js → userData/userDataTypes.js} +0 -0
|
@@ -19,6 +19,11 @@ class FarmsApi {
|
|
|
19
19
|
// =========================================================================
|
|
20
20
|
// Constructor
|
|
21
21
|
// =========================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for FarmsApi
|
|
24
|
+
* @param Provider The AftermathApi provider instance
|
|
25
|
+
* @throws Error if not all required addresses have been set in provider
|
|
26
|
+
*/
|
|
22
27
|
constructor(Provider) {
|
|
23
28
|
this.Provider = Provider;
|
|
24
29
|
// =========================================================================
|
|
@@ -30,83 +35,91 @@ class FarmsApi {
|
|
|
30
35
|
// =========================================================================
|
|
31
36
|
// Staking Pool Objects
|
|
32
37
|
// =========================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Fetches the owner caps for staking pools owned by a specific wallet address
|
|
40
|
+
* @param inputs Object containing wallet address
|
|
41
|
+
* @returns Array of StakingPoolOwnerCapObject
|
|
42
|
+
*/
|
|
33
43
|
this.fetchOwnedStakingPoolOwnerCaps = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
34
44
|
const { walletAddress } = inputs;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
const [capsV1, capsV2] = yield Promise.all([
|
|
46
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
47
|
+
walletAddress,
|
|
48
|
+
objectType: this.objectTypes.stakingPoolOwnerCapV1,
|
|
49
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
50
|
+
.stakingPoolOwnerCapObjectFromSuiObjectResponseV1,
|
|
51
|
+
}),
|
|
52
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
53
|
+
walletAddress,
|
|
54
|
+
objectType: this.objectTypes.stakingPoolOwnerCapV2,
|
|
55
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
56
|
+
.stakingPoolOwnerCapObjectFromSuiObjectResponseV2,
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
return [...capsV1, ...capsV2];
|
|
40
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* Fetches the one-time admin caps for staking pools owned by a specific wallet address
|
|
63
|
+
* @param inputs Object containing wallet address
|
|
64
|
+
* @returns Array of StakingPoolOneTimeAdminCapObject
|
|
65
|
+
*/
|
|
41
66
|
this.fetchOwnedStakingPoolOneTimeAdminCaps = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
42
67
|
const { walletAddress } = inputs;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
|
|
68
|
+
const [capsV1, capsV2] = yield Promise.all([
|
|
69
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
70
|
+
walletAddress,
|
|
71
|
+
objectType: this.objectTypes.stakingPoolOneTimeAdminCapV1,
|
|
72
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
73
|
+
.stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV1,
|
|
74
|
+
}),
|
|
75
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
76
|
+
walletAddress,
|
|
77
|
+
objectType: this.objectTypes.stakingPoolOneTimeAdminCapV2,
|
|
78
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
79
|
+
.stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV2,
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
82
|
+
return [...capsV1, ...capsV2];
|
|
49
83
|
});
|
|
50
84
|
// =========================================================================
|
|
51
85
|
// Staked Position Objects
|
|
52
86
|
// =========================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Fetches partial staked positions owned by a specific wallet address
|
|
89
|
+
* @param inputs Object containing wallet address
|
|
90
|
+
* @returns Array of PartialFarmsStakedPositionObject
|
|
91
|
+
*/
|
|
53
92
|
this.fetchOwnedPartialStakedPositions = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
54
93
|
const { walletAddress } = inputs;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
94
|
+
const [positionsV1, positionsV2] = yield Promise.all([
|
|
95
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
96
|
+
walletAddress,
|
|
97
|
+
objectType: this.objectTypes.stakedPositionV1,
|
|
98
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
99
|
+
.partialStakedPositionObjectFromSuiObjectResponseV1,
|
|
100
|
+
}),
|
|
101
|
+
this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
|
|
102
|
+
walletAddress,
|
|
103
|
+
objectType: this.objectTypes.stakedPositionV2,
|
|
104
|
+
objectFromSuiObjectResponse: utils_1.Casting.farms
|
|
105
|
+
.partialStakedPositionObjectFromSuiObjectResponseV2,
|
|
106
|
+
}),
|
|
107
|
+
]);
|
|
108
|
+
return [...positionsV1, ...positionsV2];
|
|
60
109
|
});
|
|
61
110
|
// =========================================================================
|
|
62
|
-
// Events
|
|
63
|
-
// =========================================================================
|
|
64
|
-
// =========================================================================
|
|
65
|
-
// Created Vault
|
|
66
|
-
// =========================================================================
|
|
67
|
-
this.fetchCreatedVaultEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
68
|
-
MoveEventType: this.eventTypes.createdVault,
|
|
69
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.createdVaultEventFromOnChain }));
|
|
70
|
-
// =========================================================================
|
|
71
|
-
// Staking Position Creation
|
|
72
|
-
// =========================================================================
|
|
73
|
-
this.fetchStakedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
74
|
-
MoveEventType: this.eventTypes.staked,
|
|
75
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.stakedEventFromOnChain }));
|
|
76
|
-
this.fetchStakedRelaxedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
77
|
-
MoveEventType: this.eventTypes.stakedRelaxed,
|
|
78
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.stakedRelaxedEventFromOnChain }));
|
|
79
|
-
// =========================================================================
|
|
80
|
-
// Staking Position Locking
|
|
81
|
-
// =========================================================================
|
|
82
|
-
this.fetchLockedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
83
|
-
MoveEventType: this.eventTypes.locked,
|
|
84
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.lockedEventFromOnChain }));
|
|
85
|
-
this.fetchUnlockedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
86
|
-
MoveEventType: this.eventTypes.unlocked,
|
|
87
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.unlockedEventFromOnChain }));
|
|
88
|
-
// =========================================================================
|
|
89
|
-
// Staking Position Staking
|
|
90
|
-
// =========================================================================
|
|
91
|
-
this.fetchDepositedPrincipalEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
92
|
-
MoveEventType: this.eventTypes.depositedPrincipal,
|
|
93
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.depositedPrincipalEventFromOnChain }));
|
|
94
|
-
this.fetchWithdrewPrincipalEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
95
|
-
MoveEventType: this.eventTypes.withdrewPrincipal,
|
|
96
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.withdrewPrincipalEventFromOnChain }));
|
|
97
|
-
// =========================================================================
|
|
98
|
-
// Staking Position Reward Harvesting
|
|
99
|
-
// =========================================================================
|
|
100
|
-
this.fetchHarvestedRewardsEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
|
|
101
|
-
MoveEventType: this.eventTypes.harvestedRewards,
|
|
102
|
-
}, eventFromEventOnChain: utils_1.Casting.farms.harvestedRewardsEventFromOnChain }));
|
|
103
|
-
// =========================================================================
|
|
104
111
|
// Transaction Commands
|
|
105
112
|
// =========================================================================
|
|
106
113
|
// =========================================================================
|
|
107
114
|
// Staking Transaction Commands
|
|
108
115
|
// =========================================================================
|
|
109
|
-
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated use stakeTxV2 instead
|
|
118
|
+
* Creates a transaction to stake coins in a staking pool (original version)
|
|
119
|
+
* @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, and coin type
|
|
120
|
+
* @returns Transaction object argument for StakedPosition
|
|
121
|
+
*/
|
|
122
|
+
this.stakeTxV1 = (inputs) => {
|
|
110
123
|
const { tx, stakeCoinId } = inputs;
|
|
111
124
|
return tx.moveCall({
|
|
112
125
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "stake"),
|
|
@@ -121,7 +134,35 @@ class FarmsApi {
|
|
|
121
134
|
],
|
|
122
135
|
});
|
|
123
136
|
};
|
|
124
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Creates a transaction to stake coins in a staking pool
|
|
139
|
+
* @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, lock enforcement, and coin type
|
|
140
|
+
* @returns Transaction object argument for StakedPosition
|
|
141
|
+
*/
|
|
142
|
+
this.stakeTxV2 = (inputs) => {
|
|
143
|
+
const { tx, stakeCoinId } = inputs;
|
|
144
|
+
return tx.moveCall({
|
|
145
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "stake"),
|
|
146
|
+
typeArguments: [inputs.stakeCoinType],
|
|
147
|
+
arguments: [
|
|
148
|
+
tx.object(inputs.stakingPoolId),
|
|
149
|
+
tx.object(this.addresses.objects.version),
|
|
150
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
151
|
+
typeof stakeCoinId === "string"
|
|
152
|
+
? tx.object(stakeCoinId)
|
|
153
|
+
: stakeCoinId,
|
|
154
|
+
tx.pure.u8(inputs.lockEnforcement === "Strict" ? 0 : 1),
|
|
155
|
+
tx.pure.u64(inputs.lockDurationMs), // lock_duration_ms
|
|
156
|
+
],
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated use depositPrincipalTxV2 instead
|
|
161
|
+
* Creates a transaction to deposit additional principal to a staked position (original version)
|
|
162
|
+
* @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type
|
|
163
|
+
* @returns Transaction command to deposit principal
|
|
164
|
+
*/
|
|
165
|
+
this.depositPrincipalTxV1 = (inputs) => {
|
|
125
166
|
const { tx, stakeCoinId } = inputs;
|
|
126
167
|
return tx.moveCall({
|
|
127
168
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"),
|
|
@@ -136,7 +177,34 @@ class FarmsApi {
|
|
|
136
177
|
],
|
|
137
178
|
});
|
|
138
179
|
};
|
|
139
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Creates a transaction to deposit additional principal to a staked position
|
|
182
|
+
* @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type
|
|
183
|
+
* @returns Transaction command to deposit principal
|
|
184
|
+
*/
|
|
185
|
+
this.depositPrincipalTxV2 = (inputs) => {
|
|
186
|
+
const { tx, stakeCoinId } = inputs;
|
|
187
|
+
return tx.moveCall({
|
|
188
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"),
|
|
189
|
+
typeArguments: [inputs.stakeCoinType],
|
|
190
|
+
arguments: [
|
|
191
|
+
tx.object(inputs.stakedPositionId),
|
|
192
|
+
tx.object(inputs.stakingPoolId),
|
|
193
|
+
tx.object(this.addresses.objects.version),
|
|
194
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
195
|
+
typeof stakeCoinId === "string"
|
|
196
|
+
? tx.object(stakeCoinId)
|
|
197
|
+
: stakeCoinId, // Coin
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated use withdrawPrincipalTxV2 instead
|
|
203
|
+
* Creates a transaction to withdraw principal from a staked position (original version)
|
|
204
|
+
* @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type
|
|
205
|
+
* @returns Transaction object argument for the withdrawn Coin
|
|
206
|
+
*/
|
|
207
|
+
this.withdrawPrincipalTxV1 = (inputs) => {
|
|
140
208
|
const { tx } = inputs;
|
|
141
209
|
return tx.moveCall({
|
|
142
210
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"),
|
|
@@ -149,7 +217,32 @@ class FarmsApi {
|
|
|
149
217
|
],
|
|
150
218
|
});
|
|
151
219
|
};
|
|
152
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Creates a transaction to withdraw principal from a staked position
|
|
222
|
+
* @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type
|
|
223
|
+
* @returns Transaction object argument for the withdrawn Coin
|
|
224
|
+
*/
|
|
225
|
+
this.withdrawPrincipalTxV2 = (inputs) => {
|
|
226
|
+
const { tx } = inputs;
|
|
227
|
+
return tx.moveCall({
|
|
228
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"),
|
|
229
|
+
typeArguments: [inputs.stakeCoinType],
|
|
230
|
+
arguments: [
|
|
231
|
+
tx.object(inputs.stakedPositionId),
|
|
232
|
+
tx.object(inputs.stakingPoolId),
|
|
233
|
+
tx.object(this.addresses.objects.version),
|
|
234
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
235
|
+
tx.pure.u64(inputs.withdrawAmount),
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* @deprecated use destroyStakedPositionTxV2 instead
|
|
241
|
+
* Creates a transaction to destroy a staked position (original version)
|
|
242
|
+
* @param inputs Destroy parameters including transaction, position ID, pool ID, and coin type
|
|
243
|
+
* @returns Transaction command to destroy the position
|
|
244
|
+
*/
|
|
245
|
+
this.destroyStakedPositionTxV1 = (inputs) => {
|
|
153
246
|
const { tx } = inputs;
|
|
154
247
|
return tx.moveCall({
|
|
155
248
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "destroy"),
|
|
@@ -161,7 +254,29 @@ class FarmsApi {
|
|
|
161
254
|
],
|
|
162
255
|
});
|
|
163
256
|
};
|
|
164
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Creates a transaction to destroy a staked position
|
|
259
|
+
* @param inputs Destroy parameters including transaction, position ID, and coin type
|
|
260
|
+
* @returns Transaction command to destroy the position
|
|
261
|
+
*/
|
|
262
|
+
this.destroyStakedPositionTxV2 = (inputs) => {
|
|
263
|
+
const { tx } = inputs;
|
|
264
|
+
return tx.moveCall({
|
|
265
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "destroy"),
|
|
266
|
+
typeArguments: [inputs.stakeCoinType],
|
|
267
|
+
arguments: [
|
|
268
|
+
tx.object(inputs.stakedPositionId),
|
|
269
|
+
tx.object(this.addresses.objects.version), // Version
|
|
270
|
+
],
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* @deprecated use updatePositionTxV2 instead
|
|
275
|
+
* Creates a transaction to update a staked position, recalculating rewards (original version)
|
|
276
|
+
* @param inputs Update parameters including transaction, position ID, pool ID, and coin type
|
|
277
|
+
* @returns Transaction command to update the position
|
|
278
|
+
*/
|
|
279
|
+
this.updatePositionTxV1 = (inputs) => {
|
|
165
280
|
const { tx } = inputs;
|
|
166
281
|
return tx.moveCall({
|
|
167
282
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "update_position"),
|
|
@@ -173,10 +288,34 @@ class FarmsApi {
|
|
|
173
288
|
],
|
|
174
289
|
});
|
|
175
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* Creates a transaction to update a staked position, recalculating rewards
|
|
293
|
+
* @param inputs Update parameters including transaction, position ID, pool ID, and coin type
|
|
294
|
+
* @returns Transaction command to update the position
|
|
295
|
+
*/
|
|
296
|
+
this.updatePositionTxV2 = (inputs) => {
|
|
297
|
+
const { tx } = inputs;
|
|
298
|
+
return tx.moveCall({
|
|
299
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "update_position"),
|
|
300
|
+
typeArguments: [inputs.stakeCoinType],
|
|
301
|
+
arguments: [
|
|
302
|
+
tx.object(inputs.stakedPositionId),
|
|
303
|
+
tx.object(inputs.stakingPoolId),
|
|
304
|
+
tx.object(this.addresses.objects.version),
|
|
305
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
};
|
|
176
309
|
// =========================================================================
|
|
177
310
|
// Locking Transaction Commands
|
|
178
311
|
// =========================================================================
|
|
179
|
-
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated use lockTxV2 instead
|
|
314
|
+
* Creates a transaction to lock a staked position for a specific duration (original version)
|
|
315
|
+
* @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type
|
|
316
|
+
* @returns Transaction command to lock the position
|
|
317
|
+
*/
|
|
318
|
+
this.lockTxV1 = (inputs) => {
|
|
180
319
|
const { tx } = inputs;
|
|
181
320
|
return tx.moveCall({
|
|
182
321
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "lock"),
|
|
@@ -189,7 +328,32 @@ class FarmsApi {
|
|
|
189
328
|
],
|
|
190
329
|
});
|
|
191
330
|
};
|
|
192
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Creates a transaction to lock a staked position for a specific duration
|
|
333
|
+
* @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type
|
|
334
|
+
* @returns Transaction command to lock the position
|
|
335
|
+
*/
|
|
336
|
+
this.lockTxV2 = (inputs) => {
|
|
337
|
+
const { tx } = inputs;
|
|
338
|
+
return tx.moveCall({
|
|
339
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "lock"),
|
|
340
|
+
typeArguments: [inputs.stakeCoinType],
|
|
341
|
+
arguments: [
|
|
342
|
+
tx.object(inputs.stakedPositionId),
|
|
343
|
+
tx.object(inputs.stakingPoolId),
|
|
344
|
+
tx.object(this.addresses.objects.version),
|
|
345
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
346
|
+
tx.pure.u64(inputs.lockDurationMs),
|
|
347
|
+
],
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* @deprecated use renewLockTxV2 instead
|
|
352
|
+
* Creates a transaction to renew the lock on a staked position (original version)
|
|
353
|
+
* @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type
|
|
354
|
+
* @returns Transaction command to renew the lock
|
|
355
|
+
*/
|
|
356
|
+
this.renewLockTxV1 = (inputs) => {
|
|
193
357
|
const { tx } = inputs;
|
|
194
358
|
return tx.moveCall({
|
|
195
359
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"),
|
|
@@ -201,7 +365,31 @@ class FarmsApi {
|
|
|
201
365
|
],
|
|
202
366
|
});
|
|
203
367
|
};
|
|
204
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Creates a transaction to renew the lock on a staked position
|
|
370
|
+
* @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type
|
|
371
|
+
* @returns Transaction command to renew the lock
|
|
372
|
+
*/
|
|
373
|
+
this.renewLockTxV2 = (inputs) => {
|
|
374
|
+
const { tx } = inputs;
|
|
375
|
+
return tx.moveCall({
|
|
376
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"),
|
|
377
|
+
typeArguments: [inputs.stakeCoinType],
|
|
378
|
+
arguments: [
|
|
379
|
+
tx.object(inputs.stakedPositionId),
|
|
380
|
+
tx.object(inputs.stakingPoolId),
|
|
381
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
382
|
+
tx.object(this.addresses.objects.version), // Version
|
|
383
|
+
],
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated use unlockTxV2 instead
|
|
388
|
+
* Creates a transaction to unlock a staked position (original version)
|
|
389
|
+
* @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type
|
|
390
|
+
* @returns Transaction command to unlock the position
|
|
391
|
+
*/
|
|
392
|
+
this.unlockTxV1 = (inputs) => {
|
|
205
393
|
const { tx } = inputs;
|
|
206
394
|
return tx.moveCall({
|
|
207
395
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "unlock"),
|
|
@@ -213,10 +401,34 @@ class FarmsApi {
|
|
|
213
401
|
],
|
|
214
402
|
});
|
|
215
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Creates a transaction to unlock a staked position
|
|
406
|
+
* @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type
|
|
407
|
+
* @returns Transaction command to unlock the position
|
|
408
|
+
*/
|
|
409
|
+
this.unlockTxV2 = (inputs) => {
|
|
410
|
+
const { tx } = inputs;
|
|
411
|
+
return tx.moveCall({
|
|
412
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "unlock"),
|
|
413
|
+
typeArguments: [inputs.stakeCoinType],
|
|
414
|
+
arguments: [
|
|
415
|
+
tx.object(inputs.stakedPositionId),
|
|
416
|
+
tx.object(inputs.stakingPoolId),
|
|
417
|
+
tx.object(this.addresses.objects.version),
|
|
418
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
|
|
419
|
+
],
|
|
420
|
+
});
|
|
421
|
+
};
|
|
216
422
|
// =========================================================================
|
|
217
423
|
// Reward Harvesting Transaction Commands
|
|
218
424
|
// =========================================================================
|
|
219
|
-
|
|
425
|
+
/**
|
|
426
|
+
* @deprecated use beginHarvestTxV2 instead
|
|
427
|
+
* Creates a transaction to begin the reward harvesting process (original version)
|
|
428
|
+
* @param inputs Begin harvest parameters including transaction, pool ID, and coin type
|
|
429
|
+
* @returns Transaction object argument for the harvest metadata
|
|
430
|
+
*/
|
|
431
|
+
this.beginHarvestTxV1 = (inputs) => {
|
|
220
432
|
const { tx } = inputs;
|
|
221
433
|
return tx.moveCall({
|
|
222
434
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest"),
|
|
@@ -226,7 +438,30 @@ class FarmsApi {
|
|
|
226
438
|
],
|
|
227
439
|
});
|
|
228
440
|
};
|
|
229
|
-
|
|
441
|
+
/**
|
|
442
|
+
* Creates a transaction to begin the reward harvesting process
|
|
443
|
+
* @param inputs Begin harvest parameters including transaction, position ID, pool ID, and coin type
|
|
444
|
+
* @returns Transaction object argument for the harvest cap
|
|
445
|
+
*/
|
|
446
|
+
this.beginHarvestTxV2 = (inputs) => {
|
|
447
|
+
const { tx } = inputs;
|
|
448
|
+
return tx.moveCall({
|
|
449
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest_tx"),
|
|
450
|
+
typeArguments: [inputs.stakeCoinType],
|
|
451
|
+
arguments: [
|
|
452
|
+
tx.object(inputs.stakedPositionId),
|
|
453
|
+
tx.object(inputs.stakingPoolId),
|
|
454
|
+
tx.object(this.addresses.objects.version), // Version
|
|
455
|
+
],
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated use harvestRewardsTxV2 instead
|
|
460
|
+
* Creates a transaction to harvest rewards from a staked position (original version)
|
|
461
|
+
* @param inputs Harvest parameters including transaction, position ID, pool ID, harvest metadata, stake coin type, and reward coin type
|
|
462
|
+
* @returns Transaction object argument for the harvested rewards
|
|
463
|
+
*/
|
|
464
|
+
this.harvestRewardsTxV1 = (inputs) => {
|
|
230
465
|
const { tx, harvestedRewardsEventMetadataId } = inputs;
|
|
231
466
|
return tx.moveCall({
|
|
232
467
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"),
|
|
@@ -241,7 +476,34 @@ class FarmsApi {
|
|
|
241
476
|
],
|
|
242
477
|
});
|
|
243
478
|
};
|
|
244
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Creates a transaction to harvest rewards from a staked position
|
|
481
|
+
* @param inputs Harvest parameters including transaction, harvest cap, position ID, pool ID, stake coin type, and reward coin type
|
|
482
|
+
* @returns Transaction object argument for the harvested rewards
|
|
483
|
+
*/
|
|
484
|
+
this.harvestRewardsTxV2 = (inputs) => {
|
|
485
|
+
const { tx, harvestRewardsCap } = inputs;
|
|
486
|
+
return tx.moveCall({
|
|
487
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"),
|
|
488
|
+
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
489
|
+
arguments: [
|
|
490
|
+
typeof harvestRewardsCap === "string"
|
|
491
|
+
? tx.object(harvestRewardsCap)
|
|
492
|
+
: harvestRewardsCap,
|
|
493
|
+
tx.object(inputs.stakedPositionId),
|
|
494
|
+
tx.object(inputs.stakingPoolId),
|
|
495
|
+
tx.object(this.addresses.objects.version),
|
|
496
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
|
|
497
|
+
],
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* @deprecated use endHarvestTxV2 instead
|
|
502
|
+
* Creates a transaction to end the reward harvesting process (original version)
|
|
503
|
+
* @param inputs End harvest parameters including transaction and harvest metadata
|
|
504
|
+
* @returns Transaction command to end the harvest
|
|
505
|
+
*/
|
|
506
|
+
this.endHarvestTxV1 = (inputs) => {
|
|
245
507
|
const { tx, harvestedRewardsEventMetadataId } = inputs;
|
|
246
508
|
return tx.moveCall({
|
|
247
509
|
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest"),
|
|
@@ -253,13 +515,37 @@ class FarmsApi {
|
|
|
253
515
|
],
|
|
254
516
|
});
|
|
255
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* Creates a transaction to end the reward harvesting process
|
|
520
|
+
* @param inputs End harvest parameters including transaction and harvest cap
|
|
521
|
+
* @returns Transaction command to end the harvest
|
|
522
|
+
*/
|
|
523
|
+
this.endHarvestTxV2 = (inputs) => {
|
|
524
|
+
const { tx, harvestRewardsCap } = inputs;
|
|
525
|
+
return tx.moveCall({
|
|
526
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest_tx"),
|
|
527
|
+
typeArguments: [],
|
|
528
|
+
arguments: [
|
|
529
|
+
typeof harvestRewardsCap === "string"
|
|
530
|
+
? tx.object(harvestRewardsCap)
|
|
531
|
+
: harvestRewardsCap,
|
|
532
|
+
tx.object(this.addresses.objects.version), // Version
|
|
533
|
+
],
|
|
534
|
+
});
|
|
535
|
+
};
|
|
256
536
|
// =========================================================================
|
|
257
537
|
// Staking Pool Creation Transaction Commands
|
|
258
538
|
// =========================================================================
|
|
259
|
-
|
|
539
|
+
/**
|
|
540
|
+
* @deprecated use newStakingPoolTxV2 instead
|
|
541
|
+
* Creates a transaction for the deprecated version of staking pool creation
|
|
542
|
+
* @param inputs Pool creation parameters including transaction, lock enforcement, durations, multiplier, stake amount, and coin type
|
|
543
|
+
* @returns Transaction objects for the vault and owner cap
|
|
544
|
+
*/
|
|
545
|
+
this.newStakingPoolTxV1 = (inputs) => {
|
|
260
546
|
const { tx } = inputs;
|
|
261
547
|
return tx.moveCall({
|
|
262
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
548
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "new"),
|
|
263
549
|
typeArguments: [inputs.stakeCoinType],
|
|
264
550
|
arguments: [
|
|
265
551
|
tx.pure.u64(inputs.lockEnforcement === "Strict" ? 0 : 1),
|
|
@@ -270,10 +556,53 @@ class FarmsApi {
|
|
|
270
556
|
],
|
|
271
557
|
});
|
|
272
558
|
};
|
|
273
|
-
|
|
559
|
+
/**
|
|
560
|
+
* Creates a transaction for the current version of staking pool creation
|
|
561
|
+
* @param inputs Pool creation parameters including transaction, lock enforcements array, durations, multiplier, stake amount, and coin type
|
|
562
|
+
* @returns Transaction objects for the vault and authority cap
|
|
563
|
+
*/
|
|
564
|
+
this.newStakingPoolTxV2 = (inputs) => {
|
|
565
|
+
const { tx } = inputs;
|
|
566
|
+
return tx.moveCall({
|
|
567
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "new"),
|
|
568
|
+
typeArguments: [inputs.stakeCoinType],
|
|
569
|
+
arguments: [
|
|
570
|
+
tx.object(this.addresses.objects.version),
|
|
571
|
+
tx.pure.vector("u8", inputs.lockEnforcements.map((lockEnforcement) => lockEnforcement === "Strict" ? 0 : 1)),
|
|
572
|
+
tx.pure.u64(inputs.minLockDurationMs),
|
|
573
|
+
tx.pure.u64(inputs.maxLockDurationMs),
|
|
574
|
+
tx.pure.u64(inputs.maxLockMultiplier),
|
|
575
|
+
tx.pure.u64(inputs.minStakeAmount),
|
|
576
|
+
],
|
|
577
|
+
});
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* @deprecated use shareStakingPoolTxV2 instead
|
|
581
|
+
* Creates a transaction to share a staking pool, making it public
|
|
582
|
+
* @param inputs Share pool parameters including transaction, pool ID, and coin type
|
|
583
|
+
* @returns Transaction command to share the pool
|
|
584
|
+
*/
|
|
585
|
+
this.shareStakingPoolTxV1 = (inputs) => {
|
|
586
|
+
const { tx, stakingPoolId } = inputs;
|
|
587
|
+
return tx.moveCall({
|
|
588
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "share_vault"),
|
|
589
|
+
typeArguments: [inputs.stakeCoinType],
|
|
590
|
+
arguments: [
|
|
591
|
+
typeof stakingPoolId === "string"
|
|
592
|
+
? tx.object(stakingPoolId)
|
|
593
|
+
: stakingPoolId, // AfterburnerVault
|
|
594
|
+
],
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* Creates a transaction to share a staking pool, making it public
|
|
599
|
+
* @param inputs Share pool parameters including transaction, pool ID, and coin type
|
|
600
|
+
* @returns Transaction command to share the pool
|
|
601
|
+
*/
|
|
602
|
+
this.shareStakingPoolTxV2 = (inputs) => {
|
|
274
603
|
const { tx, stakingPoolId } = inputs;
|
|
275
604
|
return tx.moveCall({
|
|
276
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.
|
|
605
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "share"),
|
|
277
606
|
typeArguments: [inputs.stakeCoinType],
|
|
278
607
|
arguments: [
|
|
279
608
|
typeof stakingPoolId === "string"
|
|
@@ -282,10 +611,16 @@ class FarmsApi {
|
|
|
282
611
|
],
|
|
283
612
|
});
|
|
284
613
|
};
|
|
285
|
-
|
|
614
|
+
/**
|
|
615
|
+
* @deprecated use transferOwnerCapTxV2 instead
|
|
616
|
+
* Creates a transaction to transfer ownership of a staking pool
|
|
617
|
+
* @param inputs Transfer parameters including transaction, owner cap ID, and recipient address
|
|
618
|
+
* @returns Transaction command to transfer the owner cap
|
|
619
|
+
*/
|
|
620
|
+
this.transferOwnerCapTxV1 = (inputs) => {
|
|
286
621
|
const { tx, ownerCapId } = inputs;
|
|
287
622
|
return tx.moveCall({
|
|
288
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
623
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "transfer_owner_cap"),
|
|
289
624
|
typeArguments: [],
|
|
290
625
|
arguments: [
|
|
291
626
|
typeof ownerCapId === "string"
|
|
@@ -295,10 +630,16 @@ class FarmsApi {
|
|
|
295
630
|
],
|
|
296
631
|
});
|
|
297
632
|
};
|
|
298
|
-
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated use grantOneTimeAdminCapTxV2 instead
|
|
635
|
+
* Creates a transaction to grant a one-time admin capability for a staking pool (original version)
|
|
636
|
+
* @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type
|
|
637
|
+
* @returns Transaction command to grant the one-time admin cap
|
|
638
|
+
*/
|
|
639
|
+
this.grantOneTimeAdminCapTxV1 = (inputs) => {
|
|
299
640
|
const { tx, ownerCapId } = inputs;
|
|
300
641
|
return tx.moveCall({
|
|
301
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
642
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "grant_one_time_admin_cap"),
|
|
302
643
|
typeArguments: [inputs.rewardCoinType],
|
|
303
644
|
arguments: [
|
|
304
645
|
typeof ownerCapId === "string"
|
|
@@ -308,19 +649,45 @@ class FarmsApi {
|
|
|
308
649
|
],
|
|
309
650
|
});
|
|
310
651
|
};
|
|
652
|
+
/**
|
|
653
|
+
* Creates a transaction to grant a one-time admin capability for a staking pool
|
|
654
|
+
* @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type
|
|
655
|
+
* @returns Transaction command to grant the one-time admin cap
|
|
656
|
+
*/
|
|
657
|
+
this.grantOneTimeAdminCapTxV2 = (inputs) => {
|
|
658
|
+
const { tx, ownerCapId } = inputs;
|
|
659
|
+
return tx.moveCall({
|
|
660
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "grant_one_time_admin_cap"),
|
|
661
|
+
typeArguments: [inputs.rewardCoinType],
|
|
662
|
+
arguments: [
|
|
663
|
+
typeof ownerCapId === "string"
|
|
664
|
+
? tx.object(ownerCapId)
|
|
665
|
+
: ownerCapId,
|
|
666
|
+
tx.object(this.addresses.objects.version),
|
|
667
|
+
tx.pure.address(inputs.recipientAddress),
|
|
668
|
+
],
|
|
669
|
+
});
|
|
670
|
+
};
|
|
311
671
|
// =========================================================================
|
|
312
672
|
// Staking Pool Mutation Transaction Commands
|
|
313
673
|
// =========================================================================
|
|
314
|
-
|
|
674
|
+
/**
|
|
675
|
+
* @deprecated use initializeStakingPoolRewardTxV2 instead
|
|
676
|
+
* Creates a transaction to initialize rewards for a staking pool (original version)
|
|
677
|
+
* @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type
|
|
678
|
+
* @returns Transaction command to initialize the reward
|
|
679
|
+
*/
|
|
680
|
+
this.initializeStakingPoolRewardTxV1 = (inputs) => {
|
|
315
681
|
const { tx, rewardCoinId } = inputs;
|
|
682
|
+
const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
|
|
683
|
+
const capId = FarmsApi.farmCapId(inputs);
|
|
316
684
|
return tx.moveCall({
|
|
317
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
: "")),
|
|
685
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap
|
|
686
|
+
? "initialize_reward_and_consume_admin_cap"
|
|
687
|
+
: "initialize_reward"),
|
|
321
688
|
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
322
689
|
arguments: [
|
|
323
|
-
tx.object(
|
|
690
|
+
tx.object(capId),
|
|
324
691
|
tx.object(inputs.stakingPoolId),
|
|
325
692
|
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
326
693
|
typeof rewardCoinId === "string"
|
|
@@ -332,54 +699,185 @@ class FarmsApi {
|
|
|
332
699
|
],
|
|
333
700
|
});
|
|
334
701
|
};
|
|
335
|
-
|
|
702
|
+
/**
|
|
703
|
+
* Creates a transaction to initialize rewards for a staking pool
|
|
704
|
+
* @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type
|
|
705
|
+
* @returns Transaction command to initialize the reward
|
|
706
|
+
*/
|
|
707
|
+
this.initializeStakingPoolRewardTxV2 = (inputs) => {
|
|
708
|
+
const { tx, rewardCoinId } = inputs;
|
|
709
|
+
const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
|
|
710
|
+
const capId = FarmsApi.farmCapId(inputs);
|
|
711
|
+
return tx.moveCall({
|
|
712
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap
|
|
713
|
+
? "initialize_reward_and_consume_admin_cap"
|
|
714
|
+
: "initialize_reward"),
|
|
715
|
+
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
716
|
+
arguments: [
|
|
717
|
+
tx.object(capId),
|
|
718
|
+
tx.object(inputs.stakingPoolId),
|
|
719
|
+
tx.object(this.addresses.objects.version),
|
|
720
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
721
|
+
typeof rewardCoinId === "string"
|
|
722
|
+
? tx.object(rewardCoinId)
|
|
723
|
+
: rewardCoinId,
|
|
724
|
+
tx.pure.u64(inputs.emissionScheduleMs),
|
|
725
|
+
tx.pure.u64(inputs.emissionRate),
|
|
726
|
+
tx.pure.u64(inputs.emissionDelayTimestampMs),
|
|
727
|
+
],
|
|
728
|
+
});
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* @deprecated use topUpStakingPoolRewardTxV2 instead
|
|
732
|
+
* Creates a transaction to add more rewards to a staking pool (original version)
|
|
733
|
+
* @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type
|
|
734
|
+
* @returns Transaction command to add rewards
|
|
735
|
+
*/
|
|
736
|
+
this.topUpStakingPoolRewardTxV1 = (inputs) => {
|
|
737
|
+
const { tx, rewardCoinId } = inputs;
|
|
738
|
+
const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
|
|
739
|
+
const capId = FarmsApi.farmCapId(inputs);
|
|
740
|
+
return tx.moveCall({
|
|
741
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap
|
|
742
|
+
? "add_reward_and_consume_admin_cap"
|
|
743
|
+
: "add_reward"),
|
|
744
|
+
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
745
|
+
arguments: [
|
|
746
|
+
tx.object(capId),
|
|
747
|
+
tx.object(inputs.stakingPoolId),
|
|
748
|
+
typeof rewardCoinId === "string"
|
|
749
|
+
? tx.object(rewardCoinId)
|
|
750
|
+
: rewardCoinId, // Coin
|
|
751
|
+
],
|
|
752
|
+
});
|
|
753
|
+
};
|
|
754
|
+
/**
|
|
755
|
+
* Creates a transaction to add more rewards to a staking pool
|
|
756
|
+
* @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type
|
|
757
|
+
* @returns Transaction command to add rewards
|
|
758
|
+
*/
|
|
759
|
+
this.topUpStakingPoolRewardTxV2 = (inputs) => {
|
|
336
760
|
const { tx, rewardCoinId } = inputs;
|
|
761
|
+
const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
|
|
762
|
+
const capId = FarmsApi.farmCapId(inputs);
|
|
337
763
|
return tx.moveCall({
|
|
338
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
: "")),
|
|
764
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap
|
|
765
|
+
? "add_reward_and_consume_admin_cap"
|
|
766
|
+
: "add_reward"),
|
|
342
767
|
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
343
768
|
arguments: [
|
|
344
|
-
tx.object(
|
|
769
|
+
tx.object(capId),
|
|
345
770
|
tx.object(inputs.stakingPoolId),
|
|
771
|
+
tx.object(this.addresses.objects.version),
|
|
346
772
|
typeof rewardCoinId === "string"
|
|
347
773
|
? tx.object(rewardCoinId)
|
|
348
774
|
: rewardCoinId, // Coin
|
|
349
775
|
],
|
|
350
776
|
});
|
|
351
777
|
};
|
|
352
|
-
|
|
778
|
+
/**
|
|
779
|
+
* @deprecated use increaseStakingPoolRewardEmissionsTxV2 instead
|
|
780
|
+
* Creates a transaction to increase the emission rate for a staking pool reward (original version)
|
|
781
|
+
* @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type
|
|
782
|
+
* @returns Transaction command to update emissions
|
|
783
|
+
*/
|
|
784
|
+
this.increaseStakingPoolRewardEmissionsTxV1 = (inputs) => {
|
|
785
|
+
const { tx } = inputs;
|
|
786
|
+
return tx.moveCall({
|
|
787
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "update_emissions_for"),
|
|
788
|
+
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
789
|
+
arguments: [
|
|
790
|
+
tx.object(inputs.ownerCapId),
|
|
791
|
+
tx.object(inputs.stakingPoolId),
|
|
792
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
793
|
+
tx.pure.u64(inputs.emissionScheduleMs),
|
|
794
|
+
tx.pure.u64(inputs.emissionRate),
|
|
795
|
+
],
|
|
796
|
+
});
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Creates a transaction to increase the emission rate for a staking pool reward
|
|
800
|
+
* @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type
|
|
801
|
+
* @returns Transaction command to update emissions
|
|
802
|
+
*/
|
|
803
|
+
this.increaseStakingPoolRewardEmissionsTxV2 = (inputs) => {
|
|
353
804
|
const { tx } = inputs;
|
|
354
805
|
return tx.moveCall({
|
|
355
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.
|
|
806
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "update_emission_schedule"),
|
|
356
807
|
typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
|
|
357
808
|
arguments: [
|
|
358
809
|
tx.object(inputs.ownerCapId),
|
|
359
810
|
tx.object(inputs.stakingPoolId),
|
|
811
|
+
tx.object(this.addresses.objects.version),
|
|
360
812
|
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
361
813
|
tx.pure.u64(inputs.emissionScheduleMs),
|
|
362
814
|
tx.pure.u64(inputs.emissionRate),
|
|
363
815
|
],
|
|
364
816
|
});
|
|
365
817
|
};
|
|
818
|
+
/**
|
|
819
|
+
* @deprecated use setStakingPoolMinStakeAmountTxV2 instead
|
|
820
|
+
* Creates a transaction to set the minimum stake amount for a staking pool (original version)
|
|
821
|
+
* @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type
|
|
822
|
+
* @returns Transaction command to set the minimum stake amount
|
|
823
|
+
*/
|
|
824
|
+
this.setStakingPoolMinStakeAmountTxV1 = (inputs) => {
|
|
825
|
+
const { tx } = inputs;
|
|
826
|
+
return tx.moveCall({
|
|
827
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "set_min_stake_amount"),
|
|
828
|
+
typeArguments: [inputs.stakeCoinType],
|
|
829
|
+
arguments: [
|
|
830
|
+
tx.object(inputs.ownerCapId),
|
|
831
|
+
tx.object(inputs.stakingPoolId),
|
|
832
|
+
tx.pure.u64(inputs.minStakeAmount),
|
|
833
|
+
],
|
|
834
|
+
});
|
|
835
|
+
};
|
|
836
|
+
/**
|
|
837
|
+
* Creates a transaction to set the minimum stake amount for a staking pool
|
|
838
|
+
* @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type
|
|
839
|
+
* @returns Transaction command to set the minimum stake amount
|
|
840
|
+
*/
|
|
841
|
+
this.setStakingPoolMinStakeAmountTxV2 = (inputs) => {
|
|
842
|
+
const { tx } = inputs;
|
|
843
|
+
return tx.moveCall({
|
|
844
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "set_min_stake_amount"),
|
|
845
|
+
typeArguments: [inputs.stakeCoinType],
|
|
846
|
+
arguments: [
|
|
847
|
+
tx.object(inputs.ownerCapId),
|
|
848
|
+
tx.object(inputs.stakingPoolId),
|
|
849
|
+
tx.object(this.addresses.objects.version),
|
|
850
|
+
tx.pure.u64(inputs.minStakeAmount),
|
|
851
|
+
],
|
|
852
|
+
});
|
|
853
|
+
};
|
|
366
854
|
// =========================================================================
|
|
367
855
|
// Staking Pool Inspection Transaction Commands
|
|
368
856
|
// =========================================================================
|
|
369
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Creates a transaction to check if a staking pool is unlocked
|
|
859
|
+
* @param inputs Check parameters including transaction, pool ID, and coin type
|
|
860
|
+
* @returns Transaction object argument for the boolean result
|
|
861
|
+
*/
|
|
862
|
+
this.isVaultUnlockedTxV1 = (inputs) => {
|
|
370
863
|
const { tx } = inputs;
|
|
371
864
|
return tx.moveCall({
|
|
372
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
865
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "is_vault_unlocked"),
|
|
373
866
|
typeArguments: [inputs.stakeCoinType],
|
|
374
867
|
arguments: [
|
|
375
868
|
tx.object(inputs.stakingPoolId), // AfterburnerVault
|
|
376
869
|
],
|
|
377
870
|
});
|
|
378
871
|
};
|
|
379
|
-
|
|
872
|
+
/**
|
|
873
|
+
* Creates a transaction to get the remaining rewards for a staking pool
|
|
874
|
+
* @param inputs Remaining rewards parameters including transaction, pool ID, and coin type
|
|
875
|
+
* @returns Transaction object argument for the vector of remaining rewards
|
|
876
|
+
*/
|
|
877
|
+
this.remainingRewardsTxV1 = (inputs) => {
|
|
380
878
|
const { tx } = inputs;
|
|
381
879
|
return tx.moveCall({
|
|
382
|
-
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.
|
|
880
|
+
target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "remaining_rewards"),
|
|
383
881
|
typeArguments: [inputs.stakeCoinType],
|
|
384
882
|
arguments: [
|
|
385
883
|
tx.object(inputs.stakingPoolId), // AfterburnerVault
|
|
@@ -392,7 +890,34 @@ class FarmsApi {
|
|
|
392
890
|
// =========================================================================
|
|
393
891
|
// Staking Transactions
|
|
394
892
|
// =========================================================================
|
|
395
|
-
|
|
893
|
+
/**
|
|
894
|
+
* @deprecated use fetchBuildStakeTxV2 instead
|
|
895
|
+
* Builds a complete transaction for staking coins
|
|
896
|
+
* @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type
|
|
897
|
+
* @returns Complete transaction ready for signing and execution
|
|
898
|
+
*/
|
|
899
|
+
this.fetchBuildStakeTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
900
|
+
const { walletAddress, isSponsoredTx } = inputs;
|
|
901
|
+
const tx = new transactions_1.Transaction();
|
|
902
|
+
tx.setSender(walletAddress);
|
|
903
|
+
const stakeCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
904
|
+
tx,
|
|
905
|
+
walletAddress,
|
|
906
|
+
coinType: inputs.stakeCoinType,
|
|
907
|
+
coinAmount: inputs.stakeAmount,
|
|
908
|
+
isSponsoredTx,
|
|
909
|
+
});
|
|
910
|
+
const stakedPosition = this.stakeTxV1(Object.assign(Object.assign({}, inputs), { tx,
|
|
911
|
+
stakeCoinId }));
|
|
912
|
+
tx.transferObjects([stakedPosition], walletAddress);
|
|
913
|
+
return tx;
|
|
914
|
+
});
|
|
915
|
+
/**
|
|
916
|
+
* Builds a complete transaction for staking coins
|
|
917
|
+
* @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type
|
|
918
|
+
* @returns Complete transaction ready for signing and execution
|
|
919
|
+
*/
|
|
920
|
+
this.fetchBuildStakeTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
396
921
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
397
922
|
const tx = new transactions_1.Transaction();
|
|
398
923
|
tx.setSender(walletAddress);
|
|
@@ -403,11 +928,38 @@ class FarmsApi {
|
|
|
403
928
|
coinAmount: inputs.stakeAmount,
|
|
404
929
|
isSponsoredTx,
|
|
405
930
|
});
|
|
406
|
-
const stakedPosition = this.
|
|
931
|
+
const stakedPosition = this.stakeTxV2(Object.assign(Object.assign({}, inputs), { tx,
|
|
932
|
+
stakeCoinId, lockEnforcement: "Strict" }));
|
|
407
933
|
tx.transferObjects([stakedPosition], walletAddress);
|
|
408
934
|
return tx;
|
|
409
935
|
});
|
|
410
|
-
|
|
936
|
+
/**
|
|
937
|
+
* @deprecated use fetchBuildDepositPrincipalTxV2 instead
|
|
938
|
+
* Builds a complete transaction for depositing additional principal to a staked position
|
|
939
|
+
* @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type
|
|
940
|
+
* @returns Complete transaction ready for signing and execution
|
|
941
|
+
*/
|
|
942
|
+
this.fetchBuildDepositPrincipalTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
943
|
+
const { walletAddress, isSponsoredTx } = inputs;
|
|
944
|
+
const tx = new transactions_1.Transaction();
|
|
945
|
+
tx.setSender(walletAddress);
|
|
946
|
+
const stakeCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
947
|
+
tx,
|
|
948
|
+
walletAddress,
|
|
949
|
+
coinType: inputs.stakeCoinType,
|
|
950
|
+
coinAmount: inputs.depositAmount,
|
|
951
|
+
isSponsoredTx,
|
|
952
|
+
});
|
|
953
|
+
this.depositPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx,
|
|
954
|
+
stakeCoinId }));
|
|
955
|
+
return tx;
|
|
956
|
+
});
|
|
957
|
+
/**
|
|
958
|
+
* Builds a complete transaction for depositing additional principal to a staked position
|
|
959
|
+
* @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type
|
|
960
|
+
* @returns Complete transaction ready for signing and execution
|
|
961
|
+
*/
|
|
962
|
+
this.fetchBuildDepositPrincipalTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
411
963
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
412
964
|
const tx = new transactions_1.Transaction();
|
|
413
965
|
tx.setSender(walletAddress);
|
|
@@ -418,24 +970,49 @@ class FarmsApi {
|
|
|
418
970
|
coinAmount: inputs.depositAmount,
|
|
419
971
|
isSponsoredTx,
|
|
420
972
|
});
|
|
421
|
-
this.
|
|
973
|
+
this.depositPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx,
|
|
422
974
|
stakeCoinId }));
|
|
423
975
|
return tx;
|
|
424
976
|
});
|
|
425
|
-
|
|
977
|
+
/**
|
|
978
|
+
* @deprecated use fetchBuildWithdrawPrincipalTxV2 instead
|
|
979
|
+
* Builds a complete transaction for withdrawing principal from a staked position
|
|
980
|
+
* @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type
|
|
981
|
+
* @returns Complete transaction ready for signing and execution
|
|
982
|
+
*/
|
|
983
|
+
this.fetchBuildWithdrawPrincipalTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
426
984
|
const { walletAddress } = inputs;
|
|
427
985
|
const tx = new transactions_1.Transaction();
|
|
428
986
|
tx.setSender(walletAddress);
|
|
429
|
-
const withdrawnCoin = this.
|
|
987
|
+
const withdrawnCoin = this.withdrawPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx }));
|
|
430
988
|
tx.transferObjects([withdrawnCoin], walletAddress);
|
|
431
989
|
return tx;
|
|
432
990
|
});
|
|
433
|
-
|
|
991
|
+
/**
|
|
992
|
+
* Builds a complete transaction for withdrawing principal from a staked position
|
|
993
|
+
* @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type
|
|
994
|
+
* @returns Complete transaction ready for signing and execution
|
|
995
|
+
*/
|
|
996
|
+
this.fetchBuildWithdrawPrincipalTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
997
|
+
const { walletAddress } = inputs;
|
|
998
|
+
const tx = new transactions_1.Transaction();
|
|
999
|
+
tx.setSender(walletAddress);
|
|
1000
|
+
const withdrawnCoin = this.withdrawPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx }));
|
|
1001
|
+
tx.transferObjects([withdrawnCoin], walletAddress);
|
|
1002
|
+
return tx;
|
|
1003
|
+
});
|
|
1004
|
+
/**
|
|
1005
|
+
* @deprecated use fetchBuildUnstakeTxV2 instead
|
|
1006
|
+
* Builds a complete transaction for unstaking (withdrawing and destroying a position)
|
|
1007
|
+
* @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type
|
|
1008
|
+
* @returns Complete transaction ready for signing and execution
|
|
1009
|
+
*/
|
|
1010
|
+
this.fetchBuildUnstakeTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
434
1011
|
const { walletAddress } = inputs;
|
|
435
1012
|
let tx;
|
|
436
1013
|
if (inputs.rewardCoinTypes.length > 0) {
|
|
437
1014
|
// harvest rewards
|
|
438
|
-
tx = yield this.
|
|
1015
|
+
tx = yield this.fetchBuildHarvestRewardsTxV1(Object.assign(Object.assign({}, inputs), { stakedPositionIds: [inputs.stakedPositionId] }));
|
|
439
1016
|
}
|
|
440
1017
|
else {
|
|
441
1018
|
// no rewards to harvest
|
|
@@ -443,33 +1020,169 @@ class FarmsApi {
|
|
|
443
1020
|
tx.setSender(walletAddress);
|
|
444
1021
|
}
|
|
445
1022
|
// withdraw principal
|
|
446
|
-
const withdrawnCoin = this.
|
|
1023
|
+
const withdrawnCoin = this.withdrawPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx }));
|
|
447
1024
|
tx.transferObjects([withdrawnCoin], walletAddress);
|
|
448
1025
|
// destroy position
|
|
449
|
-
this.
|
|
1026
|
+
this.destroyStakedPositionTxV1({
|
|
1027
|
+
tx,
|
|
1028
|
+
stakingPoolId: inputs.stakingPoolId,
|
|
1029
|
+
stakedPositionId: inputs.stakedPositionId,
|
|
1030
|
+
stakeCoinType: inputs.stakeCoinType,
|
|
1031
|
+
});
|
|
450
1032
|
return tx;
|
|
451
1033
|
});
|
|
452
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* Builds a complete transaction for unstaking (withdrawing and destroying a position)
|
|
1036
|
+
* @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type
|
|
1037
|
+
* @returns Complete transaction ready for signing and execution
|
|
1038
|
+
*/
|
|
1039
|
+
this.fetchBuildUnstakeTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
1040
|
+
const { walletAddress } = inputs;
|
|
1041
|
+
let tx;
|
|
1042
|
+
if (inputs.rewardCoinTypes.length > 0) {
|
|
1043
|
+
// harvest rewards
|
|
1044
|
+
tx = yield this.fetchBuildHarvestRewardsTxV2(Object.assign(Object.assign({}, inputs), { stakedPositionIds: [inputs.stakedPositionId] }));
|
|
1045
|
+
}
|
|
1046
|
+
else {
|
|
1047
|
+
// no rewards to harvest
|
|
1048
|
+
tx = new transactions_1.Transaction();
|
|
1049
|
+
tx.setSender(walletAddress);
|
|
1050
|
+
}
|
|
1051
|
+
// withdraw principal
|
|
1052
|
+
const withdrawnCoin = this.withdrawPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx }));
|
|
1053
|
+
tx.transferObjects([withdrawnCoin], walletAddress);
|
|
1054
|
+
// destroy position
|
|
1055
|
+
this.destroyStakedPositionTxV2({
|
|
1056
|
+
tx,
|
|
1057
|
+
stakedPositionId: inputs.stakedPositionId,
|
|
1058
|
+
stakeCoinType: inputs.stakeCoinType,
|
|
1059
|
+
});
|
|
1060
|
+
return tx;
|
|
1061
|
+
});
|
|
1062
|
+
/**
|
|
1063
|
+
* @deprecated use buildUpdatePositionTxV2 instead
|
|
1064
|
+
* Builds a transaction for updating a staked position
|
|
1065
|
+
* @param parameters for updatePositionTx
|
|
1066
|
+
* @returns Complete transaction ready for signing and execution
|
|
1067
|
+
*/
|
|
1068
|
+
this.buildUpdatePositionTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.updatePositionTxV1);
|
|
1069
|
+
/**
|
|
1070
|
+
* Builds a transaction for updating a staked position
|
|
1071
|
+
* @param parameters for updatePositionTx
|
|
1072
|
+
* @returns Complete transaction ready for signing and execution
|
|
1073
|
+
*/
|
|
1074
|
+
this.buildUpdatePositionTx2 = utils_1.Helpers.transactions.createBuildTxFunc(this.updatePositionTxV2);
|
|
453
1075
|
// =========================================================================
|
|
454
1076
|
// Locking Transactions
|
|
455
1077
|
// =========================================================================
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
* @deprecated use buildLockTxV2 instead
|
|
1080
|
+
* Builds a transaction for locking a staked position
|
|
1081
|
+
* @param parameters for lockTx
|
|
1082
|
+
* @returns Complete transaction ready for signing and execution
|
|
1083
|
+
*/
|
|
1084
|
+
this.buildLockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.lockTxV1);
|
|
1085
|
+
/**
|
|
1086
|
+
* Builds a transaction for locking a staked position
|
|
1087
|
+
* @param parameters for lockTx
|
|
1088
|
+
* @returns Complete transaction ready for signing and execution
|
|
1089
|
+
*/
|
|
1090
|
+
this.buildLockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.lockTxV2);
|
|
1091
|
+
/**
|
|
1092
|
+
* @deprecated use buildRenewLockTxV2 instead
|
|
1093
|
+
* Builds a transaction for renewing the lock on a staked position
|
|
1094
|
+
* @param parameters for renewLockTx
|
|
1095
|
+
* @returns Complete transaction ready for signing and execution
|
|
1096
|
+
*/
|
|
1097
|
+
this.buildRenewLockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.renewLockTxV1);
|
|
1098
|
+
/**
|
|
1099
|
+
* Builds a transaction for renewing the lock on a staked position
|
|
1100
|
+
* @param parameters for renewLockTx
|
|
1101
|
+
* @returns Complete transaction ready for signing and execution
|
|
1102
|
+
*/
|
|
1103
|
+
this.buildRenewLockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.renewLockTxV2);
|
|
1104
|
+
/**
|
|
1105
|
+
* @deprecated use buildUnlockTxV2 instead
|
|
1106
|
+
* Builds a transaction for unlocking a staked position
|
|
1107
|
+
* @param parameters for unlockTx
|
|
1108
|
+
* @returns Complete transaction ready for signing and execution
|
|
1109
|
+
*/
|
|
1110
|
+
this.buildUnlockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.unlockTxV1);
|
|
1111
|
+
/**
|
|
1112
|
+
* Builds a transaction for unlocking a staked position
|
|
1113
|
+
* @param parameters for unlockTx
|
|
1114
|
+
* @returns Complete transaction ready for signing and execution
|
|
1115
|
+
*/
|
|
1116
|
+
this.buildUnlockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.unlockTxV2);
|
|
459
1117
|
// =========================================================================
|
|
460
1118
|
// Reward Harvesting Transactions
|
|
461
1119
|
// =========================================================================
|
|
462
|
-
|
|
1120
|
+
/**
|
|
1121
|
+
* @deprecated use fetchBuildHarvestRewardsTxV2 instead
|
|
1122
|
+
* Builds a complete transaction for harvesting rewards from staked positions
|
|
1123
|
+
* @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag
|
|
1124
|
+
* @returns Complete transaction ready for signing and execution
|
|
1125
|
+
*/
|
|
1126
|
+
this.fetchBuildHarvestRewardsTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
1127
|
+
const { walletAddress, stakedPositionIds } = inputs;
|
|
1128
|
+
const tx = new transactions_1.Transaction();
|
|
1129
|
+
tx.setSender(walletAddress);
|
|
1130
|
+
const harvestRewardsCap = this.beginHarvestTxV1(Object.assign(Object.assign({}, inputs), { tx }));
|
|
1131
|
+
let harvestedCoins = {};
|
|
1132
|
+
for (const stakedPositionId of stakedPositionIds) {
|
|
1133
|
+
for (const rewardCoinType of inputs.rewardCoinTypes) {
|
|
1134
|
+
const harvestedCoin = this.harvestRewardsTxV1(Object.assign(Object.assign({}, inputs), { tx,
|
|
1135
|
+
stakedPositionId,
|
|
1136
|
+
rewardCoinType, harvestedRewardsEventMetadataId: harvestRewardsCap }));
|
|
1137
|
+
if (rewardCoinType in harvestedCoins) {
|
|
1138
|
+
harvestedCoins[rewardCoinType].push(harvestedCoin);
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
harvestedCoins[rewardCoinType] = [harvestedCoin];
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
this.endHarvestTxV1({
|
|
1146
|
+
tx,
|
|
1147
|
+
harvestedRewardsEventMetadataId: harvestRewardsCap,
|
|
1148
|
+
});
|
|
1149
|
+
for (const [coinType, harvestedCoinIds] of Object.entries(harvestedCoins)) {
|
|
1150
|
+
const coinToTransfer = harvestedCoinIds[0];
|
|
1151
|
+
if (harvestedCoinIds.length > 1)
|
|
1152
|
+
tx.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));
|
|
1153
|
+
if (inputs.claimSuiAsAfSui && __1.Coin.isCoinObjectType(coinType)) {
|
|
1154
|
+
this.Provider.Staking().stakeTx({
|
|
1155
|
+
tx,
|
|
1156
|
+
suiCoin: coinToTransfer,
|
|
1157
|
+
withTransfer: true,
|
|
1158
|
+
validatorAddress: this.Provider.Staking().addresses.objects
|
|
1159
|
+
.aftermathValidator,
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
else {
|
|
1163
|
+
tx.transferObjects([coinToTransfer], walletAddress);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return tx;
|
|
1167
|
+
});
|
|
1168
|
+
/**
|
|
1169
|
+
* Builds a complete transaction for harvesting rewards from staked positions
|
|
1170
|
+
* @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag
|
|
1171
|
+
* @returns Complete transaction ready for signing and execution
|
|
1172
|
+
*/
|
|
1173
|
+
this.fetchBuildHarvestRewardsTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
463
1174
|
const { walletAddress, stakedPositionIds } = inputs;
|
|
464
1175
|
const tx = new transactions_1.Transaction();
|
|
465
1176
|
tx.setSender(walletAddress);
|
|
466
|
-
|
|
1177
|
+
// For the first position, begin harvest
|
|
1178
|
+
const firstPositionId = stakedPositionIds[0];
|
|
1179
|
+
const harvestRewardsCap = this.beginHarvestTxV2(Object.assign(Object.assign({}, inputs), { tx, stakedPositionId: firstPositionId }));
|
|
467
1180
|
let harvestedCoins = {};
|
|
468
1181
|
for (const stakedPositionId of stakedPositionIds) {
|
|
469
1182
|
for (const rewardCoinType of inputs.rewardCoinTypes) {
|
|
470
|
-
const harvestedCoin = this.
|
|
1183
|
+
const harvestedCoin = this.harvestRewardsTxV2(Object.assign(Object.assign({}, inputs), { tx,
|
|
471
1184
|
stakedPositionId,
|
|
472
|
-
|
|
1185
|
+
harvestRewardsCap,
|
|
473
1186
|
rewardCoinType }));
|
|
474
1187
|
if (rewardCoinType in harvestedCoins) {
|
|
475
1188
|
harvestedCoins[rewardCoinType].push(harvestedCoin);
|
|
@@ -479,7 +1192,7 @@ class FarmsApi {
|
|
|
479
1192
|
}
|
|
480
1193
|
}
|
|
481
1194
|
}
|
|
482
|
-
this.
|
|
1195
|
+
this.endHarvestTxV2({ tx, harvestRewardsCap });
|
|
483
1196
|
for (const [coinType, harvestedCoinIds] of Object.entries(harvestedCoins)) {
|
|
484
1197
|
const coinToTransfer = harvestedCoinIds[0];
|
|
485
1198
|
if (harvestedCoinIds.length > 1)
|
|
@@ -505,27 +1218,76 @@ class FarmsApi {
|
|
|
505
1218
|
// =========================================================================
|
|
506
1219
|
// Staking Pool Creation Transactions
|
|
507
1220
|
// =========================================================================
|
|
508
|
-
|
|
1221
|
+
/**
|
|
1222
|
+
* @deprecated use fetchBuildCreateStakingPoolTxV2 instead
|
|
1223
|
+
* Builds a complete transaction for creating a new staking pool
|
|
1224
|
+
* @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type
|
|
1225
|
+
* @returns Complete transaction ready for signing and execution
|
|
1226
|
+
*/
|
|
1227
|
+
this.fetchBuildCreateStakingPoolTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
509
1228
|
const { walletAddress } = inputs;
|
|
510
1229
|
const tx = new transactions_1.Transaction();
|
|
511
1230
|
tx.setSender(walletAddress);
|
|
512
|
-
const [stakingPoolId, ownerCapId] = this.
|
|
513
|
-
this.
|
|
1231
|
+
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1(Object.assign(Object.assign({}, inputs), { tx, lockEnforcement: "Strict" }));
|
|
1232
|
+
this.shareStakingPoolTxV1({
|
|
514
1233
|
tx,
|
|
515
1234
|
stakingPoolId,
|
|
516
1235
|
stakeCoinType: inputs.stakeCoinType,
|
|
517
1236
|
});
|
|
518
|
-
this.
|
|
1237
|
+
this.transferOwnerCapTxV1({
|
|
519
1238
|
tx,
|
|
520
1239
|
ownerCapId,
|
|
521
1240
|
recipientAddress: walletAddress,
|
|
522
1241
|
});
|
|
523
1242
|
return tx;
|
|
524
1243
|
});
|
|
1244
|
+
/**
|
|
1245
|
+
* Builds a complete transaction for creating a new staking pool
|
|
1246
|
+
* @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type
|
|
1247
|
+
* @returns Complete transaction ready for signing and execution
|
|
1248
|
+
*/
|
|
1249
|
+
this.fetchBuildCreateStakingPoolTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
1250
|
+
const { walletAddress } = inputs;
|
|
1251
|
+
const tx = new transactions_1.Transaction();
|
|
1252
|
+
tx.setSender(walletAddress);
|
|
1253
|
+
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2(Object.assign(Object.assign({}, inputs), { tx, lockEnforcements: ["Strict"] }));
|
|
1254
|
+
this.shareStakingPoolTxV2({
|
|
1255
|
+
tx,
|
|
1256
|
+
stakingPoolId,
|
|
1257
|
+
stakeCoinType: inputs.stakeCoinType,
|
|
1258
|
+
});
|
|
1259
|
+
tx.transferObjects([ownerCapId], walletAddress);
|
|
1260
|
+
return tx;
|
|
1261
|
+
});
|
|
525
1262
|
// =========================================================================
|
|
526
1263
|
// Staking Pool Mutation Transactions
|
|
527
1264
|
// =========================================================================
|
|
528
|
-
|
|
1265
|
+
/**
|
|
1266
|
+
* @deprecated use fetchBuildInitializeStakingPoolRewardTxV2 instead
|
|
1267
|
+
* Builds a complete transaction for initializing rewards for a staking pool
|
|
1268
|
+
* @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type
|
|
1269
|
+
* @returns Complete transaction ready for signing and execution
|
|
1270
|
+
*/
|
|
1271
|
+
this.fetchBuildInitializeStakingPoolRewardTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
1272
|
+
const { walletAddress, isSponsoredTx } = inputs;
|
|
1273
|
+
const tx = new transactions_1.Transaction();
|
|
1274
|
+
tx.setSender(walletAddress);
|
|
1275
|
+
const rewardCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
1276
|
+
tx,
|
|
1277
|
+
walletAddress,
|
|
1278
|
+
coinType: inputs.rewardCoinType,
|
|
1279
|
+
coinAmount: inputs.rewardAmount,
|
|
1280
|
+
isSponsoredTx,
|
|
1281
|
+
});
|
|
1282
|
+
this.initializeStakingPoolRewardTxV1(Object.assign(Object.assign({}, inputs), { tx, rewardCoinId }));
|
|
1283
|
+
return tx;
|
|
1284
|
+
});
|
|
1285
|
+
/**
|
|
1286
|
+
* Builds a complete transaction for initializing rewards for a staking pool
|
|
1287
|
+
* @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type
|
|
1288
|
+
* @returns Complete transaction ready for signing and execution
|
|
1289
|
+
*/
|
|
1290
|
+
this.fetchBuildInitializeStakingPoolRewardTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
529
1291
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
530
1292
|
const tx = new transactions_1.Transaction();
|
|
531
1293
|
tx.setSender(walletAddress);
|
|
@@ -536,10 +1298,38 @@ class FarmsApi {
|
|
|
536
1298
|
coinAmount: inputs.rewardAmount,
|
|
537
1299
|
isSponsoredTx,
|
|
538
1300
|
});
|
|
539
|
-
this.
|
|
1301
|
+
this.initializeStakingPoolRewardTxV2(Object.assign(Object.assign({}, inputs), { tx, rewardCoinId }));
|
|
1302
|
+
return tx;
|
|
1303
|
+
});
|
|
1304
|
+
/**
|
|
1305
|
+
* @deprecated use fetchBuildTopUpStakingPoolRewardsTxV2 instead
|
|
1306
|
+
* Builds a complete transaction for adding more rewards to a staking pool
|
|
1307
|
+
* @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type
|
|
1308
|
+
* @returns Complete transaction ready for signing and execution
|
|
1309
|
+
*/
|
|
1310
|
+
this.fetchBuildTopUpStakingPoolRewardsTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
1311
|
+
const { walletAddress, isSponsoredTx } = inputs;
|
|
1312
|
+
const tx = new transactions_1.Transaction();
|
|
1313
|
+
tx.setSender(walletAddress);
|
|
1314
|
+
for (const reward of inputs.rewards) {
|
|
1315
|
+
const rewardCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
1316
|
+
tx,
|
|
1317
|
+
walletAddress,
|
|
1318
|
+
coinType: reward.rewardCoinType,
|
|
1319
|
+
coinAmount: reward.rewardAmount,
|
|
1320
|
+
isSponsoredTx,
|
|
1321
|
+
});
|
|
1322
|
+
this.topUpStakingPoolRewardTxV1(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx,
|
|
1323
|
+
rewardCoinId }));
|
|
1324
|
+
}
|
|
540
1325
|
return tx;
|
|
541
1326
|
});
|
|
542
|
-
|
|
1327
|
+
/**
|
|
1328
|
+
* Builds a complete transaction for adding more rewards to a staking pool
|
|
1329
|
+
* @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type
|
|
1330
|
+
* @returns Complete transaction ready for signing and execution
|
|
1331
|
+
*/
|
|
1332
|
+
this.fetchBuildTopUpStakingPoolRewardsTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
543
1333
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
544
1334
|
const tx = new transactions_1.Transaction();
|
|
545
1335
|
tx.setSender(walletAddress);
|
|
@@ -551,21 +1341,66 @@ class FarmsApi {
|
|
|
551
1341
|
coinAmount: reward.rewardAmount,
|
|
552
1342
|
isSponsoredTx,
|
|
553
1343
|
});
|
|
554
|
-
this.
|
|
1344
|
+
this.topUpStakingPoolRewardTxV2(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx,
|
|
555
1345
|
rewardCoinId }));
|
|
556
1346
|
}
|
|
557
1347
|
return tx;
|
|
558
1348
|
});
|
|
559
|
-
|
|
1349
|
+
/**
|
|
1350
|
+
* @deprecated use fetchIncreaseStakingPoolRewardsEmissionsTxV2 instead
|
|
1351
|
+
* Builds a complete transaction for increasing the emission rate of rewards for a staking pool
|
|
1352
|
+
* @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type
|
|
1353
|
+
* @returns Complete transaction ready for signing and execution
|
|
1354
|
+
*/
|
|
1355
|
+
this.fetchIncreaseStakingPoolRewardsEmissionsTxV1 = (inputs) => {
|
|
560
1356
|
const { walletAddress } = inputs;
|
|
561
1357
|
const tx = new transactions_1.Transaction();
|
|
562
1358
|
tx.setSender(walletAddress);
|
|
563
1359
|
for (const reward of inputs.rewards) {
|
|
564
|
-
this.
|
|
1360
|
+
this.increaseStakingPoolRewardEmissionsTxV1(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx }));
|
|
565
1361
|
}
|
|
566
1362
|
return tx;
|
|
567
1363
|
};
|
|
568
|
-
|
|
1364
|
+
/**
|
|
1365
|
+
* Builds a complete transaction for increasing the emission rate of rewards for a staking pool
|
|
1366
|
+
* @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type
|
|
1367
|
+
* @returns Complete transaction ready for signing and execution
|
|
1368
|
+
*/
|
|
1369
|
+
this.fetchIncreaseStakingPoolRewardsEmissionsTxV2 = (inputs) => {
|
|
1370
|
+
const { walletAddress } = inputs;
|
|
1371
|
+
const tx = new transactions_1.Transaction();
|
|
1372
|
+
tx.setSender(walletAddress);
|
|
1373
|
+
for (const reward of inputs.rewards) {
|
|
1374
|
+
this.increaseStakingPoolRewardEmissionsTxV2(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx }));
|
|
1375
|
+
}
|
|
1376
|
+
return tx;
|
|
1377
|
+
};
|
|
1378
|
+
/**
|
|
1379
|
+
* @deprecated use buildSetStakingPoolMinStakeAmountTxV2 instead
|
|
1380
|
+
* Builds a transaction for setting the minimum stake amount for a staking pool
|
|
1381
|
+
* @param parameters for setStakingPoolMinStakeAmountTx
|
|
1382
|
+
* @returns Complete transaction ready for signing and execution
|
|
1383
|
+
*/
|
|
1384
|
+
this.buildSetStakingPoolMinStakeAmountTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.setStakingPoolMinStakeAmountTxV1);
|
|
1385
|
+
/**
|
|
1386
|
+
* Builds a transaction for setting the minimum stake amount for a staking pool
|
|
1387
|
+
* @param parameters for setStakingPoolMinStakeAmountTx
|
|
1388
|
+
* @returns Complete transaction ready for signing and execution
|
|
1389
|
+
*/
|
|
1390
|
+
this.buildSetStakingPoolMinStakeAmountTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.setStakingPoolMinStakeAmountTxV2);
|
|
1391
|
+
/**
|
|
1392
|
+
* @deprecated use buildGrantOneTimeAdminCapTxV2 instead
|
|
1393
|
+
* Builds a transaction for granting a one-time admin capability for a staking pool
|
|
1394
|
+
* @param parameters for grantOneTimeAdminCapTx
|
|
1395
|
+
* @returns Complete transaction ready for signing and execution
|
|
1396
|
+
*/
|
|
1397
|
+
this.buildGrantOneTimeAdminCapTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV1);
|
|
1398
|
+
/**
|
|
1399
|
+
* Builds a transaction for granting a one-time admin capability for a staking pool
|
|
1400
|
+
* @param parameters for grantOneTimeAdminCapTx
|
|
1401
|
+
* @returns Complete transaction ready for signing and execution
|
|
1402
|
+
*/
|
|
1403
|
+
this.buildGrantOneTimeAdminCapTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV2);
|
|
569
1404
|
// =========================================================================
|
|
570
1405
|
// Private Methods
|
|
571
1406
|
// =========================================================================
|
|
@@ -575,65 +1410,159 @@ class FarmsApi {
|
|
|
575
1410
|
// =========================================================================
|
|
576
1411
|
// Vault Creation
|
|
577
1412
|
// =========================================================================
|
|
578
|
-
this.
|
|
1413
|
+
this.eventWrapperType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, "Event");
|
|
1414
|
+
/**
|
|
1415
|
+
* Creates the event type for vault creation events
|
|
1416
|
+
* @returns Fully qualified event type string
|
|
1417
|
+
*/
|
|
1418
|
+
this.createdVaultEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1419
|
+
? this.addresses.packages.vaultsInitial
|
|
1420
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.createdVault, version === 1 ? undefined : this.eventWrapperType());
|
|
579
1421
|
// =========================================================================
|
|
580
1422
|
// Vault Mutation
|
|
581
1423
|
// =========================================================================
|
|
582
|
-
|
|
583
|
-
|
|
1424
|
+
/**
|
|
1425
|
+
* Creates the event type for reward initialization events
|
|
1426
|
+
* @returns Fully qualified event type string
|
|
1427
|
+
*/
|
|
1428
|
+
this.initializedRewardEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1429
|
+
? this.addresses.packages.vaultsInitial
|
|
1430
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.initializedReward, version === 1 ? undefined : this.eventWrapperType());
|
|
1431
|
+
/**
|
|
1432
|
+
* Creates the event type for reward addition events
|
|
1433
|
+
* @returns Fully qualified event type string
|
|
1434
|
+
*/
|
|
1435
|
+
this.addedRewardEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1436
|
+
? this.addresses.packages.vaultsInitial
|
|
1437
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.addedReward, version === 1 ? undefined : this.eventWrapperType());
|
|
1438
|
+
/**
|
|
1439
|
+
* Creates the event type for emission increase events
|
|
1440
|
+
* @returns Fully qualified event type string
|
|
1441
|
+
*/
|
|
584
1442
|
this.increasedEmissionsEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.increasedEmissions);
|
|
1443
|
+
/**
|
|
1444
|
+
* Creates the event type for emission update events
|
|
1445
|
+
* @returns Fully qualified event type string
|
|
1446
|
+
*/
|
|
1447
|
+
this.updatedEmissionsEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.increasedEmissions, this.eventWrapperType());
|
|
585
1448
|
// =========================================================================
|
|
586
1449
|
// Staking Position Creation
|
|
587
1450
|
// =========================================================================
|
|
588
|
-
|
|
589
|
-
|
|
1451
|
+
/**
|
|
1452
|
+
* Creates the event type for strict staking events
|
|
1453
|
+
* @returns Fully qualified event type string
|
|
1454
|
+
*/
|
|
1455
|
+
this.stakedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1456
|
+
? this.addresses.packages.vaultsInitial
|
|
1457
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.staked, version === 1 ? undefined : this.eventWrapperType());
|
|
1458
|
+
/**
|
|
1459
|
+
* Creates the event type for relaxed staking events
|
|
1460
|
+
* @returns Fully qualified event type string
|
|
1461
|
+
*/
|
|
1462
|
+
this.stakedRelaxedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1463
|
+
? this.addresses.packages.vaultsInitial
|
|
1464
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.stakedRelaxed, version === 1 ? undefined : this.eventWrapperType());
|
|
590
1465
|
// =========================================================================
|
|
591
1466
|
// Staking Position Locking
|
|
592
1467
|
// =========================================================================
|
|
593
|
-
|
|
594
|
-
|
|
1468
|
+
/**
|
|
1469
|
+
* Creates the event type for position locking events
|
|
1470
|
+
* @returns Fully qualified event type string
|
|
1471
|
+
*/
|
|
1472
|
+
this.lockedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1473
|
+
? this.addresses.packages.vaultsInitial
|
|
1474
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.locked, version === 1 ? undefined : this.eventWrapperType());
|
|
1475
|
+
/**
|
|
1476
|
+
* Creates the event type for position unlocking events
|
|
1477
|
+
* @returns Fully qualified event type string
|
|
1478
|
+
*/
|
|
1479
|
+
this.unlockedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1480
|
+
? this.addresses.packages.vaultsInitial
|
|
1481
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.unlocked, version === 1 ? undefined : this.eventWrapperType());
|
|
595
1482
|
// =========================================================================
|
|
596
1483
|
// Staking Position Staking
|
|
597
1484
|
// =========================================================================
|
|
598
|
-
|
|
599
|
-
|
|
1485
|
+
/**
|
|
1486
|
+
* Creates the event type for principal deposit events
|
|
1487
|
+
* @returns Fully qualified event type string
|
|
1488
|
+
*/
|
|
1489
|
+
this.depositedPrincipalEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1490
|
+
? this.addresses.packages.vaultsInitial
|
|
1491
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.depositedPrincipal, version === 1 ? undefined : this.eventWrapperType());
|
|
1492
|
+
/**
|
|
1493
|
+
* Creates the event type for principal withdrawal events
|
|
1494
|
+
* @returns Fully qualified event type string
|
|
1495
|
+
*/
|
|
1496
|
+
this.withdrewPrincipalEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1497
|
+
? this.addresses.packages.vaultsInitial
|
|
1498
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.withdrewPrincipal, version === 1 ? undefined : this.eventWrapperType());
|
|
600
1499
|
// =========================================================================
|
|
601
1500
|
// Staking Position Reward Harvesting
|
|
602
1501
|
// =========================================================================
|
|
603
|
-
|
|
1502
|
+
/**
|
|
1503
|
+
* Creates the event type for reward harvesting events
|
|
1504
|
+
* @returns Fully qualified event type string
|
|
1505
|
+
*/
|
|
1506
|
+
this.harvestedRewardsEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
|
|
1507
|
+
? this.addresses.packages.vaultsInitial
|
|
1508
|
+
: this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.harvestedRewards, version === 1 ? undefined : this.eventWrapperType());
|
|
604
1509
|
const addresses = this.Provider.addresses.farms;
|
|
605
1510
|
if (!addresses)
|
|
606
1511
|
throw new Error("not all required addresses have been set in provider");
|
|
607
1512
|
this.addresses = addresses;
|
|
608
1513
|
this.objectTypes = {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
1514
|
+
stakedPositionV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,
|
|
1515
|
+
stakingPoolOwnerCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OwnerCap`,
|
|
1516
|
+
stakingPoolOneTimeAdminCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OneTimeAdminCap`,
|
|
1517
|
+
stakedPositionV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,
|
|
1518
|
+
stakingPoolOwnerCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::AuthorityCap<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::VAULT<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::ADMIN>>`,
|
|
1519
|
+
// NOTE: will this work with `<phantom Role, phantom Reward>` ?
|
|
1520
|
+
stakingPoolOneTimeAdminCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.vaultV2}::OneTime`,
|
|
612
1521
|
};
|
|
613
1522
|
this.eventTypes = {
|
|
1523
|
+
// v1
|
|
614
1524
|
// staking pools
|
|
615
1525
|
// creation
|
|
616
|
-
|
|
1526
|
+
createdVaultV1: this.createdVaultEventType(1),
|
|
617
1527
|
// mutation
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
1528
|
+
initializedRewardV1: this.initializedRewardEventType(1),
|
|
1529
|
+
addedRewardV1: this.addedRewardEventType(1),
|
|
1530
|
+
increasedEmissionsV1: this.increasedEmissionsEventType(),
|
|
621
1531
|
// staking positions
|
|
622
1532
|
// creation
|
|
623
|
-
|
|
624
|
-
|
|
1533
|
+
stakedV1: this.stakedEventType(1),
|
|
1534
|
+
stakedRelaxedV1: this.stakedRelaxedEventType(1),
|
|
625
1535
|
// locking
|
|
626
|
-
|
|
627
|
-
|
|
1536
|
+
lockedV1: this.lockedEventType(1),
|
|
1537
|
+
unlockedV1: this.unlockedEventType(1),
|
|
628
1538
|
// staking
|
|
629
|
-
|
|
630
|
-
|
|
1539
|
+
depositedPrincipalV1: this.depositedPrincipalEventType(1),
|
|
1540
|
+
withdrewPrincipalV1: this.withdrewPrincipalEventType(1),
|
|
631
1541
|
// reward harvesting
|
|
632
|
-
|
|
1542
|
+
harvestedRewardsV1: this.harvestedRewardsEventType(1),
|
|
1543
|
+
// v2
|
|
1544
|
+
// staking pools
|
|
1545
|
+
// creation
|
|
1546
|
+
createdVaultV2: this.createdVaultEventType(2),
|
|
1547
|
+
// mutation
|
|
1548
|
+
initializedRewardV2: this.initializedRewardEventType(2),
|
|
1549
|
+
addedRewardV2: this.addedRewardEventType(2),
|
|
1550
|
+
updatedEmissionsV2: this.updatedEmissionsEventType(),
|
|
1551
|
+
// staking positions
|
|
1552
|
+
// creation
|
|
1553
|
+
stakedV2: this.stakedEventType(2),
|
|
1554
|
+
// locking
|
|
1555
|
+
lockedV2: this.lockedEventType(2),
|
|
1556
|
+
unlockedV2: this.unlockedEventType(2),
|
|
1557
|
+
// staking
|
|
1558
|
+
depositedPrincipalV2: this.depositedPrincipalEventType(2),
|
|
1559
|
+
withdrewPrincipalV2: this.withdrewPrincipalEventType(2),
|
|
1560
|
+
// reward harvesting
|
|
1561
|
+
harvestedRewardsV2: this.harvestedRewardsEventType(2),
|
|
633
1562
|
};
|
|
634
1563
|
this.moveErrors = {
|
|
635
1564
|
[this.addresses.packages.vaults]: {
|
|
636
|
-
[FarmsApi.constants.moduleNames.
|
|
1565
|
+
[FarmsApi.constants.moduleNames.vaultV1]: {
|
|
637
1566
|
/// A user attempts provides a `Coin` or `u64` with value zero.
|
|
638
1567
|
0: "Zero",
|
|
639
1568
|
/// A user provides a `StakedPosition` and a `AfterburnerVault` that don't correspond with one
|
|
@@ -662,6 +1591,7 @@ class FarmsApi {
|
|
|
662
1591
|
9: "Invalid Lock Multiplier",
|
|
663
1592
|
10: "Invalid Argument",
|
|
664
1593
|
11: "Deprecated",
|
|
1594
|
+
12: "Afterburner Vault Still Active",
|
|
665
1595
|
},
|
|
666
1596
|
[FarmsApi.constants.moduleNames.stakedPosition]: {
|
|
667
1597
|
/// A user attempts provides a `Coin` or `u64` with value zero.
|
|
@@ -687,6 +1617,60 @@ class FarmsApi {
|
|
|
687
1617
|
10: "Zero Rewards",
|
|
688
1618
|
},
|
|
689
1619
|
},
|
|
1620
|
+
[this.addresses.packages.vaultsV2]: {
|
|
1621
|
+
[FarmsApi.constants.moduleNames.vaultV2]: {
|
|
1622
|
+
/// A user provides a `Coin` with value zero.
|
|
1623
|
+
0: "Zero",
|
|
1624
|
+
/// A user tries to create a `Vault` where `min_lock_duration_ms` is strictly greater than
|
|
1625
|
+
/// `max_lock_duration_ms`.
|
|
1626
|
+
1: "Invalid Min Max Lock Durations",
|
|
1627
|
+
/// A user tries to create a `Vault` and provides a `u8` that does not map to a valid lock
|
|
1628
|
+
/// enforcement policy.
|
|
1629
|
+
2: "Invalid Lock Enforcement",
|
|
1630
|
+
/// The creator of a `Vault` tries to update the emission schedule or add more of a specific
|
|
1631
|
+
/// reward type that has not yet been initialized into the `Vault`.
|
|
1632
|
+
3: "Emissions Not Initialized",
|
|
1633
|
+
/// A `Reward` `Coin` type was passed to a function and either the `Reward` type does not
|
|
1634
|
+
/// correspond to any of the `Vault`'s reward types--for the functions that act on the `Reward`
|
|
1635
|
+
/// type--or, for `initialize_reward`, the `Reward` type has already had its emissions initialized.
|
|
1636
|
+
4: "Invalid Reward Coin Type",
|
|
1637
|
+
/// A user attempts to withdraw an amount of principal that would bring their position below the
|
|
1638
|
+
/// `Vault`'s `min_stake_amount`.
|
|
1639
|
+
5: "Invalid Stake Amount",
|
|
1640
|
+
/// A user tries to claim zero rewards
|
|
1641
|
+
6: "Zero Claim",
|
|
1642
|
+
/// A user provided a max lock multiplier that was strictly less than the minimum lower bound.
|
|
1643
|
+
7: "Invalid Lock Multiplier",
|
|
1644
|
+
},
|
|
1645
|
+
[FarmsApi.constants.moduleNames.stakedPosition]: {
|
|
1646
|
+
/// A user attempts to perform a restricted action on a `StakedPosition` that is still locked. For
|
|
1647
|
+
/// example `unlock` can only be called on a `StakedPosition` that is no longer locked.
|
|
1648
|
+
0: "Locked",
|
|
1649
|
+
/// A user provides a `StakedPosition` and a `Vault` that don't correspond with one another.
|
|
1650
|
+
/// This can only occur if two `Vault`s with the same underlying `Stake` generic are created.
|
|
1651
|
+
1: "Invalid Vault",
|
|
1652
|
+
/// A user tries to stake into a `Vault` with a `lock_duration_ms` below the vault's
|
|
1653
|
+
/// `min_lock_duration_ms`.
|
|
1654
|
+
2: "Invalid Lock Duration",
|
|
1655
|
+
/// A user attempts to withdraw an amount of principal that would bring their position below the
|
|
1656
|
+
/// `Vault`'s `min_stake_amount`.
|
|
1657
|
+
3: "Invalid Stake Amount",
|
|
1658
|
+
/// A user attempts to withdraw more principal than their `StakedPosition` holds.
|
|
1659
|
+
4: "Invalid Withdraw Amount",
|
|
1660
|
+
/// A user attempts to split more principal than their `StakedPosition` holds.
|
|
1661
|
+
5: "Invalid Split Amount",
|
|
1662
|
+
/// A user attempts to stake into a `Vault` that has no rewards.
|
|
1663
|
+
6: "Vault Is Inactive",
|
|
1664
|
+
/// A user requested to harvest a reward type for which they've only accrued less than the minimal
|
|
1665
|
+
/// claim amount.
|
|
1666
|
+
7: "Zero Rewards",
|
|
1667
|
+
/// A user attempts to stake into a `Vault` with a `LockEnforcement` policy that the vault does
|
|
1668
|
+
/// not support.
|
|
1669
|
+
8: "Invalid Lock Enforcement",
|
|
1670
|
+
/// A user attempts to call `destroy` on a `StakedPosition` that has unharvested rewards.
|
|
1671
|
+
9: "Position Has Unclaimed Rewards",
|
|
1672
|
+
},
|
|
1673
|
+
},
|
|
690
1674
|
};
|
|
691
1675
|
}
|
|
692
1676
|
}
|
|
@@ -696,10 +1680,12 @@ exports.FarmsApi = FarmsApi;
|
|
|
696
1680
|
// =========================================================================
|
|
697
1681
|
FarmsApi.constants = {
|
|
698
1682
|
moduleNames: {
|
|
699
|
-
|
|
1683
|
+
vaultV1: "afterburner_vault",
|
|
1684
|
+
vaultV2: "vault",
|
|
700
1685
|
stakedPosition: "staked_position",
|
|
701
1686
|
vaultRegistry: "vault_registry",
|
|
702
|
-
events: "
|
|
1687
|
+
events: "events",
|
|
1688
|
+
authority: "authority",
|
|
703
1689
|
},
|
|
704
1690
|
eventNames: {
|
|
705
1691
|
// staking pools
|
|
@@ -709,6 +1695,7 @@ FarmsApi.constants = {
|
|
|
709
1695
|
initializedReward: "InitializedRewardEvent",
|
|
710
1696
|
addedReward: "AddedRewardEvent",
|
|
711
1697
|
increasedEmissions: "IncreasedEmissionsEvent",
|
|
1698
|
+
updatedEmissions: "UpdatedEmissionsEvent",
|
|
712
1699
|
// staking positions
|
|
713
1700
|
// creation
|
|
714
1701
|
staked: "StakedEvent",
|
|
@@ -734,6 +1721,15 @@ FarmsApi.constants = {
|
|
|
734
1721
|
// =========================================================================
|
|
735
1722
|
// Helpers
|
|
736
1723
|
// =========================================================================
|
|
737
|
-
|
|
1724
|
+
/**
|
|
1725
|
+
* Checks if the input contains a one-time admin cap ID
|
|
1726
|
+
* @param inputs FarmOwnerOrOneTimeAdminCap object
|
|
1727
|
+
* @returns True if the input contains a one-time admin cap ID
|
|
1728
|
+
*/
|
|
738
1729
|
FarmsApi.isFarmOneTimeAdminCapId = (inputs) => "oneTimeAdminCapId" in inputs;
|
|
1730
|
+
/**
|
|
1731
|
+
* Gets the appropriate cap ID from the input
|
|
1732
|
+
* @param inputs FarmOwnerOrOneTimeAdminCap object
|
|
1733
|
+
* @returns Either the owner cap ID or one-time admin cap ID
|
|
1734
|
+
*/
|
|
739
1735
|
FarmsApi.farmCapId = (inputs) => "ownerCapId" in inputs ? inputs.ownerCapId : inputs.oneTimeAdminCapId;
|