@orca-so/whirlpool-sdk
Version:
Whirlpool SDK for the Orca protocol.
65 lines (64 loc) • 3.42 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.WhirlpoolAdminImpl = void 0;
const whirlpool_client_sdk_1 = require("@orca-so/whirlpool-client-sdk");
const anchor_1 = require("@project-serum/anchor");
const address_1 = require("../utils/address");
class WhirlpoolAdminImpl {
constructor(ctx) {
this.ctx = ctx;
}
// TODO: Context dictates that we are current in an existing configAddress space.
// So it's a bit weird to have a WhirlpoolAdmin of a certain context initing another config
// Maybe place this in WhirlpoolAdminInstance?
initConfig(params) {
const { whirlpoolConfigKeypair, feeAuthority, collectProtocolFeesAuthority, rewardEmissionsSuperAuthority, defaultProtocolFeeRate, } = params;
const client = new whirlpool_client_sdk_1.WhirlpoolClient(this.ctx);
return client.initConfigTx({
whirlpoolConfigKeypair,
feeAuthority: (0, address_1.toPubKey)(feeAuthority),
collectProtocolFeesAuthority: (0, address_1.toPubKey)(collectProtocolFeesAuthority),
rewardEmissionsSuperAuthority: (0, address_1.toPubKey)(rewardEmissionsSuperAuthority),
defaultProtocolFeeRate,
funder: this.ctx.provider.wallet.publicKey,
});
}
initFeeTier(params) {
const { whirlpoolConfigKey, tickSpacing, feeAuthority, defaultFeeRate } = params;
const client = new whirlpool_client_sdk_1.WhirlpoolClient(this.ctx);
const feeTierPda = (0, whirlpool_client_sdk_1.getFeeTierPda)((0, address_1.toPubKey)(this.ctx.program.programId), (0, address_1.toPubKey)(whirlpoolConfigKey), tickSpacing);
return client.initFeeTierTx({
whirlpoolConfigKey: (0, address_1.toPubKey)(whirlpoolConfigKey),
feeAuthority: (0, address_1.toPubKey)(feeAuthority),
feeTierPda,
tickSpacing,
defaultFeeRate,
funder: this.ctx.provider.wallet.publicKey,
});
}
setFeeAuthority(newFeeAuthority) {
const client = new whirlpool_client_sdk_1.WhirlpoolClient(this.ctx);
return client.setFeeAuthorityTx({
whirlpoolsConfig: (0, anchor_1.translateAddress)(this.ctx.configAddress),
feeAuthority: this.ctx.provider.wallet.publicKey,
newFeeAuthority: (0, address_1.toPubKey)(newFeeAuthority),
});
}
setCollectProtocolFeeAuthority(newCollectProtocolFeesAuthority) {
const client = new whirlpool_client_sdk_1.WhirlpoolClient(this.ctx);
return client.setCollectProtocolFeesAuthorityTx({
whirlpoolsConfig: this.ctx.configAddress,
collectProtocolFeesAuthority: this.ctx.provider.wallet.publicKey,
newCollectProtocolFeesAuthority: (0, address_1.toPubKey)(newCollectProtocolFeesAuthority),
});
}
setRewardEmissionsBySuperAuthority(rewardEmissionsSuperAuthority, newRewardEmissionsSuperAuthority) {
const client = new whirlpool_client_sdk_1.WhirlpoolClient(this.ctx);
return client.setRewardEmissionsSuperAuthorityTx({
whirlpoolsConfig: this.ctx.configAddress,
rewardEmissionsSuperAuthority: (0, address_1.toPubKey)(rewardEmissionsSuperAuthority),
newRewardEmissionsSuperAuthority: (0, address_1.toPubKey)(newRewardEmissionsSuperAuthority),
});
}
}
exports.WhirlpoolAdminImpl = WhirlpoolAdminImpl;
;