@orca-so/whirlpool-sdk
Version:
Whirlpool SDK for the Orca protocol.
43 lines (42 loc) • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PoolUtil = void 0;
const web3_js_1 = require("@solana/web3.js");
const percentage_1 = require("../../utils/public/percentage");
const address_1 = require("../address");
class PoolUtil {
constructor() { }
static isRewardInitialized(rewardInfo) {
return (!web3_js_1.PublicKey.default.equals(rewardInfo.mint) && !web3_js_1.PublicKey.default.equals(rewardInfo.vault));
}
static getFeeRate(feeRate) {
/**
* Smart Contract comment: https://github.com/orca-so/whirlpool/blob/main/programs/whirlpool/src/state/whirlpool.rs#L9-L11
* // Stored as hundredths of a basis point
* // u16::MAX corresponds to ~6.5%
* pub fee_rate: u16,
*/
return percentage_1.Percentage.fromFraction(feeRate, 1e6); // TODO
}
static getProtocolFeeRate(protocolFeeRate) {
/**
* Smart Contract comment: https://github.com/orca-so/whirlpool/blob/main/programs/whirlpool/src/state/whirlpool.rs#L13-L14
* // Stored as a basis point
* pub protocol_fee_rate: u16,
*/
return percentage_1.Percentage.fromFraction(protocolFeeRate, 1e4); // TODO
}
static orderMints(mintX, mintY) {
let mintA, mintB;
if (Buffer.compare((0, address_1.toPubKey)(mintX).toBuffer(), (0, address_1.toPubKey)(mintY).toBuffer()) < 0) {
mintA = mintX;
mintB = mintY;
}
else {
mintA = mintY;
mintB = mintX;
}
return [mintA, mintB];
}
}
exports.PoolUtil = PoolUtil;