Skip to content

Commit

Permalink
rename purchaseNameInfo() to getPriceForMintingName()
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Nov 10, 2022
1 parent b5f7805 commit e1bfa49
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 109 deletions.
37 changes: 17 additions & 20 deletions contracts/SoulStore.sol
Expand Up @@ -176,32 +176,29 @@ contract SoulStore is PayDexAMM {
}

/// @notice Returns the price of the name minting
/// @dev Returns all current pricing and amount informations for a purchase
/// @dev Returns current pricing for name minting for a given name length and years period
/// @param paymentMethod Address of token that user want to pay
/// @param name Name of the new soul name
/// @param yearsPeriod Years of validity of the name
/// @return priceInStableCoin Current price of the name minting in stable coin
/// @return priceInETH Current price of the name minting in native token (ETH)
/// @return priceInUtilityToken Current price of the name minting in utility token ($MASA)
function purchaseNameInfo(string memory name, uint256 yearsPeriod)
public
view
returns (
uint256 priceInStableCoin,
uint256 priceInETH,
uint256 priceInUtilityToken
)
{
/// @return Current price of the name minting in the given payment method
function getPriceForMintingName(
address paymentMethod,
string memory name,
uint256 yearsPeriod
) public view returns (uint256) {
uint256 mintingPrice = getNameRegistrationPricePerYear(name).mul(
yearsPeriod
);

priceInStableCoin = mintingPrice;
// get swapped price in ETH and $MASA
priceInETH = _convertFromStableCoin(wrappedNativeToken, mintingPrice);
priceInUtilityToken = _convertFromStableCoin(
utilityToken,
mintingPrice
);
if (paymentMethod == stableCoin) {
return mintingPrice;
} else if (paymentMethod == address(0)) {
return _convertFromStableCoin(wrappedNativeToken, mintingPrice);
} else if (paymentMethod == utilityToken || erc20token[paymentMethod]) {
return _convertFromStableCoin(paymentMethod, mintingPrice);
} else {
revert("INVALID_PAYMENT_METHOD");
}
}

/* ========== PRIVATE FUNCTIONS ========== */
Expand Down
49 changes: 24 additions & 25 deletions docs/SoulStore.md
Expand Up @@ -92,6 +92,30 @@ Returns the price of register a name per year in stable coin for an specific len
|---|---|---|
| _0 | uint256 | Price in stable coin for that name length |

### getPriceForMintingName

```solidity
function getPriceForMintingName(address paymentMethod, string name, uint256 yearsPeriod) external view returns (uint256)
```

Returns the price of the name minting

*Returns current pricing for name minting for a given name length and years period*

#### Parameters

| Name | Type | Description |
|---|---|---|
| paymentMethod | address | Address of token that user want to pay |
| name | string | Name of the new soul name |
| yearsPeriod | uint256 | Years of validity of the name |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | Current price of the name minting in the given payment method |

### nameRegistrationPricePerYear

```solidity
Expand Down Expand Up @@ -198,31 +222,6 @@ Mints a new Soul Name purchasing it
|---|---|---|
| _0 | uint256 | TokenId of the new sou name |

### purchaseNameInfo

```solidity
function purchaseNameInfo(string name, uint256 yearsPeriod) external view returns (uint256 priceInStableCoin, uint256 priceInETH, uint256 priceInUtilityToken)
```

Returns the price of the name minting

*Returns all current pricing and amount informations for a purchase*

#### Parameters

| Name | Type | Description |
|---|---|---|
| name | string | Name of the new soul name |
| yearsPeriod | uint256 | Years of validity of the name |

#### Returns

| Name | Type | Description |
|---|---|---|
| priceInStableCoin | uint256 | Current price of the name minting in stable coin |
| priceInETH | uint256 | Current price of the name minting in native token (ETH) |
| priceInUtilityToken | uint256 | Current price of the name minting in utility token ($MASA) |

### removeErc20Token

```solidity
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Expand Up @@ -2,3 +2,5 @@ export const SWAPROUTER_GOERLI = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
export const USDC_GOERLI = "0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C";
export const MASA_GOERLI = "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60"; // It's the DAI address on goerli
export const WETH_GOERLI = "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6";

export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";

0 comments on commit e1bfa49

Please sign in to comment.