Created
September 5, 2022 23:26
-
-
Save anilhelvaci/aee3a844292a0b9834ef88fa414757c4 to your computer and use it in GitHub Desktop.
This code snippet shows how to push a price up in native Agoric AMM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const moveFromCentralPriceUp = async (zoe, | |
ammPublicFacet, | |
secondaryR, | |
centralR, | |
liquidityIssuer, | |
upperBoundry, | |
swapInterval = 1n) => { | |
const { | |
swapSecondaryForCentral, | |
makeCentral, | |
makeSecondary, | |
} = await makeLiquidityInvitations(zoe, ammPublicFacet, secondaryR, centralR, liquidityIssuer); | |
const { amountOut } = await E(ammPublicFacet).getInputPrice(makeCentral(1n), makeSecondary(0n)); | |
let inputPriceAmountOut = amountOut; | |
while (AmountMath.isGTE(upperBoundry.numerator, inputPriceAmountOut)) { | |
await swapSecondaryForCentral(swapInterval); | |
const { amountOut } = await E(ammPublicFacet).getInputPrice(makeCentral(1n), makeSecondary(0n)); | |
inputPriceAmountOut = amountOut; | |
// console.log('INTER_INPUT_PRICE', inputPriceAmountOut); | |
} | |
return harden({ inputPriceAmountOut, swapInterval }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment