-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathICurve.sol
More file actions
88 lines (83 loc) · 4.01 KB
/
Copy pathICurve.sol
File metadata and controls
88 lines (83 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;
import {CurveErrorCodes} from "./CurveErrorCodes.sol";
interface ICurve {
/**
* @notice Validates if a delta value is valid for the curve. The criteria for
* validity can be different for each type of curve, for instance ExponentialCurve
* requires delta to be greater than 1.
* @param delta The delta value to be validated
* @return valid True if delta is valid, false otherwise
*/
function validateDelta(uint128 delta) external pure returns (bool valid);
/**
* @notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token.
* @param newSpotPrice The new spot price to be set
* @return valid True if the new spot price is valid, false otherwise
*/
function validateSpotPrice(uint128 newSpotPrice) external view returns (bool valid);
/**
* @notice Given the current state of the pair and the trade, computes how much the user
* should pay to purchase an NFT from the pair, the new spot price, and other values.
* @param spotPrice The current selling spot price of the pair, in tokens
* @param delta The delta parameter of the pair, what it means depends on the curve
* @param numItems The number of NFTs the user is buying from the pair
* @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
* @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
* @return error Any math calculation errors, only Error.OK means the returned values are valid
* @return newSpotPrice The updated selling spot price, in tokens
* @return newDelta The updated delta, used to parameterize the bonding curve
* @return inputValue The amount that the user should pay, in tokens
* @return tradeFee The amount that is sent to the trade fee recipient
* @return protocolFee The amount of fee to send to the protocol, in tokens
*/
function getBuyInfo(
uint128 spotPrice,
uint128 delta,
uint256 numItems,
uint256 feeMultiplier,
uint256 protocolFeeMultiplier
)
external
view
returns (
CurveErrorCodes.Error error,
uint128 newSpotPrice,
uint128 newDelta,
uint256 inputValue,
uint256 tradeFee,
uint256 protocolFee
);
/**
* @notice Given the current state of the pair and the trade, computes how much the user
* should receive when selling NFTs to the pair, the new spot price, and other values.
* @param spotPrice The current selling spot price of the pair, in tokens
* @param delta The delta parameter of the pair, what it means depends on the curve
* @param numItems The number of NFTs the user is selling to the pair
* @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
* @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
* @return error Any math calculation errors, only Error.OK means the returned values are valid
* @return newSpotPrice The updated selling spot price, in tokens
* @return newDelta The updated delta, used to parameterize the bonding curve
* @return outputValue The amount that the user should receive, in tokens
* @return tradeFee The amount that is sent to the trade fee recipient
* @return protocolFee The amount of fee to send to the protocol, in tokens
*/
function getSellInfo(
uint128 spotPrice,
uint128 delta,
uint256 numItems,
uint256 feeMultiplier,
uint256 protocolFeeMultiplier
)
external
view
returns (
CurveErrorCodes.Error error,
uint128 newSpotPrice,
uint128 newDelta,
uint256 outputValue,
uint256 tradeFee,
uint256 protocolFee
);
}