lsts template
This commit is contained in:
parent
697f40eec0
commit
59588451b6
|
@ -230,100 +230,77 @@ const getLstStakePool = async (
|
|||
}
|
||||
};
|
||||
|
||||
const LSTExactIn = (
|
||||
inMint: string,
|
||||
nativeInAmount: string,
|
||||
stakePoolAddress: string,
|
||||
): string => {
|
||||
const LSTExactIn = (inMint: string, uiAmountIn: string): string => {
|
||||
const template = `tasks:
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- httpTask:
|
||||
url: https://api.sanctum.so/v1/swap/quote?input=${inMint}&outputLstMint=So11111111111111111111111111111111111111112&amount=${nativeInAmount}&mode=ExactIn
|
||||
- jsonParseTask:
|
||||
path: $.outAmount
|
||||
- divideTask:
|
||||
scalar: ${nativeInAmount}
|
||||
onFailure:
|
||||
- splStakePoolTask:
|
||||
pubkey: ${stakePoolAddress}
|
||||
- cacheTask:
|
||||
cacheItems:
|
||||
- variableName: poolTokenSupply
|
||||
job:
|
||||
tasks:
|
||||
- jsonParseTask:
|
||||
path: $.uiPoolTokenSupply
|
||||
aggregationMethod: NONE
|
||||
- variableName: totalStakeLamports
|
||||
job:
|
||||
tasks:
|
||||
- jsonParseTask:
|
||||
path: $.uiTotalLamports
|
||||
aggregationMethod: NONE
|
||||
- valueTask:
|
||||
big: \${totalStakeLamports}
|
||||
- divideTask:
|
||||
big: \${poolTokenSupply}
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- sanctumLstPriceTask:
|
||||
lstMint: ${inMint}
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- valueTask:
|
||||
big: ${uiAmountIn}
|
||||
- divideTask:
|
||||
job:
|
||||
tasks:
|
||||
- jupiterSwapTask:
|
||||
inTokenAddress: So11111111111111111111111111111111111111112
|
||||
outTokenAddress: ${inMint}
|
||||
baseAmountString: ${uiAmountIn}
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- multiplyTask:
|
||||
job:
|
||||
tasks:
|
||||
- oracleTask:
|
||||
pythAddress: H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG
|
||||
pythAllowedConfidenceInterval: 10`;
|
||||
job:
|
||||
tasks:
|
||||
- oracleTask:
|
||||
pythAddress: ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d
|
||||
pythAllowedConfidenceInterval: 10
|
||||
onFailure:
|
||||
- multiplyTask:
|
||||
job:
|
||||
tasks:
|
||||
- oracleTask:
|
||||
switchboardAddress: AEcJSgRBkU9WnKCBELj66TPFfzhKWBWa4tL7JugnonUa`;
|
||||
return template;
|
||||
};
|
||||
|
||||
const LSTExactOut = (
|
||||
inMint: string,
|
||||
nativeOutSolAmount: string,
|
||||
stakePoolAddress: string,
|
||||
): string => {
|
||||
const LSTExactOut = (inMint: string, uiOutSolAmount: string): string => {
|
||||
const template = `tasks:
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- cacheTask:
|
||||
cacheItems:
|
||||
- variableName: QTY
|
||||
job:
|
||||
tasks:
|
||||
- httpTask:
|
||||
url: https://api.sanctum.so/v1/swap/quote?input=${inMint}&outputLstMint=So11111111111111111111111111111111111111112&amount=${nativeOutSolAmount}&mode=ExactOut
|
||||
- jsonParseTask:
|
||||
path: $.inAmount
|
||||
- httpTask:
|
||||
url: https://api.sanctum.so/v1/swap/quote?input=${inMint}&outputLstMint=So11111111111111111111111111111111111111112&amount=\${QTY}&mode=ExactIn
|
||||
- jsonParseTask:
|
||||
path: $.outAmount
|
||||
- divideTask:
|
||||
big: \${QTY}
|
||||
onFailure:
|
||||
- splStakePoolTask:
|
||||
pubkey: ${stakePoolAddress}
|
||||
- cacheTask:
|
||||
cacheItems:
|
||||
- variableName: poolTokenSupply
|
||||
job:
|
||||
tasks:
|
||||
- jsonParseTask:
|
||||
path: $.uiPoolTokenSupply
|
||||
aggregationMethod: NONE
|
||||
- variableName: totalStakeLamports
|
||||
job:
|
||||
tasks:
|
||||
- jsonParseTask:
|
||||
path: $.uiTotalLamports
|
||||
aggregationMethod: NONE
|
||||
- valueTask:
|
||||
big: \${totalStakeLamports}
|
||||
- divideTask:
|
||||
big: \${poolTokenSupply}
|
||||
- multiplyTask:
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- sanctumLstPriceTask:
|
||||
lstMint: ${inMint}
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- cacheTask:
|
||||
cacheItems:
|
||||
- variableName: QTY
|
||||
job:
|
||||
tasks:
|
||||
- jupiterSwapTask:
|
||||
inTokenAddress: So11111111111111111111111111111111111111112
|
||||
outTokenAddress: ${inMint}
|
||||
baseAmountString: ${uiOutSolAmount}
|
||||
- jupiterSwapTask:
|
||||
inTokenAddress: ${inMint}
|
||||
outTokenAddress: So11111111111111111111111111111111111111112
|
||||
baseAmountString: \${QTY}
|
||||
- divideTask:
|
||||
big: \${QTY}
|
||||
- conditionalTask:
|
||||
attempt:
|
||||
- multiplyTask:
|
||||
job:
|
||||
tasks:
|
||||
- oracleTask:
|
||||
pythAddress: H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG
|
||||
pythAllowedConfidenceInterval: 10`;
|
||||
- oracleTask:
|
||||
pythAddress: ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d
|
||||
pythAllowedConfidenceInterval: 10
|
||||
onFailure:
|
||||
- multiplyTask:
|
||||
job:
|
||||
tasks:
|
||||
- oracleTask:
|
||||
switchboardAddress: AEcJSgRBkU9WnKCBELj66TPFfzhKWBWa4tL7JugnonUa`;
|
||||
return template;
|
||||
};
|
||||
|
||||
|
@ -459,11 +436,7 @@ async function setupSwitchboard(userProvider: AnchorProvider) {
|
|||
? OracleJob.fromYaml(
|
||||
LSTExactIn(
|
||||
TOKEN_MINT,
|
||||
toNative(
|
||||
Math.ceil(Number(swapValue) / price),
|
||||
tokeninfo!.decimals,
|
||||
).toString(),
|
||||
lstPool,
|
||||
Math.ceil(Number(swapValue) / price).toString(),
|
||||
),
|
||||
)
|
||||
: OracleJob.fromObject({
|
||||
|
@ -536,11 +509,7 @@ async function setupSwitchboard(userProvider: AnchorProvider) {
|
|||
? OracleJob.fromYaml(
|
||||
LSTExactOut(
|
||||
TOKEN_MINT,
|
||||
toNative(
|
||||
Math.ceil(Number(swapValue) / price),
|
||||
tokeninfo!.decimals,
|
||||
).toString(),
|
||||
lstPool,
|
||||
Math.ceil(Number(swapValue) / price).toString(),
|
||||
),
|
||||
)
|
||||
: OracleJob.fromObject({
|
||||
|
|
Loading…
Reference in New Issue