Skip to content

Commit

Permalink
added 250 ppm slippage by default
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Jan 16, 2023
1 parent 0e23ccd commit 66ddcc2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/contracts/masa-contracts.ts
Expand Up @@ -274,19 +274,26 @@ export class MasaContracts {
signer: ethers.Signer,
paymentMethod: PaymentMethod,
nameLength: number,
duration = 1
duration = 1,
slippage: number | undefined = 250
): Promise<{
price: BigNumber;
paymentAddress: string;
formattedPrice: string;
}> {
const paymentAddress = this.getPaymentAddress(paymentMethod);
const price = await this.identity.SoulStoreContract.getPriceForMintingName(
let price = await this.identity.SoulStoreContract.getPriceForMintingName(
paymentAddress,
nameLength,
duration
);

if (slippage) {
if (paymentMethod === "eth") {
price = price.add(price.mul(slippage).div(10000));
}
}

let decimals = 18;
if (paymentAddress !== ethers.constants.AddressZero) {
const contract = ERC20__factory.connect(paymentAddress, signer);
Expand Down

0 comments on commit 66ddcc2

Please sign in to comment.